Expand description
This provides virtualized userspace access to a buzzer.
Each app can have one outstanding buzz request, and buzz requests will queue with each app getting exclusive access to the buzzer during its turn. Apps can specify the frequency and duration of the square wave buzz, but the duration is capped to prevent this from being annoying.
Apps can subscribe to an optional callback if they care about getting buzz done events.
§Usage
ⓘ
let virtual_pwm_buzzer = static_init!(
capsules::virtual_pwm::PwmPinUser<'static, nrf52::pwm::Pwm>,
capsules::virtual_pwm::PwmPinUser::new(mux_pwm, nrf5x::pinmux::Pinmux::new(31))
);
virtual_pwm_buzzer.add_to_mux();
let virtual_alarm_buzzer = static_init!(
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf5x::rtc::Rtc>,
capsules::virtual_alarm::VirtualMuxAlarm::new(mux_alarm)
);
virtual_alarm_buzzer.setup();
let pwm_buzzer = static_init!(
capsules::buzzer_pwm::PwmBuzzer<
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52833::rtc::Rtc>,
capsules::virtual_pwm::PwmPinUser<'static, nrf52833::pwm::Pwm>,
>,
capsules::buzzer_pwm::PwmBuzzer::new(
virtual_pwm_buzzer,
virtual_alarm_buzzer,
capsules::buzzer_pwm::DEFAULT_MAX_BUZZ_TIME_MS,
)
);
let buzzer_driver = static_init!(
capsules::buzzer_driver::Buzzer<
'static,
capsules::buzzer_pwm::PwmBuzzer<
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52833::rtc::Rtc>,
capsules::virtual_pwm::PwmPinUser<'static, nrf52833::pwm::Pwm>,
>,
>,
capsules::buzzer_driver::Buzzer::new(
pwm_buzzer,
capsules::buzzer_driver::DEFAULT_MAX_BUZZ_TIME_MS,
board_kernel.create_grant(capsules::buzzer_driver::DRIVER_NUM, &memory_allocation_capability)
)
);
pwm_buzzer.set_client(buzzer_driver);
virtual_alarm_buzzer.set_client(pwm_buzzer);
Structs§
Enums§
Constants§
- Standard max buzz time.