software:firmware
MakAir Firmware
buzzer.h File Reference

Buzzer related functions. More...

Go to the source code of this file.

Macros

#define WATCHDOG_TIMEOUT   1000000
 Watchdog timeout in microseconds. More...
 
#define BUZZER_TIMER   TIM5
 Hardware Timer to use for the buzzer. More...
 
#define BUZZER_TIM_CHANNEL   1
 Hardware Timer channel to use for the buzzer. More...
 

Functions

void Buzzer_Init ()
 Initialization of HardwareTimer for buzzer. More...
 
void Buzzer_Start (const uint32_t *Buzzer, uint32_t Size, bool RepeatBuzzer)
 Generic function to activate a buzzer. More...
 
void Buzzer_Low_Prio_Start (void)
 Activate the buzzer pattern for low priority alarms. More...
 
void Buzzer_Medium_Prio_Start (void)
 Activate the buzzer pattern for medium priority alarms. More...
 
void Buzzer_High_Prio_Start (void)
 Activate the buzzer pattern for high priority alarms. More...
 
void Buzzer_Boot_Start (void)
 Activate boot bip. More...
 
void Buzzer_Mute (void)
 Mute the buzzer for 120s. More...
 
void Buzzer_Resume (void)
 Resume the muted alarm. More...
 
void Buzzer_Stop (void)
 Stop Buzzer. More...
 

Detailed Description

Buzzer related functions.

Author
Makers For Life

Definition in file buzzer.h.

Macro Definition Documentation

◆ BUZZER_TIM_CHANNEL

#define BUZZER_TIM_CHANNEL   1

Hardware Timer channel to use for the buzzer.

Definition at line 17 of file buzzer.h.

◆ BUZZER_TIMER

#define BUZZER_TIMER   TIM5

Hardware Timer to use for the buzzer.

Definition at line 14 of file buzzer.h.

◆ WATCHDOG_TIMEOUT

#define WATCHDOG_TIMEOUT   1000000

Watchdog timeout in microseconds.

Definition at line 11 of file buzzer.h.

Function Documentation

◆ Buzzer_Boot_Start()

void Buzzer_Boot_Start ( void  )

Activate boot bip.

Definition at line 194 of file buzzer.cpp.

