#pragma once #define DEBUGLOG_DEFAULT_LOG_LEVEL_INFO #include #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: typedef enum { DO1, DO2, DO3, DO4, DO5, DO6, DO7, DO8, DO_MAX } channel_t; TCA9554PWR(I2C &i2c, const uint8_t address); ~TCA9554PWR(); const bool setOut(const uint8_t channel, const bool state); const bool toggleOut(const uint8_t channel); const bool setPort(const uint8_t state); const bool readOut(const uint8_t channel, bool &state); 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); }; }