#include "dac_types.h"
#include "types.h"
#include <stdbool.h>
Go to the source code of this file.
◆ DAC_BUZDeinit()
void DAC_BUZDeinit |
( |
void |
| ) |
|
Definition at line 76 of file dac.c.
77{
78 LPC_PINCON->PINSEL1 &= ~(3 << 20);
79 LPC_GPIO0->FIODIR &= ~(1 << 26);
80
84}
_PRIVATE TIMER DAC_SecondsTimer
_PRIVATE TIMER DAC_SamplesTimer
void TIMER_Deinit(TIMER timer)
Deconfigures a TIMER peripheral (also match registers).
◆ DAC_BUZInit()
void DAC_BUZInit |
( |
u8 |
timer_a, |
|
|
u8 |
timer_b, |
|
|
u8 |
int_priority |
|
) |
| |
Initializes the DAC peripheral.
- Parameters
-
int_priority | The interrupt priority of the timer. If set to INT_PRIO_DEF, the default interrupt priority will be used. |
- Note
- This implementation requires the use of 2 timers to feed the DAC with samples and to play the note for the given duration. By giving these parameters to this function, you ensure that those timers are not and won't be used for other purposes.
Definition at line 66 of file dac.c.
67{
68
69 LPC_PINCON->PINSEL1 |= (2 << 20);
70 LPC_GPIO0->FIODIR |= (1 << 26);
71
74}
void TIMER_Init(TIMER *timer, u8 which, u32 prescaler, u8 int_priority)
Initializes a TIMER peripheral.
◆ DAC_BUZIsPlaying()
bool DAC_BUZIsPlaying |
( |
void |
| ) |
|
Definition at line 114 of file dac.c.
115{
117}
bool TIMER_IsEnabled(TIMER timer)
Checks if a TIMER peripheral is enabled.
◆ DAC_BUZPlay()
Plays the given note for the given duration.
- Parameters
-
tone | The tone to be played |
bpm | The tempo of the note (i.e. 60, 120, 240, etc.) |
Definition at line 91 of file dac.c.
92{
93
97 .match = get_tone_timing(tone.
note, tone.
octave)});
98
99
100
101
102
107 .match = tone_duration});
108
109
112}
_PRIVATE void next_sample(void)
void TIMER_Enable(TIMER timer)
Enables a TIMER peripheral.
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...
◆ DAC_BUZSetVolume()
void DAC_BUZSetVolume |
( |
u8 |
volume | ) |
|
Sets the volume of the buzzer.
- Parameters
-
volume | The volume of the buzzer (between 0 and 10). |
Definition at line 86 of file dac.c.
87{
89}
_PRIVATE u8 DAC_SinVolume
#define IS_BETWEEN_EQ(value, low, hi)
◆ DAC_BUZStop()
void DAC_BUZStop |
( |
void |
| ) |
|
Definition at line 119 of file dac.c.
120{
123 LPC_DAC->DACR &= ~(0x3FF << 6);
124
127
130}
_PRIVATE u32 DAC_SinTableIndex
void TIMER_Reset(TIMER timer)
Resets a TIMER peripheral without deconfiguring it.
void TIMER_Disable(TIMER timer)
Disables a TIMER peripheral.