|
modm API documentation
|
#include <modm/architecture/interface/gpio_expander.hpp>
Public Typedefs | |
| using | PortType = uint8_t |
| typedef modm::Flags< Pin, PortType > | Pins |
| Use type-safe flags container for the pins. | |
Public Member Functions | |
| modm::ResumableResult< bool > | setOutput (Pins pins) |
| Sets one or more pins to output. | |
| modm::ResumableResult< bool > | set (Pins pins) |
| modm::ResumableResult< bool > | reset (Pins pins) |
| modm::ResumableResult< bool > | toggle (Pins pins) |
| modm::ResumableResult< bool > | set (Pins pins, bool value) |
| bool | isSet (Pin pin) const |
| Returns the set logical output state of the pin. | |
| modm::Gpio::Direction | getDirection (Pin pin) const |
| returns direction of one pin at run-time | |
| modm::ResumableResult< bool > | setInput (Pins pins) |
| Sets one or more pins to input. | |
| bool | read (Pins pins) const |
| modm::ResumableResult< bool > | readInput () |
| Reads the inputs and buffers them. | |
| modm::ResumableResult< bool > | writePort (PortType data) |
| modm::ResumableResult< bool > | readPort (PortType &data) |
| Reads the entire port, buffers them and outputs the result to data. | |
| Pins | getDirections () const |
| Returns the direction bits: 0 for Input, 1 for Output. | |
| Pins | getOutputs () const |
| Returns the output bits: 0 for low, 1 for high. | |
| Pins | getInputs () const |
| Returns the input bits: 0 for low, 1 for high. | |
Static Public Member Functions | |
| static constexpr uint8_t | indexFromPin (Pin pin) |
Static Public Attributes | |
| static constexpr uint8_t | width |
Interface of an IO expander driver.
All IO expander driver should implement this interface, so that they can be wrapped into modm::GpioExpanderPin and modm::GpioExpanderPort.
The interface is almost identical to an GPIO pin, except multiple pins can be set at once.
read() function does not perform a read bus access, but operates on the buffered result of readInput(). This allows a capture-and-evaluate approach, which is especially useful for reducing bus traffic and necessary for sampling all pins at the same time for modm::GpioExpanderPort.| using modm::GpioExpander::PortType = uint8_t |
This contains the underlying type that can hold the bits of the entire port. This value is implementation defined, it may also be uint16_t.
|
staticconstexpr |
Returns the index of the pin as a constexpr function. The mapping is implementation defined, however, as an implementation hint when using a bit mask, you should use modm::leftmostBit()
| bool modm::GpioExpander::read | ( | Pins | pins | ) | const |
Returns true if all pins have a high level
readInput() to update the result. | modm::ResumableResult<bool> modm::GpioExpander::reset | ( | Pins | pins | ) |
Resets one or more pins to logic low
| modm::ResumableResult<bool> modm::GpioExpander::set | ( | Pins | pins | ) |
Sets one or more pins to logic high
| modm::ResumableResult<bool> modm::GpioExpander::set | ( | Pins | pins, |
| bool | value | ||
| ) |
sets one or more pins to high or low level
| modm::ResumableResult<bool> modm::GpioExpander::toggle | ( | Pins | pins | ) |
Toggles one or more pins
| modm::ResumableResult<bool> modm::GpioExpander::writePort | ( | PortType | data | ) |
Writes data to the entire port
|
staticconstexpr |
This holds the width of the port as number of bits and can be used in drivers to assert the correct requirements