Skip to content

Commit

Permalink
zephyr: device: gpio: Add Send to Gpio and GpioPin
Browse files Browse the repository at this point in the history
Thread safety is managed by using a token on the operations, so these
become Send safe.

Signed-off-by: David Brown <[email protected]>
  • Loading branch information
d3zd3z committed Jan 6, 2025
1 parent aeea001 commit b957752
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zephyr/src/device/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub struct Gpio {
pub(crate) device: *const raw::device,
}

// SAFETY: Gpio's can be shared with other threads. Safety is maintained by the Token.
unsafe impl Send for Gpio {}

impl Gpio {
/// Constructor, used by the devicetree generated code.
///
Expand Down Expand Up @@ -73,6 +76,9 @@ pub struct GpioPin {
pub(crate) pin: raw::gpio_dt_spec,
}

// SAFETY: GpioPin's can be shared with other threads. Safety is maintained by the Token.
unsafe impl Send for GpioPin {}

impl GpioPin {
/// Constructor, used by the devicetree generated code.
#[allow(dead_code)]
Expand Down

0 comments on commit b957752

Please sign in to comment.