diff --git a/Adafruit_BusIO_Register.cpp b/Adafruit_BusIO_Register.cpp index 7f8c37a..fb4735a 100644 --- a/Adafruit_BusIO_Register.cpp +++ b/Adafruit_BusIO_Register.cpp @@ -310,3 +310,25 @@ bool Adafruit_BusIO_RegisterBits::write(uint32_t data) { * @returns The data width used when initializing the register */ uint8_t Adafruit_BusIO_Register::width(void) { return _width; } + +/*! + * @brief Set the default width of data + * @param width the default width of data read from register + */ +void Adafruit_BusIO_Register::setWidth(uint8_t width) { _width = width; } + +/*! + * @brief Set register address + * @param address the address from register + */ +void Adafruit_BusIO_Register::setAddress(uint16_t address) { + _address = address; +} + +/*! + * @brief Set the width of register address + * @param address_width the width for register address + */ +void Adafruit_BusIO_Register::setAddressWidth(uint16_t address_width) { + _addrwidth = address_width; +} diff --git a/Adafruit_BusIO_Register.h b/Adafruit_BusIO_Register.h index 278ccc8..bc27e5f 100644 --- a/Adafruit_BusIO_Register.h +++ b/Adafruit_BusIO_Register.h @@ -33,6 +33,7 @@ public: Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice, uint16_t reg_addr, uint8_t width = 1, uint8_t byteorder = LSBFIRST, uint8_t address_width = 1); + Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice, uint16_t reg_addr, Adafruit_BusIO_SPIRegType type, uint8_t width = 1, uint8_t byteorder = LSBFIRST, @@ -54,6 +55,10 @@ public: uint8_t width(void); + void setWidth(uint8_t width); + void setAddress(uint16_t address); + void setAddressWidth(uint16_t address_width); + void print(Stream *s = &Serial); void println(Stream *s = &Serial);