![]() |
Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
|
Low-level driver for the PWM buzzer. More...

Modules | |
| Musical Note and Tempo Definitions | |
Files | |
| file | buzzer.h |
| Provides a driver for playing musical notes on a PWM-driven buzzer. | |
Data Structures | |
| struct | note_t |
| Represents a single musical note with a frequency and duration. More... | |
| struct | buzzer_t |
| Represents the buzzer device handle. More... | |
Functions | |
| void | buzzer_init (buzzer_t *bz, TIM_HandleTypeDef *htim, uint32_t channel) |
| Initializes the buzzer object and its associated timer hardware. | |
| void | musica_maestro (buzzer_t *bz, const note_t *partition, uint16_t melody_length) |
| Plays a melody by iterating through an array of notes. | |
Variables | |
| buzzer_t | buzzer |
| Global instance of the buzzer object. | |
Low-level driver for the PWM buzzer.
| void buzzer_init | ( | buzzer_t * | bz, |
| TIM_HandleTypeDef * | htim, | ||
| uint32_t | channel | ||
| ) |
Initializes the buzzer object and its associated timer hardware.
Initializes the buzzer object.
This function should be called once at startup to associate the buzzer object with its hardware timer.
| [in,out] | bz | Pointer to the global buzzer_t object. |
| [in] | htim | Pointer to the initialized TIM_HandleTypeDef for the buzzer. |
| [in] | channel | The TIM_CHANNEL_x that the buzzer is connected to. |
Definition at line 23 of file buzzer.c.
References bz, Error_Handler(), buzzer_t::htim, NULL, and buzzer_t::tim_channel.
Referenced by main().


Plays a melody by iterating through an array of notes.
Plays a melody from an array of notes.
Iterates through the provided array of note_t structures, playing each note for its specified duration.
| [in] | bz | Pointer to the initialized buzzer_t object. |
| [in] | partition | An array of note_t objects representing the melody. |
| [in] | melody_length | The number of notes in the partition array. |
Definition at line 38 of file buzzer.c.
References bz, note_t::duration_ms, note_t::frequency, buzzer_t::htim, NULL, REST, buzzer_t::tim_channel, TIMER_CLOCK_FREQ, and TIMER_PRESCALER.
Referenced by main().
