wasm_embedded_spec/
gpio.rs

1//! Platform GPIO API abstraction (and wrappers).
2//!
3//! Provides a platform GPIO trait with wiggle and c wrappers
4
5use embedded_hal::digital::PinState;
6
7use super::Error;
8
9/// Platform GPIO API abstraction.
10///
11/// This hides runtime implementation details to simplify implementing GPIO contexts.
12/// Hopefully one day generation is improved so we don't _need_ this any more
13#[cfg_attr(feature = "mocks", mockall::automock)]
14pub trait Gpio {
15    /// Initialise a GPIO by port and pin, returning a handle
16    fn init(&mut self, port: i32, pin: i32, output: bool) -> Result<i32, Error>;
17
18    /// Deinitialise a GPIO by handle
19    fn deinit(&mut self, handle: i32) -> Result<(), Error>;
20
21    /// Set a GPIO state by handle
22    fn set(&mut self, handle: i32, state: PinState) -> Result<(), Error>;
23
24    /// Fetch a GPIO state by handle
25    fn get(&mut self, handle: i32) -> Result<PinState, Error>;
26}