const uint32_t Buzzer_Boot[BUZZER_BOOT_SIZE]
Boot buzzer pattern definition, composed of multiple couple of states (Actif/Inactif) and duration (m...
Definition: buzzer.cpp:79
#define BUZZER_BOOT_SIZE
Boot buzzer pattern size.
Definition: buzzer.cpp:75
void Buzzer_Start(const uint32_t *Buzzer, uint32_t Size, bool RepeatBuzzer)
Generic function to activate a buzzer.
Definition: buzzer.cpp:140

◆ Buzzer_High_Prio_Start()

void Buzzer_High_Prio_Start ( void  )

Activate the buzzer pattern for high priority alarms.

Definition at line 186 of file buzzer.cpp.

const uint32_t Buzzer_High_Prio[BUZZER_HIGH_PRIO_SIZE]
High priority alarm buzzer pattern definition, composed of multiple couple of states (Actif/Inactif) ...
Definition: buzzer.cpp:52
#define BUZZER_HIGH_PRIO_SIZE
High priority alarm buzzer pattern size.
Definition: buzzer.cpp:48

◆ Buzzer_Init()

void Buzzer_Init ( )

Initialization of HardwareTimer for buzzer.

Definition at line 128 of file buzzer.cpp.

128  {
129  // Buzzer HardwareTimer object creation
130  BuzzerTim = new HardwareTimer(BUZZER_TIMER);
131 
133  // CPU Clock down to 10 kHz
134  BuzzerTim->setPrescaleFactor((BuzzerTim->getTimerClkFreq() / (TIMER_TICK_PER_MS * 1000)));
135  BuzzerTim->setOverflow(1); // don't care right now, timer is not started in init
136  BuzzerTim->setMode(BUZZER_TIM_CHANNEL, TIMER_OUTPUT_COMPARE, NC);
137  BuzzerTim->attachInterrupt(Update_IT_callback);
138 }
void Update_IT_callback(HardwareTimer *)
When timer period expires, switch to next state in the pattern of the buzzer.
Definition: buzzer.cpp:102
#define TIMER_TICK_PER_MS
Definition: buzzer.cpp:33
HardwareTimer * BuzzerTim
Definition: buzzer.cpp:91
#define BUZZER_TIMER
Hardware Timer to use for the buzzer.
Definition: buzzer.h:14
#define BUZZER_TIM_CHANNEL
Hardware Timer channel to use for the buzzer.
Definition: buzzer.h:17
void BuzzerControl_Off(void)
Switch buzzer OFF.

◆ Buzzer_Low_Prio_Start()

void Buzzer_Low_Prio_Start ( void  )

Activate the buzzer pattern for low priority alarms.

Definition at line 192 of file buzzer.cpp.

const uint32_t Buzzer_Low_Prio[BUZZER_LOW_PRIO_SIZE]
Low priority alarm buzzer pattern definition, composed of multiple couple of states (Actif/Inactif) a...
Definition: buzzer.cpp:71
#define BUZZER_LOW_PRIO_SIZE
Low priority alarm buzzer pattern size.
Definition: buzzer.cpp:67

◆ Buzzer_Medium_Prio_Start()

void Buzzer_Medium_Prio_Start ( void  )

Activate the buzzer pattern for medium priority alarms.

Definition at line 188 of file buzzer.cpp.

188  {
190 }
const uint32_t Buzzer_Medium_Prio[BUZZER_MEDIUM_PRIO_SIZE]
Medium priority alarm buzzer pattern definition, composed of multiple couple of states (Actif/Inactif...
Definition: buzzer.cpp:63
#define BUZZER_MEDIUM_PRIO_SIZE
Medium priority alarm buzzer pattern size.
Definition: buzzer.cpp:59

◆ Buzzer_Mute()

void Buzzer_Mute ( void  )

Mute the buzzer for 120s.

Definition at line 156 of file buzzer.cpp.

156  {
157  // If we are in Repeat and not muted, then an alarm is ringing
158  if ((Active_Buzzer_Repeat == true) && (Buzzer_Muted == false)) {
159  // Set the buzzer as muted
160  Buzzer_Muted = true;
161  // Reset the timer
162  BuzzerTim->setCount(0);
163  // Reset the index, so that we will restart after the mute period
165 
166  // Configuration of mute pattern
168  BuzzerTim->setOverflow(PAUSE_120S, TICK_FORMAT);
169 
170  // Timer starts. Required to configure output on GPIO
171  BuzzerTim->resume();
172  }
173 }
bool Active_Buzzer_Repeat
Definition: buzzer.cpp:87
bool Buzzer_Muted
Definition: buzzer.cpp:89
uint32_t Active_Buzzer_Index
Definition: buzzer.cpp:85
#define PAUSE_120S
Definition: buzzer.cpp:38

◆ Buzzer_Resume()

void Buzzer_Resume ( void  )

Resume the muted alarm.

Definition at line 175 of file buzzer.cpp.

175  {
176  BuzzerTim->setCount(0);
177  Buzzer_Muted = false;
179 
180  BuzzerTim->setOverflow(Active_Buzzer[Active_Buzzer_Index + 1u], TICK_FORMAT);
181 
182  // Timer starts. Required to configure output on GPIO
183  BuzzerTim->resume();
184 }
const uint32_t * Active_Buzzer
Definition: buzzer.cpp:84

◆ Buzzer_Start()

void Buzzer_Start ( const uint32_t *  Buzzer,
uint32_t  Size,
bool  RepeatBuzzer 
)

Generic function to activate a buzzer.

Parameters
BuzzerBuzzer pattern array
SizeSize of the buzzer pattern array
RepeatBuzzerIs pattern repeating after its end

Definition at line 140 of file buzzer.cpp.

140  {
141  BuzzerTim->setCount(0);
142  Active_Buzzer = Buzzer;
144  Active_Buzzer_Size = Size;
145  Active_Buzzer_Repeat = RepeatBuzzer;
146  Active_Buzzer_Has_Begun = false;
147  Buzzer_Muted = false;
148 
149  BuzzerTim->setPreloadEnable(false);
150  BuzzerTim->setOverflow(100, TICK_FORMAT);
151 
152  // Timer starts
153  BuzzerTim->resume();
154 }
bool Active_Buzzer_Has_Begun
Definition: buzzer.cpp:88
uint32_t Active_Buzzer_Size
Definition: buzzer.cpp:86

◆ Buzzer_Stop()

void Buzzer_Stop ( void  )

Stop Buzzer.

Definition at line 196 of file buzzer.cpp.

196  {
197  Active_Buzzer_Repeat = false;
198 
199  // Avoid unexpected infinite buzzing
201  BuzzerTim->pause();
202 }