peary::component::PCA9539
peary::component::PCA9539
PCA9539 I/O Expander Component.
#include <peary/hardware/components/PCA9539.hpp>
Inherits from peary::hal::Component
Public Types
| Name | |
|---|---|
| enum class | Register { INPUT_PORT_0 = 0x00, INPUT_PORT_1 = 0x01, OUTPUT_PORT_0 = 0x02, OUTPUT_PORT_1 = 0x03, POLARITY_INVERSION_PORT_0 = 0x04, POLARITY_INVERSION_PORT_1 = 0x05, CONFIGURATION_PORT_0 = 0x06, CONFIGURATION_PORT_1 = 0x07} |
| enum class | Port { P0 = 0, P1 = 1} |
| enum class | Channel { CH0 = 0, CH1 = 1, CH2 = 2, CH3 = 3, CH4 = 4, CH5 = 5, CH6 = 6, CH7 = 7} |
Public Functions
| Name | |
|---|---|
| PCA9539(const std::string & i2c_bus, uint8_t device_address)Constructor for PCA9539 class. | |
| bool | getInputLevel(Port port, Channel channel)Get the input level of a specific port and channel. |
| utils::Polarity | getOutputLevel(Port port, Channel channel)Get the output level of a specific port and channel. |
| void | setOutputLevel(Port port, Channel channel, utils::Polarity polarity)Set the output level polarity of a specific port and channel. |
| void | invertInputPolarity(Port port, Channel channel, bool invert)Check if the input polarity is inverted for a specific port and channel. |
| utils::Direction | getDirection(Port port, Channel channel)Get the direction (input/output) of a specific port and channel. |
| void | setDirection(Port port, Channel channel, utils::Direction direction)Set the direction (input/output) of a specific port and channel. |
Additional inherited members
Public Functions inherited from peary::hal::Component
| Name | |
|---|---|
| Component() =defaultDefault constructor. | |
| virtual | ~Component() =defaultDefault destructor. |
Public Types Documentation
enum Register
| Enumerator | Value | Description |
|---|---|---|
| INPUT_PORT_0 | 0x00 | |
| INPUT_PORT_1 | 0x01 | |
| OUTPUT_PORT_0 | 0x02 | |
| OUTPUT_PORT_1 | 0x03 | |
| POLARITY_INVERSION_PORT_0 | 0x04 | |
| POLARITY_INVERSION_PORT_1 | 0x05 | |
| CONFIGURATION_PORT_0 | 0x06 | |
| CONFIGURATION_PORT_1 | 0x07 |
enum Port
| Enumerator | Value | Description |
|---|---|---|
| P0 | 0 | |
| P1 | 1 |
enum Channel
| Enumerator | Value | Description |
|---|---|---|
| CH0 | 0 | |
| CH1 | 1 | |
| CH2 | 2 | |
| CH3 | 3 | |
| CH4 | 4 | |
| CH5 | 5 | |
| CH6 | 6 | |
| CH7 | 7 |
Public Functions Documentation
function PCA9539
PCA9539(
const std::string & i2c_bus,
uint8_t device_address
)
Constructor for PCA9539 class.
Parameters:
- i2c_bus The I2C bus to which the PCA9539 is connected
- device_address The I2C address of the PCA9539 device
function getInputLevel
bool getInputLevel(
Port port,
Channel channel
)
Get the input level of a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
Return: True if the input level is high, false if low
function getOutputLevel
utils::Polarity getOutputLevel(
Port port,
Channel channel
)
Get the output level of a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
Return: The output level polarity (HIGH or LOW)
function setOutputLevel
void setOutputLevel(
Port port,
Channel channel,
utils::Polarity polarity
)
Set the output level polarity of a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
- polarity The desired output level polarity (HIGH or LOW)
function invertInputPolarity
void invertInputPolarity(
Port port,
Channel channel,
bool invert
)
Check if the input polarity is inverted for a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
- invert True if the input polarity is inverted, false otherwise
function getDirection
utils::Direction getDirection(
Port port,
Channel channel
)
Get the direction (input/output) of a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
Return: The direction (INPUT or OUTPUT)
function setDirection
void setDirection(
Port port,
Channel channel,
utils::Direction direction
)
Set the direction (input/output) of a specific port and channel.
Parameters:
- port The port (P0 or P1)
- channel The channel (CH0 to CH7)
- direction The desired direction (INPUT or OUTPUT)
Updated on 2025-11-14 at 11:31:23 +0100