5#define DAC_CLK_HZ 25000000
6#define DAC_SIN_TABLE_SZ 45
16const u16 DAC_Sin[] = {410, 467, 523, 576, 627, 673, 714, 749, 778, 799, 813, 819, 817, 807, 789,
17 764, 732, 694, 650, 602, 550, 495, 438, 381, 324, 270, 217, 169, 125, 87,
18 55, 30, 12, 2, 0, 6, 20, 41, 70, 105, 146, 193, 243, 297, 353};
40 sample /= (10 / volume);
58 LPC_DAC->DACR = (volumed_sample << 6);
69 LPC_PINCON->PINSEL1 |= (2 << 20);
70 LPC_GPIO0->FIODIR |= (1 << 26);
78 LPC_PINCON->PINSEL1 &= ~(3 << 20);
79 LPC_GPIO0->FIODIR &= ~(1 << 26);
97 .match = get_tone_timing(tone.
note, tone.
octave)});
107 .match = tone_duration});
123 LPC_DAC->DACR &= ~(0x3FF << 6);
_PRIVATE void next_sample(void)
bool DAC_BUZIsPlaying(void)
_PRIVATE TIMER DAC_SecondsTimer
void DAC_BUZSetVolume(u8 volume)
Sets the volume of the buzzer.
_PRIVATE TIMER DAC_SamplesTimer
void DAC_BUZInit(u8 timer_a, u8 timer_b, u8 int_priority)
Initializes the DAC peripheral.
const u16 DAC_Sin[]
Sine wave samples for the DAC. They represent one complete period. Each sample needs to be sent to th...
_PRIVATE u32 DAC_SinTableIndex
_PRIVATE u8 DAC_SinVolume
_PRIVATE u16 adjust_sample_volume(u16 sample, u8 volume)
void DAC_BUZPlay(DAC_Tone tone, u16 bpm)
Plays the given note for the given duration.
void TIMER_Reset(TIMER timer)
Resets a TIMER peripheral without deconfiguring it.
void TIMER_Init(TIMER *timer, u8 which, u32 prescaler, u8 int_priority)
Initializes a TIMER peripheral.
void TIMER_Disable(TIMER timer)
Disables a TIMER peripheral.
void TIMER_Enable(TIMER timer)
Enables a TIMER peripheral.
bool TIMER_IsEnabled(TIMER timer)
Checks if a TIMER peripheral is enabled.
void TIMER_Deinit(TIMER timer)
Deconfigures a TIMER peripheral (also match registers).
void TIMER_SetMatch(TIMER timer, TIMER_MatchRegister match_reg)
Sets the match value for a match register of a TIMER peripheral.
void TIMER_SetInterruptHandler(TIMER timer, u8 source, TIMER_InterruptHandler handler)
Sets the interrupt handler for a TIMER peripheral, on a specific source between the 4 match registers...
#define IS_BETWEEN_EQ(value, low, hi)