|
roo_control
API Documentation for roo_control
|
PCF8574 I2C-controlled 8-bit port extender. More...
#include <pcf8574.h>
Data Structures | |
| class | OutputPort |
| Output-only port. More... | |
| class | Port |
| Quasi-bidirectional port usable as both input and output. More... | |
Public Member Functions | |
| Pcf8574 (TwoWire &wire, uint8_t addr) | |
| Creates the extender on the specified TwoWire bus and I2C address. | |
| roo_time::Duration | getReadCacheDuration () const |
| Returns the maximum allowed staleness of cached reads. | |
| void | setReadCacheDuration (roo_time::Duration duration) |
| Sets the maximum allowed staleness of cached reads. | |
| bool | read (uint8_t &data) |
| Reads, caches, and returns levels of all ports. | |
| bool | write (uint8_t data) |
| Writes the levels of all ports. | |
| uint8_t | last_read () const |
| Returns the most recently read byte, or 0xFF if never read. | |
| uint8_t | last_written () const |
| Returns the most recently written byte, or 0xFF if never written. | |
| BinaryLogicalState | readPort (uint8_t port) |
| Reads the level of the specified port. | |
| bool | writePort (uint8_t port, BinaryLogicalState state) |
| Writes the level of the specified port. | |
PCF8574 I2C-controlled 8-bit port extender.
Datasheet: https://www.ti.com/lit/ds/symlink/pcf8574.pdf
Each port can be used as digital input, digital output, or quasi-bidirectional.
To use a given port as output, drive the corresponding bit from the extender, and read it from the slave. See the datasheet for details.
To use a given port as input, set the corresponding bit to HIGH (the initial value), and then use the slave to drive the line to VCC or GND.
Creates the extender on the specified TwoWire bus and I2C address.
Definition at line 34 of file pcf8574.cpp.
|
inline |
|
inline |
Returns the most recently read byte, or 0xFF if never read.
Definition at line 83 of file pcf8574.h.
Referenced by readPort().
|
inline |
Reads, caches, and returns levels of all ports.
If called within the read-cache interval, may return cached results. Returns false on a communication failure.
Definition at line 80 of file pcf8574.cpp.
Referenced by readPort().
| BinaryLogicalState roo_control::Pcf8574::readPort | ( | uint8_t | port | ) |
Reads the level of the specified port.
For output ports, the value generally reflects what was last written, but it is always read from the extender. On failure, returns the last known state.
Definition at line 53 of file pcf8574.cpp.
References roo_control::BINARY_STATE_HIGH, roo_control::BINARY_STATE_LOW, last_read(), and read().
|
inline |
Writes the levels of all ports.
For input ports, the corresponding bits should be HIGH to allow the slave to keep driving the actual line level. Returns false on failure.
Definition at line 99 of file pcf8574.cpp.
Referenced by writePort().
| bool roo_control::Pcf8574::writePort | ( | uint8_t | port, |
| BinaryLogicalState | state | ||
| ) |
Writes the level of the specified port.
Returns false on a communication failure. For input ports, it is OK to write HIGH to allow the slave to keep driving the level seen by readPort. Writing LOW will force the LOW state.
Definition at line 62 of file pcf8574.cpp.
References roo_control::BINARY_STATE_HIGH, and write().
Referenced by roo_control::Pcf8574::Port::setState().