Files
ETcontroller_PRO/lib/GPIO/TCA9554PWR_Driver.h
2025-06-27 18:55:20 +02:00

51 lines
1.6 KiB
C++

#pragma once
#include "I2C_Driver.h"
/****************************************************** The macro defines the TCA9554PWR information ******************************************************/
#define TCA9554_ADDRESS 0x20 // TCA9554PWR I2C address
#define TCA9554_INPUT_REG 0x00 // Input register, input level
#define TCA9554_OUTPUT_REG 0x01 // Output register, high and low level output
#define TCA9554_POLARITY_REG 0x02 // The Polarity Inversion register (register 2) allows polarity inversion of pins defined as inputs by the Configuration register.
#define TCA9554_CONFIG_REG 0x03 // Configuration register, mode configuration
#define TCA9554_OUT_MODE 0x00 // Configuration register value, output mode
#define TCA9554_IN_MODE 0xff // Configuration register value, input mode
#define Low 0x00
#define High 0x01
namespace drivers
{
class TCA9554PWR
{
public:
enum
{
OUT_PIN1,
OUT_PIN2,
OUT_PIN3,
OUT_PIN4,
OUT_PIN5,
OUT_PIN6,
OUT_PIN7,
OUT_PIN8,
OUT_PIN_MAX
};
TCA9554PWR(I2C &i2c, const uint8_t address);
const bool setOut(const uint8_t channel, const bool state);
const bool setPort(const uint8_t state);
const bool readOut(const uint8_t channel);
const bool readPort(uint8_t &state);
private:
I2C &m_i2c;
uint8_t m_address;
const bool writeRegister(const uint8_t reg, const uint8_t val);
const bool readRegister(const uint8_t reg, uint8_t &val);
};
}