diff --git a/src/databus/Arduino_XCA9554SWSPI.cpp b/src/databus/Arduino_XCA9554SWSPI.cpp index d5944990..19eb7855 100644 --- a/src/databus/Arduino_XCA9554SWSPI.cpp +++ b/src/databus/Arduino_XCA9554SWSPI.cpp @@ -3,14 +3,14 @@ //#define XCA9554_DEBUG Arduino_XCA9554SWSPI::Arduino_XCA9554SWSPI(int8_t rst, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire, uint8_t i2c_addr) - : _rst(rst), _cs(cs), _sck(sck), _mosi(mosi), _wire(wire), _address(i2c_addr) + : _rst(rst), _cs(cs), _sck(sck), _mosi(mosi), _wire(wire), _i2c_addr(i2c_addr) { } bool Arduino_XCA9554SWSPI::begin(int32_t, int8_t) { _wire->begin(); - _wire->beginTransmission(_address); + _wire->beginTransmission(_i2c_addr); if (!_wire->endTransmission()) { Serial.println("Found xCA9554"); @@ -148,7 +148,7 @@ void Arduino_XCA9554SWSPI::writeRegister(uint8_t reg, uint8_t *data, size_t len) #ifdef XCA9554_DEBUG Serial.printf("Writing to $%02X: ", reg); #endif - _wire->beginTransmission(_address); + _wire->beginTransmission(_i2c_addr); _wire->write(reg); for (size_t i = 0; i < len; i++) { @@ -165,13 +165,13 @@ void Arduino_XCA9554SWSPI::writeRegister(uint8_t reg, uint8_t *data, size_t len) uint8_t Arduino_XCA9554SWSPI::readRegister(uint8_t reg, uint8_t *data, size_t len) { - _wire->beginTransmission(_address); + _wire->beginTransmission(_i2c_addr); _wire->write(reg); #ifdef XCA9554_DEBUG Serial.printf("Read from $%02X: ", reg); #endif _wire->endTransmission(); - _wire->requestFrom(_address, len); + _wire->requestFrom(_i2c_addr, len); size_t index = 0; while (index < len) { data[index++] = _wire->read(); @@ -225,7 +225,6 @@ int Arduino_XCA9554SWSPI::digitalRead(uint8_t pin) { if (is_found) { - int state = 0; uint8_t port = 0; this->readRegister(XCA9554_INPUT_PORT_REG, &port, 1); //Serial.printf("Read 0x%02X\n", port); diff --git a/src/databus/Arduino_XCA9554SWSPI.h b/src/databus/Arduino_XCA9554SWSPI.h index ea064ea8..94b6d4af 100644 --- a/src/databus/Arduino_XCA9554SWSPI.h +++ b/src/databus/Arduino_XCA9554SWSPI.h @@ -5,7 +5,7 @@ #include "Arduino_DataBus.h" -#define XCA9554_IIC_ADDRESS 0x38 +#define XCA9554_IIC_i2c_addr 0x38 #define XCA9554_INPUT_PORT_REG 0x00 #define XCA9554_OUTPUT_PORT_REG 0x01 @@ -15,7 +15,7 @@ class Arduino_XCA9554SWSPI : public Arduino_DataBus { public: - Arduino_XCA9554SWSPI(int8_t rst, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire = &Wire, uint8_t i2c_addr = XCA9554_IIC_ADDRESS); + Arduino_XCA9554SWSPI(int8_t rst, int8_t cs, int8_t sck, int8_t mosi, TwoWire *wire = &Wire, uint8_t i2c_addr = XCA9554_IIC_i2c_addr); bool begin(int32_t speed = GFX_NOT_DEFINED, int8_t dataMode = GFX_NOT_DEFINED) override; void beginWrite() override; @@ -39,11 +39,12 @@ class Arduino_XCA9554SWSPI : public Arduino_DataBus void writeRegister(uint8_t reg, uint8_t *data, size_t len); uint8_t readRegister(uint8_t reg, uint8_t *data, size_t len); - uint8_t _address, output_buf = 0; + uint8_t output_buf = 0; bool is_found; int8_t _rst, _cs, _sck, _mosi; TwoWire *_wire; + uint8_t _i2c_addr; private: };