DigitalIO driver with dynamic channel count

This commit is contained in:
Emanuele Trabattoni
2025-07-12 13:45:00 +02:00
parent 1955b8cb39
commit ef7b9506b6
8 changed files with 335 additions and 38 deletions

View File

@@ -39,7 +39,7 @@ namespace drivers
uint8_t currState(0);
uint8_t newState(0);
if (ch < OUT_PIN1 || ch > OUT_PIN8)
if (ch < DO1 || ch > DO8)
{
LOG_ERROR("Invalid write to output channel: [%d]", ch);
return false;
@@ -64,7 +64,7 @@ namespace drivers
const bool TCA9554PWR::readOut(const uint8_t ch)
{
uint8_t currState(0);
if (ch < OUT_PIN1 || ch > OUT_PIN8)
if (ch < DO1 || ch > DO8)
{
LOG_ERROR("Invalid read to output channel: [%d]", ch);
return false;

View File

@@ -21,18 +21,18 @@ namespace drivers
{
public:
enum
typedef enum
{
OUT_PIN1,
OUT_PIN2,
OUT_PIN3,
OUT_PIN4,
OUT_PIN5,
OUT_PIN6,
OUT_PIN7,
OUT_PIN8,
OUT_PIN_MAX
};
DO1,
DO2,
DO3,
DO4,
DO5,
DO6,
DO7,
DO8,
DO_MAX
} channel_t;
TCA9554PWR(I2C &i2c, const uint8_t address);
~TCA9554PWR();