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

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

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

Public Typedefs

typedef modm::Flags16< Pin > Pins
 
using PortType = uint16_t
 
template<Pca9535< I2cMaster > & object, Pin StartPin, uint8_t Width, GpioPort::DataOrder DataOrder = GpioPort::DataOrder::Normal>
using Port = GpioExpanderPort< Pca9535< I2cMaster >, object, StartPin, Width, DataOrder >
 Alias-templates for simpler use of the Port.
 
template<Pca9535< I2cMaster > & object>
using P0_0 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_0 >
 
template<Pca9535< I2cMaster > & object>
using P0_1 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_1 >
 
template<Pca9535< I2cMaster > & object>
using P0_2 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_2 >
 
template<Pca9535< I2cMaster > & object>
using P0_3 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_3 >
 
template<Pca9535< I2cMaster > & object>
using P0_4 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_4 >
 
template<Pca9535< I2cMaster > & object>
using P0_5 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_5 >
 
template<Pca9535< I2cMaster > & object>
using P0_6 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_6 >
 
template<Pca9535< I2cMaster > & object>
using P0_7 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P0_7 >
 
template<Pca9535< I2cMaster > & object>
using P1_0 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_0 >
 
template<Pca9535< I2cMaster > & object>
using P1_1 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_1 >
 
template<Pca9535< I2cMaster > & object>
using P1_2 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_2 >
 
template<Pca9535< I2cMaster > & object>
using P1_3 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_3 >
 
template<Pca9535< I2cMaster > & object>
using P1_4 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_4 >
 
template<Pca9535< I2cMaster > & object>
using P1_5 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_5 >
 
template<Pca9535< I2cMaster > & object>
using P1_6 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_6 >
 
template<Pca9535< I2cMaster > & object>
using P1_7 = GpioExpanderPin< Pca9535< I2cMaster >, object, Pin::P1_7 >
 

Public Types

enum  Pin : uint16_t {
  P0_0 = (1 << 0), P0_1 = (1 << 1), P0_2 = (1 << 2), P0_3 = (1 << 3),
  P0_4 = (1 << 4), P0_5 = (1 << 5), P0_6 = (1 << 6), P0_7 = (1 << 7),
  P1_0 = (1 << 8), P1_1 = (1 << 9), P1_2 = (1 << 10), P1_3 = (1 << 11),
  P1_4 = (1 << 12), P1_5 = (1 << 13), P1_6 = (1 << 14), P1_7 = (1 << 15)
}
 

Public Member Functions

 Pca9535 (uint8_t address=0x20)
 Constructor, sets address to default of 0x20 (range 0x20 - 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 pin) const
 
modm::ResumableResult< bool > setInput (Pins pins)
 
modm::ResumableResult< bool > setInvertInput (Pins pins)
 
modm::ResumableResult< bool > resetInvertInput (Pins pins)
 
bool read (Pins pins) const
 
modm::ResumableResult< bool > readInput ()
 
modm::ResumableResult< bool > writePort (PortType data)
 
modm::ResumableResult< bool > readPort (PortType &data)
 
Pins getDirections () const
 
Pins getOutputs () const
 
Pins getInputs () const
 
Pins getPolarities () const
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > ping ()
 
void setAddress (uint8_t address)
 
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
 

Protected Member Functions

modm::ResumableResult< ReturnType > resumable function (...)
 
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 seperate 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 ()
 Force all resumable functions to stop running at the current nesting level.
 
bool wasTransactionSuccessful ()
 

Protected Attributes

I2cWriteReadTransaction transaction
 

Detailed Description

template<typename I2cMaster>
class modm::pca9535< I2cMaster >

Author
Niklas Hauser

Member Typedef Documentation

template<typename I2cMaster >
template<Pca9535< I2cMaster > & object>
using modm::pca9535< I2cMaster >::P0_0 = GpioExpanderPin< Pca9535<I2cMaster>, object, Pin::P0_0 >

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.

modm::ResumableResult< ReturnType > resumable modm::NestedResumable< 1 >::function (   ...)
inherited

Run the resumable function.

You need to implement this method in you subclass yourself.

Returns
>NestingError if still running, <=NestingError if it has finished.
int8_t modm::NestedResumable< 1 >::getResumableDepth ( ) const
inheritedinline
Returns
the nesting depth in the current resumable function, or -1 if called outside any resumable function
bool modm::NestedResumable< 1 >::isResumableRunning ( ) const
inheritedinline
Returns
true if a resumable function is running at the current nesting level, else false
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.
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: