#include <modm/architecture/interface/gpio_expander.hpp>
|  | 
| 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.
- Note
- The driver must buffer the expanders IO registers. This means at least the direction, output and input values should be buffered so that a read-modify-write can be performed on SRAM and then only one write is performed on the bus instead of a read and write!
- Warning
- The read()function does not perform a read bus access, but operates on the buffered result ofreadInput(). 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 formodm::GpioExpanderPort.
- See also
- modm::GpioExpanderPin 
- 
modm::GpioExpanderPort 
- 
modm::GpioIO
- Author
- Niklas Hauser 
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. 
 
 
  
  | 
        
          | static constexpr uint8_t modm::GpioExpander::indexFromPin | ( | Pin | pin | ) |  |  | 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 
- Warning
- This function operates on the buffered input read. You have to call readInput()to update the result.
 
 
      
        
          | bool modm::GpioExpander::reset | ( | Pins | pins | ) |  | 
      
 
Resets one or more pins to logic low 
- Warning
- only modifies pins that have previously been set to output! 
 
 
      
        
          | bool modm::GpioExpander::set | ( | Pins | pins | ) |  | 
      
 
Sets one or more pins to logic high 
- Warning
- only modifies pins that have previously been set to output! 
 
 
      
        
          | bool modm::GpioExpander::set | ( | Pins | pins, | 
        
          |  |  | bool | value | 
        
          |  | ) |  |  | 
      
 
sets one or more pins to high or low level 
- Warning
- only modifies pins that have previously been set to output! 
 
 
      
        
          | bool modm::GpioExpander::toggle | ( | Pins | pins | ) |  | 
      
 
Toggles one or more pins 
- Warning
- only modifies pins that have previously been set to output! 
 
 
      
        
          | bool modm::GpioExpander::writePort | ( | PortType | data | ) |  | 
      
 
Writes data to the entire port 
- Warning
- only modifies pins that have previously been set to output! 
 
 
  
  | 
        
          | constexpr uint8_t modm::GpioExpander::width |  | staticconstexpr | 
 
This holds the width of the port as number of bits and can be used in drivers to assert the correct requirements 
 
 
The documentation for this class was generated from the following file: