tock
tock copied to clipboard
Define Buzzer HIL and PWM Buzzer Driver
Pull Request Overview
This pull request changes the way the buzzer driver works. Before this PR, the buzzer syscall driver assumed all buzzer systems work with PWM. This PR:
- defines a buzzer HIL
- provides a PWM buzzer driver that implements the buzzer HIL
- provides a generic buzzer syscall driver
- uses the driver for the Microbit, clue and acd boards
Testing Strategy
This pull request was tested using a Microbit.
TODO or Help Wanted
Feedback for the buzzer HIL is much appreciated.
Documentation Updated
- [x] Updated the relevant files in
/docs
, or no updates are required.
Formatting
- [x] Ran
make prepush
.
Before this PR, the buzzer syscall driver assumed all buzzer systems work with PWM.
Do you have an example for a buzzer which does not work with PWM? I I'm not mistaken, this PR only has an implementation for PWM-controlled buzzers, right?
Do you have an example for a buzzer which does not work with PWM? I I'm not mistaken, this PR only has an implementation for PWM-controlled buzzers, right?
You might be right, even tough I can think of having for instance an external device over some bus.
The main idea behind the HIL came from a use case where the buzzer was needed from another capsule.
I am not necessarily averse to having a buzzer HIL, but I think that there should be a compelling usecase for such peripherals which might be representable by a more general-purpose API. I figure an external chip will use some communication bus, which might be a more appropriate layer of abstraction in the kernel. Would you mind describing your usecase for controlling buzzers from within the kernel?
Why did you remove the support for multiple apps and queuing?
I figured that an app that wants to notify the user using the buzzer wants to do it immediately, not wait after another notification. Therefore the buzzer should play the sound instantly, otherwise it doesn't really serve its purpose.
@bradjc Have your concerns been addressed?
@bradjc Have your concerns been addressed?
No, not really. We currently have a virtualized buzzer that supports multiple apps, and this replaces it with one that makes the userspace app responsible for doing retries. Perhaps we need a new "buzz immediate" syscall or syscall driver that boards that only want immediate buzz (or if the platform can't provide an immediate buzz it returns an error) can use. But I don't see why we would get rid of the current support for queuing in the process.
I also don't see the need to change the name from buzzer_driver.rs
to buzzer.rs
. buzzer_driver
is more clear this is a userspace driver.
I believe this is now good to go. I changed the driver so that there is a separate syscall for the buzzer to immediately buzz, but I also kept a syscall for queuing buzz commands. I also returned to the old buzzer_driver.rs name.
I believe this is now good to go. I changed the driver so that there is a separate syscall for the buzzer to immediately buzz, but I also kept a syscall for queuing buzz commands. I also returned to the old buzzer_driver.rs name.
@bradjc?
@TeodoraMiu Looks like there are some simple conflicts to resolve.
Great!
bors r+