Mark PIO StateMachine, Rx and Tx as Send (#177)

* Mark PIO StateMachine, Rx and Tx as Send

* Improve comment grammar.

Co-authored-by: Wilfried Chauveau <wilfried.chauveau@ithinuel.me>
This commit is contained in:
contradict 2021-10-27 03:34:08 -07:00 committed by GitHub
parent 73e2c6921f
commit fe1e55b8c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -516,6 +516,9 @@ impl<SM: ValidStateMachine, State> StateMachine<SM, State> {
}
}
/// Safety: All shared register accesses are atomic.
unsafe impl<SM: ValidStateMachine + Send, State> Send for StateMachine<SM, State> {}
impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
/// Starts execution of the selected program.
pub fn start(mut self) -> StateMachine<SM, Running> {
@ -676,6 +679,9 @@ pub struct Rx<SM: ValidStateMachine> {
_phantom: core::marker::PhantomData<SM>,
}
/// Safety: All shared register access is atomic.
unsafe impl<SM: ValidStateMachine + Send> Send for Rx<SM> {}
impl<SM: ValidStateMachine> Rx<SM> {
fn register_block(&self) -> &pac::pio0::RegisterBlock {
// Safety: The register is unique to this Tx instance.
@ -713,6 +719,9 @@ pub struct Tx<SM: ValidStateMachine> {
_phantom: core::marker::PhantomData<SM>,
}
/// Safety: All shared register access is atomic.
unsafe impl<SM: ValidStateMachine + Send> Send for Tx<SM> {}
impl<SM: ValidStateMachine> Tx<SM> {
fn register_block(&self) -> &pac::pio0::RegisterBlock {
// Safety: The register is unique to this Tx instance.