modm API documentation
|
#include <modm/architecture/interface/gpio_expander.hpp>
Public Types | |
enum | DataOrder : bool { DataOrder::Normal = false, DataOrder::Reversed = true } |
This enum can be used to reverse the bit order of the Data. More... | |
Static Public Member Functions | |
static constexpr DataOrder | getDataOrder () |
static void | setOutput () |
static void | setInput () |
static PortType | read () |
static void | write (PortType data) |
static void | toggle () |
static void | write (PortType data) |
The write data is always right-aligned regardless of physical mapping. | |
Static Public Attributes | |
static constexpr uint8_t | width = Width |
static constexpr GpioExpander & | ioExpander = expander |
static constexpr uint8_t | number_of_ports |
Create an modm::GpioPort
compatible interface from any IO-expander conforming to the modm::GpioExpander
interface.
This allows the transparent usage of IO Expander ports in classes that require Ports as template arguments. The port access is optimized so that only one write or one read needs to be performed to update the port values. Any port position and width is supported and operates independently from the other IOs on the expander.
SoftwareGpioPort
to create a port out of individual GpioExpanderPin
classes, however, since each pin is individually accessed, this means more bus traffic and a non-atomic write and read of port data! It is strongly recommended to use this optimized class instead!Usage:
However, instead of using this class like that, prefer using the alias-template types provided by the IO-expander of your choice for better readability:
You can reverse the ports bit order in software at runtime, so that data is written or read in reverse bit order when accessing the port:
GpioExpander | Type of class conforming to the modm::GpioExpander interface |
expander | instance of the expander with the selected pin |
StartPin | starting pin of the port, physically LSB |
Width | width of the entire port in bits |
DataOrder | the bit order mapping of data |
|
inheritedstrong |
This enum can be used to reverse the bit order of the Data.
Enum Values | Documentation |
---|---|
Normal | bit order of data is the same as bit order of port |
Reversed | bit order of data is the reverse bit order of port |
|
inheritedstaticconstexpr |
This holds the number of unique platform ports that this implementation accesses. It's always at least 1.