Trait kernel::hil::gpio_async::Port
[−]
[src]
pub trait Port { fn disable(&self, pin: usize) -> ReturnCode; fn make_output(&self, pin: usize) -> ReturnCode; fn make_input(&self, pin: usize, mode: InputMode) -> ReturnCode; fn read(&self, pin: usize) -> ReturnCode; fn toggle(&self, pin: usize) -> ReturnCode; fn set(&self, pin: usize) -> ReturnCode; fn clear(&self, pin: usize) -> ReturnCode; fn enable_interrupt(
&self,
pin: usize,
mode: InterruptMode,
identifier: usize
) -> ReturnCode; fn disable_interrupt(&self, pin: usize) -> ReturnCode; }
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
fn disable(&self, pin: usize) -> ReturnCode
Try to disable a GPIO pin. This cannot be supported for all devices.
fn make_output(&self, pin: usize) -> ReturnCode
Configure a pin as an ouput GPIO.
fn make_input(&self, pin: usize, mode: InputMode) -> ReturnCode
Configure a pin as an input GPIO. Not all InputMode settings may be supported by a given device.
fn read(&self, pin: usize) -> ReturnCode
Get the state (0 or 1) of an input pin. The value will be returned via a callback.
fn toggle(&self, pin: usize) -> ReturnCode
Toggle an output GPIO pin.
fn set(&self, pin: usize) -> ReturnCode
Assert a GPIO pin high.
fn clear(&self, pin: usize) -> ReturnCode
Clear a GPIO pin low.
fn enable_interrupt(
&self,
pin: usize,
mode: InterruptMode,
identifier: usize
) -> ReturnCode
&self,
pin: usize,
mode: InterruptMode,
identifier: usize
) -> ReturnCode
Setup an interrupt on a GPIO input pin. The identifier should be the port number and will be returned when the interrupt callback fires.
fn disable_interrupt(&self, pin: usize) -> ReturnCode
Disable an interrupt on a GPIO input pin.