Struct capsules::mcp23008::MCP23008
[−]
[src]
pub struct MCP23008<'a> { i2c: &'a I2CDevice, state: Cell<State>, buffer: TakeCell<'static, [u8]>, interrupt_pin: Option<&'static Pin>, interrupt_settings: Cell<u32>, identifier: Cell<usize>, client: Cell<Option<&'static Client>>, }
Fields
i2c: &'a I2CDevice
state: Cell<State>
buffer: TakeCell<'static, [u8]>
interrupt_pin: Option<&'static Pin>
interrupt_settings: Cell<u32>
identifier: Cell<usize>
client: Cell<Option<&'static Client>>
Methods
impl<'a> MCP23008<'a>
[src]
pub fn new(
i2c: &'a I2CDevice,
interrupt_pin: Option<&'static Pin>,
buffer: &'static mut [u8]
) -> MCP23008<'a>
[src]
i2c: &'a I2CDevice,
interrupt_pin: Option<&'static Pin>,
buffer: &'static mut [u8]
) -> MCP23008<'a>
pub fn set_client<C: Client>(&self, client: &'static C)
[src]
Set the client of this MCP23008 when commands finish or interrupts
occur. The identifier
is simply passed back with the callback
so that the upper layer can keep track of which device triggered.
fn enable_host_interrupt(&self) -> ReturnCode
[src]
fn set_direction(&self, pin_number: u8, direction: Direction) -> ReturnCode
[src]
fn configure_pullup(&self, pin_number: u8, enabled: bool) -> ReturnCode
[src]
Set the pull-up on the pin also configure it to be an input.
fn set_pin(&self, pin_number: u8, value: PinState) -> ReturnCode
[src]
fn toggle_pin(&self, pin_number: u8) -> ReturnCode
[src]
fn read_pin(&self, pin_number: u8) -> ReturnCode
[src]
fn enable_interrupt_pin(
&self,
pin_number: u8,
direction: InterruptMode
) -> ReturnCode
[src]
&self,
pin_number: u8,
direction: InterruptMode
) -> ReturnCode
fn disable_interrupt_pin(&self, pin_number: u8) -> ReturnCode
[src]
fn save_pin_interrupt_state(
&self,
pin_number: u8,
enabled: bool,
direction: InterruptMode
)
[src]
&self,
pin_number: u8,
enabled: bool,
direction: InterruptMode
)
Helper function for keeping track of which interrupts are currently enabled.
fn remove_pin_interrupt_state(&self, pin_number: u8)
[src]
fn get_pin_interrupt_enabled_state(&self) -> u8
[src]
Create an 8 bit bitmask of which interrupts are enabled.
fn check_pin_interrupt_enabled(&self, pin_number: u8) -> bool
[src]
fn get_pin_interrupt_direction(&self, pin_number: u8) -> InterruptMode
[src]
Trait Implementations
impl<'a> I2CClient for MCP23008<'a>
[src]
fn command_complete(&self, buffer: &'static mut [u8], _error: Error)
[src]
Called when an I2C command completed. The error
denotes whether the command completed successfully or if an error occured. Read more
impl<'a> Client for MCP23008<'a>
[src]
fn fired(&self, _: usize)
[src]
Called when an interrupt occurs. The identifier
will be the same value that was passed to enable_interrupt()
when the interrupt was configured. Read more
impl<'a> Port for MCP23008<'a>
[src]
fn disable(&self, pin: usize) -> ReturnCode
[src]
Try to disable a GPIO pin. This cannot be supported for all devices.
fn make_output(&self, pin: usize) -> ReturnCode
[src]
Configure a pin as an ouput GPIO.
fn make_input(&self, pin: usize, mode: InputMode) -> ReturnCode
[src]
Configure a pin as an input GPIO. Not all InputMode settings may be supported by a given device. Read more
fn read(&self, pin: usize) -> ReturnCode
[src]
Get the state (0 or 1) of an input pin. The value will be returned via a callback. Read more
fn toggle(&self, pin: usize) -> ReturnCode
[src]
Toggle an output GPIO pin.
fn set(&self, pin: usize) -> ReturnCode
[src]
Assert a GPIO pin high.
fn clear(&self, pin: usize) -> ReturnCode
[src]
Clear a GPIO pin low.
fn enable_interrupt(
&self,
pin: usize,
mode: InterruptMode,
identifier: usize
) -> ReturnCode
[src]
&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. Read more
fn disable_interrupt(&self, pin: usize) -> ReturnCode
[src]
Disable an interrupt on a GPIO input pin.