modm API documentation
modm::mcp23x17< Transport > Class Template Reference

#include <modm/driver/gpio/mcp23x17.hpp>

Inheritance diagram for modm::mcp23x17< Transport >:
modm::GpioExpander

Public Typedefs

typedef modm::Flags16< Pin > Pins
 
using PortType = uint16_t
 
template<Mcp23x17< Transport > & object, Pin StartPin, uint8_t Width, GpioPort::DataOrder DataOrder = GpioPort::DataOrder::Normal>
using Port = GpioExpanderPort< Mcp23x17< Transport >, object, StartPin, Width, DataOrder >
 Alias-templates for simpler use of the Port.
 
template<Mcp23x17< Transport > & object>
using A0 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A0 >
 
template<Mcp23x17< Transport > & object>
using A1 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A1 >
 
template<Mcp23x17< Transport > & object>
using A2 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A2 >
 
template<Mcp23x17< Transport > & object>
using A3 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A3 >
 
template<Mcp23x17< Transport > & object>
using A4 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A4 >
 
template<Mcp23x17< Transport > & object>
using A5 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A5 >
 
template<Mcp23x17< Transport > & object>
using A6 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A6 >
 
template<Mcp23x17< Transport > & object>
using A7 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::A7 >
 
template<Mcp23x17< Transport > & object>
using B0 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B0 >
 
template<Mcp23x17< Transport > & object>
using B1 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B1 >
 
template<Mcp23x17< Transport > & object>
using B2 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B2 >
 
template<Mcp23x17< Transport > & object>
using B3 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B3 >
 
template<Mcp23x17< Transport > & object>
using B4 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B4 >
 
template<Mcp23x17< Transport > & object>
using B5 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B5 >
 
template<Mcp23x17< Transport > & object>
using B6 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B6 >
 
template<Mcp23x17< Transport > & object>
using B7 = GpioExpanderPin< Mcp23x17< Transport >, object, Pin::B7 >
 

Public Types

enum  Pin : uint16_t {
  A0 = Bit0, A1 = Bit1, A2 = Bit2, A3 = Bit3,
  A4 = Bit4, A5 = Bit5, A6 = Bit6, A7 = Bit7,
  B0 = Bit8, B1 = Bit9, B2 = Bit10, B3 = Bit11,
  B4 = Bit12, B5 = Bit13, B6 = Bit14, B7 = Bit15
}
 

Public Member Functions

 Mcp23x17 (uint8_t address=0x20)
 Constructor, sets address to default of 0x20 (range 0x20 - 0x27)
 
modm::ResumableResult< bool > initialize ()
 
modm::ResumableResult< bool > setOutput (Pins pins)
 
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)
 
modm::Gpio::Direction getDirection (Pin pin)
 
modm::ResumableResult< bool > setInput (Pins pins)
 
modm::ResumableResult< bool > setPullUp (Pins pins)
 
modm::ResumableResult< bool > resetPullUp (Pins pins)
 
modm::ResumableResult< bool > setInvertInput (Pins pins)
 
modm::ResumableResult< bool > resetInvertInput (Pins pins)
 
bool read (Pin pin)
 
modm::ResumableResult< bool > readInput ()
 
modm::ResumableResult< bool > readAllInput ()
 
modm::ResumableResult< bool > writePort (PortType data)
 
modm::ResumableResult< bool > readPort (PortType &data)
 
Pins getDirections ()
 
Pins getOutputs ()
 
Pins getInputs ()
 
Pins getPolarities ()
 
modm::Gpio::Direction getDirection (Pin pin) const
 returns direction of one pin at run-time
 
Pins getDirections () const
 Returns the direction bits: 0 for Input, 1 for Output.
 
Pins getInputs () const
 Returns the input bits: 0 for low, 1 for high.
 
Pins getOutputs () const
 Returns the output bits: 0 for low, 1 for high.
 
bool isSet (Pin pin) const
 Returns the set logical output state of the pin.
 
bool read (Pins pins) const
 
modm::ResumableResult< bool > readPort (PortType &data)
 Reads the entire port, buffers them and outputs the result to data.
 
modm::ResumableResult< bool > reset (Pins pins)
 
modm::ResumableResult< bool > set (Pins pins)
 
modm::ResumableResult< bool > set (Pins pins, bool value)
 
modm::ResumableResult< bool > setInput (Pins pins)
 Sets one or more pins to input.
 
modm::ResumableResult< bool > setOutput (Pins pins)
 Sets one or more pins to output.
 
modm::ResumableResult< bool > toggle (Pins pins)
 
modm::ResumableResult< bool > writePort (PortType data)
 

Static Public Member Functions

static constexpr uint8_t indexFromPin (Pin pin)
 

Static Public Attributes

static constexpr uint8_t width = 16
 

Detailed Description

template<class Transport>
class modm::mcp23x17< Transport >

See also
Mcp23TransportI2c
Mcp23TransportSpi
Template Parameters
TransportEither the I2C or SPI Transport Layer.
Author
Fabian Greif
Niklas Hauser

Member Typedef Documentation

template<class Transport >
template<Mcp23x17< Transport > & object>
using modm::mcp23x17< Transport >::A0 = GpioExpanderPin< Mcp23x17<Transport>, object, Pin::A0 >

Alias-templates for simpler use of the Pin

Member Function Documentation

bool modm::GpioExpander::read ( Pins  pins) const
inherited

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.
modm::ResumableResult<bool> modm::GpioExpander::reset ( Pins  pins)
inherited

Resets one or more pins to logic low

Warning
only modifies pins that have previously been set to output!
modm::ResumableResult<bool> modm::GpioExpander::set ( Pins  pins)
inherited

Sets one or more pins to logic high

Warning
only modifies pins that have previously been set to output!
modm::ResumableResult<bool> modm::GpioExpander::set ( Pins  pins,
bool  value 
)
inherited

sets one or more pins to high or low level

Warning
only modifies pins that have previously been set to output!
modm::ResumableResult<bool> modm::GpioExpander::toggle ( Pins  pins)
inherited

Toggles one or more pins

Warning
only modifies pins that have previously been set to output!
modm::ResumableResult<bool> modm::GpioExpander::writePort ( PortType  data)
inherited

Writes data to the entire port

Warning
only modifies pins that have previously been set to output!

The documentation for this class was generated from the following file: