Trait kernel::hil::gpio_async::Port

source ·
pub trait Port {
    // Required methods
    fn disable(&self, pin: usize) -> Result<(), ErrorCode>;
    fn make_output(&self, pin: usize) -> Result<(), ErrorCode>;
    fn make_input(
        &self,
        pin: usize,
        mode: FloatingState
    ) -> Result<(), ErrorCode>;
    fn read(&self, pin: usize) -> Result<(), ErrorCode>;
    fn toggle(&self, pin: usize) -> Result<(), ErrorCode>;
    fn set(&self, pin: usize) -> Result<(), ErrorCode>;
    fn clear(&self, pin: usize) -> Result<(), ErrorCode>;
    fn enable_interrupt(
        &self,
        pin: usize,
        mode: InterruptEdge
    ) -> Result<(), ErrorCode>;
    fn disable_interrupt(&self, pin: usize) -> Result<(), ErrorCode>;
    fn is_pending(&self, pin: usize) -> bool;
}
Expand description

Interface for banks of asynchronous GPIO pins. GPIO pins are asynchronous when there is an asynchronous interface used to control them. The most common example is when using a GPIO extender on an I2C or SPI bus. With asynchronous GPIO functions, every config action results in an eventual callback function that indicates that the configuration has finished (unless the initial function call returns an error code, then no callback will be generated).

Asynchronous GPIO pins are grouped into ports because it is assumed that the remote entity that is controlling the pins can control multiple pins. Typically, a port will be provided by a particular driver.

The API for the Port mirrors the synchronous GPIO interface.

Required Methods§

source

fn disable(&self, pin: usize) -> Result<(), ErrorCode>

Try to disable a GPIO pin. This cannot be supported for all devices.

source

fn make_output(&self, pin: usize) -> Result<(), ErrorCode>

Configure a pin as an ouput GPIO.

source

fn make_input(&self, pin: usize, mode: FloatingState) -> Result<(), ErrorCode>

Configure a pin as an input GPIO. Not all FloatingMode settings may be supported by a given device.

source

fn read(&self, pin: usize) -> Result<(), ErrorCode>

Get the state (0 or 1) of an input pin. The value will be returned via a callback.

source

fn toggle(&self, pin: usize) -> Result<(), ErrorCode>

Toggle an output GPIO pin.

source

fn set(&self, pin: usize) -> Result<(), ErrorCode>

Assert a GPIO pin high.

source

fn clear(&self, pin: usize) -> Result<(), ErrorCode>

Clear a GPIO pin low.

source

fn enable_interrupt( &self, pin: usize, mode: InterruptEdge ) -> Result<(), ErrorCode>

Setup an interrupt on a GPIO input pin. The identifier should be the port number and will be returned when the interrupt callback fires.

source

fn disable_interrupt(&self, pin: usize) -> Result<(), ErrorCode>

Disable an interrupt on a GPIO input pin.

source

fn is_pending(&self, pin: usize) -> bool

Implementors§