Adafruit Bus IO Library
|
The class which defines a device register (a location to read/write data from) More...
#include <Adafruit_BusIO_Register.h>
Public Member Functions | |
Adafruit_BusIO_Register (Adafruit_I2CDevice *i2cdevice, uint16_t reg_addr, uint8_t width=1, uint8_t byteorder=LSBFIRST, uint8_t address_width=1) | |
Create a register we access over an I2C Device (which defines the bus and address) More... | |
Adafruit_BusIO_Register (Adafruit_SPIDevice *spidevice, uint16_t reg_addr, Adafruit_BusIO_SPIRegType type, uint8_t width=1, uint8_t byteorder=LSBFIRST, uint8_t address_width=1) | |
Create a register we access over an SPI Device (which defines the bus and CS pin) More... | |
Adafruit_BusIO_Register (Adafruit_I2CDevice *i2cdevice, Adafruit_SPIDevice *spidevice, Adafruit_BusIO_SPIRegType type, uint16_t reg_addr, uint8_t width=1, uint8_t byteorder=LSBFIRST, uint8_t address_width=1) | |
Create a register we access over an I2C or SPI Device. This is a handy function because we can pass in nullptr for the unused interface, allowing libraries to mass-define all the registers. More... | |
Adafruit_BusIO_Register (Adafruit_GenericDevice *genericdevice, uint16_t reg_addr, uint8_t width=1, uint8_t byteorder=LSBFIRST, uint8_t address_width=1) | |
Create a register we access over a GenericDevice. More... | |
bool | read (uint8_t *buffer, uint8_t len) |
Read a number of bytes from a register into a buffer. More... | |
bool | read (uint8_t *value) |
Read 1 byte of data from the register location. More... | |
bool | read (uint16_t *value) |
Read 2 bytes of data from the register location. More... | |
uint32_t | read (void) |
Read data from the register location. This does not do any error checking! More... | |
uint32_t | readCached (void) |
Read cached data from last time we wrote to this register. More... | |
bool | write (uint8_t *buffer, uint8_t len) |
Write a buffer of data to the register location. More... | |
bool | write (uint32_t value, uint8_t numbytes=0) |
Write up to 4 bytes of data to the register location. More... | |
uint8_t | width (void) |
The width of the register data, helpful for doing calculations. More... | |
void | setWidth (uint8_t width) |
Set the default width of data. More... | |
void | setAddress (uint16_t address) |
Set register address. More... | |
void | setAddressWidth (uint16_t address_width) |
Set the width of register address. More... | |
void | print (Stream *s=&Serial) |
Pretty printer for this register. More... | |
void | println (Stream *s=&Serial) |
Pretty printer for this register. More... | |
The class which defines a device register (a location to read/write data from)
Adafruit_BusIO_Register::Adafruit_BusIO_Register | ( | Adafruit_I2CDevice * | i2cdevice, |
uint16_t | reg_addr, | ||
uint8_t | width = 1 , |
||
uint8_t | byteorder = LSBFIRST , |
||
uint8_t | address_width = 1 |
||
) |
Create a register we access over an I2C Device (which defines the bus and address)
i2cdevice | The I2CDevice to use for underlying I2C access |
reg_addr | The address pointer value for the I2C/SMBus register, can be 8 or 16 bits |
width | The width of the register data itself, defaults to 1 byte |
byteorder | The byte order of the register (used when width is > 1), defaults to LSBFIRST |
address_width | The width of the register address itself, defaults to 1 byte |
Adafruit_BusIO_Register::Adafruit_BusIO_Register | ( | Adafruit_SPIDevice * | spidevice, |
uint16_t | reg_addr, | ||
Adafruit_BusIO_SPIRegType | type, | ||
uint8_t | width = 1 , |
||
uint8_t | byteorder = LSBFIRST , |
||
uint8_t | address_width = 1 |
||
) |
Create a register we access over an SPI Device (which defines the bus and CS pin)
spidevice | The SPIDevice to use for underlying SPI access |
reg_addr | The address pointer value for the SPI register, can be 8 or 16 bits |
type | The method we use to read/write data to SPI (which is not as well defined as I2C) |
width | The width of the register data itself, defaults to 1 byte |
byteorder | The byte order of the register (used when width is > 1), defaults to LSBFIRST |
address_width | The width of the register address itself, defaults to 1 byte |
Adafruit_BusIO_Register::Adafruit_BusIO_Register | ( | Adafruit_I2CDevice * | i2cdevice, |
Adafruit_SPIDevice * | spidevice, | ||
Adafruit_BusIO_SPIRegType | type, | ||
uint16_t | reg_addr, | ||
uint8_t | width = 1 , |
||
uint8_t | byteorder = LSBFIRST , |
||
uint8_t | address_width = 1 |
||
) |
Create a register we access over an I2C or SPI Device. This is a handy function because we can pass in nullptr for the unused interface, allowing libraries to mass-define all the registers.
i2cdevice | The I2CDevice to use for underlying I2C access, if nullptr we use SPI |
spidevice | The SPIDevice to use for underlying SPI access, if nullptr we use I2C |
reg_addr | The address pointer value for the I2C/SMBus/SPI register, can be 8 or 16 bits |
type | The method we use to read/write data to SPI (which is not as well defined as I2C) |
width | The width of the register data itself, defaults to 1 byte |
byteorder | The byte order of the register (used when width is > 1), defaults to LSBFIRST |
address_width | The width of the register address itself, defaults to 1 byte |
Adafruit_BusIO_Register::Adafruit_BusIO_Register | ( | Adafruit_GenericDevice * | genericdevice, |
uint16_t | reg_addr, | ||
uint8_t | width = 1 , |
||
uint8_t | byteorder = LSBFIRST , |
||
uint8_t | address_width = 1 |
||
) |
Create a register we access over a GenericDevice.
genericdevice | Generic device to use |
reg_addr | Register address we will read/write |
width | Width of the register in bytes (1-4) |
byteorder | Byte order of register data (LSBFIRST or MSBFIRST) |
address_width | Width of the register address in bytes (1 or 2) |
bool Adafruit_BusIO_Register::read | ( | uint8_t * | buffer, |
uint8_t | len | ||
) |
Read a number of bytes from a register into a buffer.
buffer | Buffer to read data into |
len | Number of bytes to read into the buffer |
bool Adafruit_BusIO_Register::read | ( | uint8_t * | value | ) |
Read 1 byte of data from the register location.
value | Pointer to uint8_t variable to read into |
bool Adafruit_BusIO_Register::read | ( | uint16_t * | value | ) |
Read 2 bytes of data from the register location.
value | Pointer to uint16_t variable to read into |
uint32_t Adafruit_BusIO_Register::read | ( | void | ) |
Read data from the register location. This does not do any error checking!
uint32_t Adafruit_BusIO_Register::readCached | ( | void | ) |
Read cached data from last time we wrote to this register.
bool Adafruit_BusIO_Register::write | ( | uint8_t * | buffer, |
uint8_t | len | ||
) |
Write a buffer of data to the register location.
buffer | Pointer to data to write |
len | Number of bytes to write |
bool Adafruit_BusIO_Register::write | ( | uint32_t | value, |
uint8_t | numbytes = 0 |
||
) |
Write up to 4 bytes of data to the register location.
value | Data to write |
numbytes | How many bytes from 'value' to write |
uint8_t Adafruit_BusIO_Register::width | ( | void | ) |
The width of the register data, helpful for doing calculations.
void Adafruit_BusIO_Register::setWidth | ( | uint8_t | width | ) |
Set the default width of data.
width | the default width of data read from register |
void Adafruit_BusIO_Register::setAddress | ( | uint16_t | address | ) |
Set register address.
address | the address from register |
void Adafruit_BusIO_Register::setAddressWidth | ( | uint16_t | address_width | ) |
Set the width of register address.
address_width | the width for register address |
void Adafruit_BusIO_Register::print | ( | Stream * | s = &Serial | ) |
Pretty printer for this register.
s | The Stream to print to, defaults to &Serial |
void Adafruit_BusIO_Register::println | ( | Stream * | s = &Serial | ) |
Pretty printer for this register.
s | The Stream to print to, defaults to &Serial |