![]() |
Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
|
Provides a driver for playing musical notes on a PWM-driven buzzer. More...
#include "stm32h7xx_hal.h"

Go to the source code of this file.
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... | |
Macros | |
| #define | REST 0 |
| A rest (silence) in a melody. | |
| #define | NOTE_Gb5 740 |
| Note G-flat, 5th octave. | |
| #define | NOTE_D6 1175 |
| Note D, 6th octave. | |
| #define | NOTE_Db6 1109 |
| Note D-flat, 6th octave. | |
| #define | NOTE_B5 988 |
| Note B, 5th octave. | |
| #define | NOTE_A5 880 |
| Note A, 5th octave. | |
| #define | TEMPO_BASE_MS 100 |
| The base duration for a note, in milliseconds. | |
| #define | DURATION_QUARTER (TEMPO_BASE_MS) |
| Duration of a quarter note. | |
| #define | DURATION_EIGHTH (TEMPO_BASE_MS / 2) |
| Duration of an eighth note. | |
| #define | DURATION_HALF (TEMPO_BASE_MS * 2) |
| Duration of a half note. | |
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. | |
Provides a driver for playing musical notes on a PWM-driven buzzer.
This module abstracts the low-level timer (TIM) peripheral to provide a simple interface for initializing a buzzer and playing melodies. It includes definitions for musical notes and a structure for defining a song.
Definition in file buzzer.h.