pub struct Expander<EI: ExpanderInterface> { /* private fields */ }Expand description
The port expander device itself.
Implementations§
Source§impl<EI: ExpanderInterface + Send> Expander<EI>
impl<EI: ExpanderInterface + Send> Expander<EI>
Sourcepub fn new(iface: EI) -> Self
pub fn new(iface: EI) -> Self
Create a new Expander.
Takes ownership of the ExpanderInterface which it should use to communicate with the
MAX7301.
Sourcepub fn configure<'e>(&'e mut self) -> Configurator<'e, EI>
pub fn configure<'e>(&'e mut self) -> Configurator<'e, EI>
Begin (re)configuring the port expander hardware by returning a Configurator.
The Configurator is a builder-like interface that can be used to alter port modes and
device configuration bits.
Sourcepub fn into_immediate<M: IOMutex<Self>>(self) -> ImmediateIO<M, EI>
pub fn into_immediate<M: IOMutex<Self>>(self) -> ImmediateIO<M, EI>
Convert this expander into an immediate-mode I/O adapter.
The I/O adapter can be used to generate individual PortPins that allow
embedded-hal-compatible access to the GPIOs on the expander directly, with every
operation immediately triggering a bus operation.
See ImmediateIO for detail.
Sourcepub fn into_transactional<M: IOMutex<Self>>(self) -> TransactionalIO<M, EI>
pub fn into_transactional<M: IOMutex<Self>>(self) -> TransactionalIO<M, EI>
Convert this expander into a transactional I/O adapter.
The I/O adapter can be used to generate individual PortPins that allow
embedded-hal-compatible access to the GPIOs on the expander. Unlike immediate mode, the
operations on PortPin trait methods are buffered in a write-back cache.
See TransactionalIO for detail.
Sourcepub fn read_port(&mut self, port: u8) -> Result<bool, EI::Error>
pub fn read_port(&mut self, port: u8) -> Result<bool, EI::Error>
Perform a read of the current value of a single I/O port on the expander.
Sourcepub fn read_ports(&mut self, start_port: u8) -> Result<u8, EI::Error>
pub fn read_ports(&mut self, start_port: u8) -> Result<u8, EI::Error>
Perform a read of the current value of 8 consecutive I/O ports on the expander in a single bus transaction.
There is no alignment requirement; the start_port may be any valid port, and that port
along with up to 7 following ports will be read in one transaction. The return value is a
u8 where the LSB is the value read from start_port, and each higher bit is the 7 ports
following it in ascending order. If any of the bits would correspond to a port higher than
31, then those bits will be unset.
Sourcepub fn write_port(&mut self, port: u8, bit: bool) -> Result<(), EI::Error>
pub fn write_port(&mut self, port: u8, bit: bool) -> Result<(), EI::Error>
Write a value to a single I/O port on the expander.
Sourcepub fn write_ports(&mut self, start_port: u8, bits: u8) -> Result<(), EI::Error>
pub fn write_ports(&mut self, start_port: u8, bits: u8) -> Result<(), EI::Error>
Write a value to 8 consecutive I/O ports on the expander in a single bus transaction.
There is no alignment requirement; the start_port may be any valid port, and that port
along with up to 7 following ports will be written in one transaction. bits is a u8
where the LSB is the value to write to start_port, and each higher bit is the 7 ports
following it in ascending order. If any of the bits would correspond to a port higher than
31, then those bits will be ignored.