BSP Buzzer Module
Section titled “BSP Buzzer Module”Board-level view of the buzzer: how a BSP wires the shared LEDC driver. The application side (sound events, priorities, customization) is the sound module, documented in buzzer.md and sound_system.md.
The former application layer (Buzzer class / esp3d_buzzer, esp3d_notes.h, blocking buzzer_bip(), malloc + task based buzzer_play(), buzzer_tone.h) was removed in a14.
Board Constants (board_config.h, PiBot)
Section titled “Board Constants (board_config.h, PiBot)”| Constant | Value | Meaning |
|---|---|---|
BUZZER_PIN | GPIO_NUM_26 | Buzzer GPIO |
BUZZER_ACTIVE_HIGH_FLAG | 1 | GPIO level for buzzer on |
BUZZER_PWM_FREQ_HZ | 1000 | Default PWM frequency (each note sets its own) |
BUZZER_PWM_RESOLUTION_BITS | 10 | Duty resolution |
BUZZER_PWM_TIMER_IDX / BUZZER_PWM_CHANNEL_IDX | 1 / 1 | LEDC timer / channel |
BUZZER_PWM_DUTY_PERCENT | 15 | Volume (1–50 %, 50 = loudest); lowered because SC8002B current peaks on fast repeated key beeps are suspected of causing BROWNOUT resets (2026-11-01, not confirmed on hardware) |
buzzer_def.h
Section titled “buzzer_def.h”buzzer_config_t buzzer_cfg = { .output_invert = !BUZZER_ACTIVE_HIGH_FLAG, // Invert if not active-high .gpio_num = BUZZER_PIN, .timer_idx = BUZZER_PWM_TIMER_IDX, .channel_idx = BUZZER_PWM_CHANNEL_IDX, .freq_hz = BUZZER_PWM_FREQ_HZ, .resolution_bits = BUZZER_PWM_RESOLUTION_BITS, .duty_percent = BUZZER_PWM_DUTY_PERCENT,};board_init()
Section titled “board_init()”#if (ESP3D_BUZZER_FEATURE) ret = buzzer_configure(&buzzer_cfg); if (ret != ESP_OK) { esp3d_log_e("Buzzer initialization failed"); return ret; }#endif // ESP3D_BUZZER_FEATUREDriver API (hardware/common/drivers/buzzer/buzzer.h)
Section titled “Driver API (hardware/common/drivers/buzzer/buzzer.h)”| Function | Description |
|---|---|
buzzer_configure(const buzzer_config_t *config) | LEDC timer + channel setup for the buzzer GPIO |
buzzer_tone_start(uint16_t freq_hz) | Continuous tone, non-blocking, safe from an esp_timer callback; 0 = silence |
buzzer_tone_stop(void) | Silence, non-blocking |
Only the sound module’s tone backend calls buzzer_tone_start() / buzzer_tone_stop(), from its esp_timer callback, so there is no concurrent LEDC access.
Boards without a buzzer leave BUZZER_SERVICE OFF (today only pibot_pendant_v1_0 enables it). The Factory apps and the PiBot custom bootloader have their own standalone buzzer code, see buzzer.md “Factory App & Bootloader Buzzer”.
Related Modules
Section titled “Related Modules”- buzzer — sound module, events, customization
- bsp_board_initialization —
board_init() - pibot_pendant_v1_0_bsp — PiBot BSP