AVRly - AVR Development Resources
am_radio.h
Go to the documentation of this file.
1/******************************************************************************
2 @copyright Copyright © 2022 by Jason Duffy.
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21******************************************************************************/
22
23/**
24 * @file am_radio.h
25 * @ingroup am_radio
26 * @author Jason Duffy
27 * @date 10th September 2022
28 * @brief Driver for a small, low power AM radio transmitter, to broadcast
29 * monophonic square wave tones over a short distance. This project was
30 * inspired by the book "Make: AVR Programming" by Elliot Williams.
31 *
32 * Only tested with F_CPU = 8MHZ, but will build on this later to make it work
33 * with other CPU speeds.
34 */
35
36#ifndef AM_RADIO_DOT_H
37#define AM_RADIO_DOT_H
38
39#include <stdint.h>
40#include "scale.h"
41
42
43/**
44 * Enum to expose the predefined carrier frequency options.
45 * 1000KHZ (1MHZ) is ideal, but may be taken in your locality so try another if
46 * there is too much interferance.
47 */
48typedef enum
49{
50 _500_KHZ = 500000,
51 _570_KHZ = 570000,
52 _670_KHZ = 670000,
53 _800_KHZ = 800000,
54 _1000_KHZ = 1000000,
55 _1333_KHZ = 1333000,
57
58
59/**
60 * Enum to expose the predefined duration options.
61 */
62typedef enum
63{
64 SEMIBREVE,
65 MINIM,
66 CROTCHET,
67 QUAVER,
68 SEMIQUAVER,
69 DEMISEMIQUAVER,
71
72
73/**
74 * Initialises timer/counter for radio transmission at a specified carrier frequency.
75 */
76void init_am_radio(frequency_khz_t carrier_freq);
77
78/**
79 * Sets tempo for musical tones to be transmitted (in BPM).
80 */
81void am_radio_set_tempo(uint8_t tempo);
82
83/**
84 * Transmits a square wave, monophonic note for the specified duration.
85 */
87
88/**
89 * Waits a specified duration before playing the next note.
90 */
91void am_radio_rest(note_duration_t rest_length);
92
93/**
94 * Test sequence, transmits an arpeggio scale in C major.
95 */
96void arpeggio_in_c_test(void);
97
98
99#endif //AM_RADIO_DOT_H
100
101/*** end of file ***/
void am_radio_transmit_note(note_pitch_t pitch, note_duration_t note_length)
Transmits a square wave, monophonic note for the specified duration.
Definition: am_radio.c:94
void am_radio_set_tempo(uint8_t tempo)
Sets tempo for musical tones to be transmitted (in BPM).
Definition: am_radio.c:80
void init_am_radio(frequency_khz_t carrier_freq)
Initialises timer/counter for radio transmission at a specified carrier frequency.
Definition: am_radio.c:47
frequency_khz_t
Enum to expose the predefined carrier frequency options.
Definition: am_radio.h:49
void arpeggio_in_c_test(void)
Test sequence, transmits an arpeggio scale in C major.
Definition: am_radio.c:131
void am_radio_rest(note_duration_t rest_length)
Waits a specified duration before playing the next note.
Definition: am_radio.c:119
note_duration_t
Enum to expose the predefined duration options.
Definition: am_radio.h:63
Contains the count values required for the note pitches to work at 8MHZ F_CPU.
note_pitch_t
Enum to expose the count values required to generate the pitches.
Definition: scale.h:39