-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a signal for when the CDC control state changes #1926
Conversation
embassy-usb/src/class/cdc_acm.rs
Outdated
@@ -30,6 +32,9 @@ const REQ_SET_LINE_CODING: u8 = 0x20; | |||
const REQ_GET_LINE_CODING: u8 = 0x21; | |||
const REQ_SET_CONTROL_LINE_STATE: u8 = 0x22; | |||
|
|||
/// Signal will be send whenever the CDC control state changes | |||
pub static CDC_CONTROL_CHANGED: Signal<CriticalSectionRawMutex, ()> = Signal::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be global, because you can create multiple instances of the CDC ACM class. It should be a field in State
.
Also, ideally it should be a WakerRegistration
instead of a Signal
, because it's lighter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, didn't realise it could be instantiated multiple times. Will have a go at refactoring.
Directly exposing a Signal allows the user to do other stuff with it, like signal it. We want the user to only be able to wait. The public API should be methods on |
I have updated this to use a WakerRegistration now. Ready for review again. Sorry, but my git-fu is horribly lacking and my attempt to squash the commits failed. I assume you can do that on merge? |
Signed-off-by: Matt Spencer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thank you! :)
This allows an async wait for changes in dts for example.