modm API documentation
modm::pca8574< I2cMaster > Class Template Reference

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

Inheritance diagram for modm::pca8574< I2cMaster >:
modm::I2cDevice< I2cMaster, 2 > modm::GpioExpander modm::NestedResumable< 10+1 >

Public Typedefs

typedef modm::Flags8< Pin > Pins
 
using PortType = uint8_t
 
template<Pca8574< I2cMaster > & object, Pin StartPin, uint8_t Width, GpioPort::DataOrder DataOrder = GpioPort::DataOrder::Normal>
using Port = GpioExpanderPort< Pca8574< I2cMaster >, object, StartPin, Width, DataOrder >
 Alias-templates for simpler use of the Port.
 
template<Pca8574< I2cMaster > & object>
using P0 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P0 >
 
template<Pca8574< I2cMaster > & object>
using P1 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P1 >
 
template<Pca8574< I2cMaster > & object>
using P2 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P2 >
 
template<Pca8574< I2cMaster > & object>
using P3 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P3 >
 
template<Pca8574< I2cMaster > & object>
using P4 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P4 >
 
template<Pca8574< I2cMaster > & object>
using P5 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P5 >
 
template<Pca8574< I2cMaster > & object>
using P6 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P6 >
 
template<Pca8574< I2cMaster > & object>
using P7 = GpioExpanderPin< Pca8574< I2cMaster >, object, Pin::P7 >
 

Public Types

enum  Pin : uint8_t {
  P0 = (1 << 0), P1 = (1 << 1), P2 = (1 << 2), P3 = (1 << 3),
  P4 = (1 << 4), P5 = (1 << 5), P6 = (1 << 6), P7 = (1 << 7)
}
 

Public Member Functions

 Pca8574 (uint8_t address=0x27)
 Constructor, sets address to default of 0x27.
 
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) const
 
modm::Gpio::Direction getDirection (Pin) const
 
modm::ResumableResult< bool > setInput (Pins pins)
 
bool read (Pins pins) const
 
modm::ResumableResult< bool > readInput ()
 
modm::ResumableResult< bool > writePort (PortType value)
 
modm::ResumableResult< bool > readPort (PortType &value)
 
Pins getOutputs ()
 
Pins getInputs ()
 
Pins getDirections ()
 0 is input, 1 is output
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > ping ()
 
modm::ResumableResult< bool > read (uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
void setAddress (uint8_t address)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
modm::ResumableResult< bool > writeRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Starts a write-read transaction and waits until finished.
 
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 read (Pins pins) const
 
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)
 

Static Public Member Functions

static constexpr uint8_t indexFromPin (Pin pin)
 

Static Public Attributes

static constexpr uint8_t width = 8
 

Protected Member Functions

int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
bool isTransactionRunning ()
 
modm::ResumableResult< bool > runTransaction ()
 Starts our own transaction and waits until finished.
 
bool startRead (uint8_t *buffer, std::size_t size)
 Configures the transaction with a read operation and starts it.
 
bool startTransaction ()
 Starts the transaction with our own transaction object.
 
bool startTransaction (modm::I2cTransaction *transaction)
 Starts the transaction with a separate transaction object.
 
bool startWrite (const uint8_t *buffer, std::size_t size)
 Configures the transaction with a write operation and starts it.
 
bool startWriteRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Configures the transaction with a write/read operation and starts it.
 
void stopResumable ()
 
bool wasTransactionSuccessful ()
 

Protected Attributes

I2cWriteReadTransaction transaction
 

Detailed Description

template<class I2cMaster>
class modm::pca8574< I2cMaster >

PCA8574: Remote 8-bit I/O expander for I2C-bus with interrupt

This IO-Expander only has open-drain outputs with weak internal pull-ups.

Author
Sascha Schade
Niklas Hauser

Member Typedef Documentation

template<class I2cMaster >
template<Pca8574< I2cMaster > & object>
using modm::pca8574< I2cMaster >::P0 = GpioExpanderPin< Pca8574<I2cMaster>, object, Pin::P0 >

Alias-templates for simpler use of the Pin

Member Function Documentation

void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::attachConfigurationHandler ( I2c::ConfigurationHandler  handler)
inheritedinline

Attaches a configuration handler, which is called before a transaction, whenever the configuration has to be changed.

bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::isTransactionRunning ( )
inheritedinlineprotected
Returns
true when transaction is busy.
modm::ResumableResult<bool> modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::ping ( )
inheritedinline
Return Values
truedevice responds to address
falseno device with address found
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!
void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::setAddress ( uint8_t  address)
inheritedinline

Sets a new address of the slave device.

Parameters
addressthe slave address not yet shifted left (address < 128).
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!
bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::wasTransactionSuccessful ( )
inheritedinlineprotected
Returns
true when transaction did not return an error.

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