Skip to content

Commit b957752

Browse files
committed
zephyr: device: gpio: Add Send to Gpio and GpioPin
Thread safety is managed by using a token on the operations, so these become Send safe. Signed-off-by: David Brown <[email protected]>
1 parent aeea001 commit b957752

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

zephyr/src/device/gpio.rs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ pub struct Gpio {
4242
pub(crate) device: *const raw::device,
4343
}
4444

45+
// SAFETY: Gpio's can be shared with other threads. Safety is maintained by the Token.
46+
unsafe impl Send for Gpio {}
47+
4548
impl Gpio {
4649
/// Constructor, used by the devicetree generated code.
4750
///
@@ -73,6 +76,9 @@ pub struct GpioPin {
7376
pub(crate) pin: raw::gpio_dt_spec,
7477
}
7578

79+
// SAFETY: GpioPin's can be shared with other threads. Safety is maintained by the Token.
80+
unsafe impl Send for GpioPin {}
81+
7682
impl GpioPin {
7783
/// Constructor, used by the devicetree generated code.
7884
#[allow(dead_code)]

0 commit comments

Comments
 (0)