From fe1e55b8c0022d3474d09ca881e9d77465698b68 Mon Sep 17 00:00:00 2001 From: contradict Date: Wed, 27 Oct 2021 03:34:08 -0700 Subject: [PATCH] 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 --- rp2040-hal/src/pio.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rp2040-hal/src/pio.rs b/rp2040-hal/src/pio.rs index 986370a..85e3bbd 100644 --- a/rp2040-hal/src/pio.rs +++ b/rp2040-hal/src/pio.rs @@ -516,6 +516,9 @@ impl StateMachine { } } +/// Safety: All shared register accesses are atomic. +unsafe impl Send for StateMachine {} + impl StateMachine { /// Starts execution of the selected program. pub fn start(mut self) -> StateMachine { @@ -676,6 +679,9 @@ pub struct Rx { _phantom: core::marker::PhantomData, } +/// Safety: All shared register access is atomic. +unsafe impl Send for Rx {} + impl Rx { fn register_block(&self) -> &pac::pio0::RegisterBlock { // Safety: The register is unique to this Tx instance. @@ -713,6 +719,9 @@ pub struct Tx { _phantom: core::marker::PhantomData, } +/// Safety: All shared register access is atomic. +unsafe impl Send for Tx {} + impl Tx { fn register_block(&self) -> &pac::pio0::RegisterBlock { // Safety: The register is unique to this Tx instance.