128x64 EasyC OLED Display 1.0.0
This is a library for Soldered OLED Display
Loading...
Searching...
No Matches
Adafruit_BusIO_Register Class Reference

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)
 
 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)
 
 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 NULL for the unused interface, allowing libraries to mass-define all the registers.
 
bool read (uint8_t *buffer, uint8_t len)
 Read a buffer of data from the register location.
 
bool read (uint8_t *value)
 Read 1 byte of data from the register location.
 
bool read (uint16_t *value)
 Read 2 bytes of data from the register location.
 
uint32_t read (void)
 Read data from the register location. This does not do any error checking!
 
uint32_t readCached (void)
 Read cached data from last time we wrote to this register.
 
bool write (uint8_t *buffer, uint8_t len)
 Write a buffer of data to the register location.
 
bool write (uint32_t value, uint8_t numbytes=0)
 Write up to 4 bytes of data to the register location.
 
uint8_t width (void)
 The width of the register data, helpful for doing calculations.
 
void setWidth (uint8_t width)
 Set the default width of data.
 
void setAddress (uint16_t address)
 Set register address.
 
void setAddressWidth (uint16_t address_width)
 Set the width of register address.
 
void print (Stream *s=&Serial)
 Pretty printer for this register.
 
void println (Stream *s=&Serial)
 Pretty printer for this register.
 

Private Attributes

Adafruit_I2CDevice_i2cdevice
 
Adafruit_SPIDevice_spidevice
 
Adafruit_BusIO_SPIRegType _spiregtype
 
uint16_t _address
 
uint8_t _width
 
uint8_t _addrwidth
 
uint8_t _byteorder
 
uint8_t _buffer [4]
 
uint32_t _cached = 0
 

Detailed Description

The class which defines a device register (a location to read/write data from)

Constructor & Destructor Documentation

◆ Adafruit_BusIO_Register() [1/3]

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)

Parameters
i2cdeviceThe I2CDevice to use for underlying I2C access
reg_addrThe address pointer value for the I2C/SMBus register, can be 8 or 16 bits
widthThe width of the register data itself, defaults to 1 byte
byteorderThe byte order of the register (used when width is > 1), defaults to LSBFIRST
address_widthThe width of the register address itself, defaults to 1 byte

◆ Adafruit_BusIO_Register() [2/3]

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)

Parameters
spideviceThe SPIDevice to use for underlying SPI access
reg_addrThe address pointer value for the SPI register, can be 8 or 16 bits
typeThe method we use to read/write data to SPI (which is not as well defined as I2C)
widthThe width of the register data itself, defaults to 1 byte
byteorderThe byte order of the register (used when width is > 1), defaults to LSBFIRST
address_widthThe width of the register address itself, defaults to 1 byte

◆ Adafruit_BusIO_Register() [3/3]

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 NULL for the unused interface, allowing libraries to mass-define all the registers.

Parameters
i2cdeviceThe I2CDevice to use for underlying I2C access, if NULL we use SPI
spideviceThe SPIDevice to use for underlying SPI access, if NULL we use I2C
reg_addrThe address pointer value for the I2C/SMBus/SPI register, can be 8 or 16 bits
typeThe method we use to read/write data to SPI (which is not as well defined as I2C)
widthThe width of the register data itself, defaults to 1 byte
byteorderThe byte order of the register (used when width is > 1), defaults to LSBFIRST
address_widthThe width of the register address itself, defaults to 1 byte

Member Function Documentation

◆ print()

void Adafruit_BusIO_Register::print ( Stream * s = &Serial)

Pretty printer for this register.

Parameters
sThe Stream to print to, defaults to &Serial

◆ println()

void Adafruit_BusIO_Register::println ( Stream * s = &Serial)

Pretty printer for this register.

Parameters
sThe Stream to print to, defaults to &Serial

◆ read() [1/4]

bool Adafruit_BusIO_Register::read ( uint16_t * value)

Read 2 bytes of data from the register location.

Parameters
valuePointer to uint16_t variable to read into
Returns
True on successful write (only really useful for I2C as SPI is uncheckable)

◆ read() [2/4]

bool Adafruit_BusIO_Register::read ( uint8_t * buffer,
uint8_t len )

Read a buffer of data from the register location.

Parameters
bufferPointer to data to read into
lenNumber of bytes to read
Returns
True on successful write (only really useful for I2C as SPI is uncheckable)

◆ read() [3/4]

bool Adafruit_BusIO_Register::read ( uint8_t * value)

Read 1 byte of data from the register location.

Parameters
valuePointer to uint8_t variable to read into
Returns
True on successful write (only really useful for I2C as SPI is uncheckable)

◆ read() [4/4]

uint32_t Adafruit_BusIO_Register::read ( void )

Read data from the register location. This does not do any error checking!

Returns
Returns 0xFFFFFFFF on failure, value otherwise

◆ readCached()

uint32_t Adafruit_BusIO_Register::readCached ( void )

Read cached data from last time we wrote to this register.

Returns
Returns 0xFFFFFFFF on failure, value otherwise

◆ setAddress()

void Adafruit_BusIO_Register::setAddress ( uint16_t address)

Set register address.

Parameters
addressthe address from register

◆ setAddressWidth()

void Adafruit_BusIO_Register::setAddressWidth ( uint16_t address_width)

Set the width of register address.

Parameters
address_widththe width for register address

◆ setWidth()

void Adafruit_BusIO_Register::setWidth ( uint8_t width)

Set the default width of data.

Parameters
widththe default width of data read from register

◆ width()

uint8_t Adafruit_BusIO_Register::width ( void )

The width of the register data, helpful for doing calculations.

Returns
The data width used when initializing the register

◆ write() [1/2]

bool Adafruit_BusIO_Register::write ( uint32_t value,
uint8_t numbytes = 0 )

Write up to 4 bytes of data to the register location.

Parameters
valueData to write
numbytesHow many bytes from 'value' to write
Returns
True on successful write (only really useful for I2C as SPI is uncheckable)

◆ write() [2/2]

bool Adafruit_BusIO_Register::write ( uint8_t * buffer,
uint8_t len )

Write a buffer of data to the register location.

Parameters
bufferPointer to data to write
lenNumber of bytes to write
Returns
True on successful write (only really useful for I2C as SPI is uncheckable)

Member Data Documentation

◆ _address

uint16_t Adafruit_BusIO_Register::_address
private

◆ _addrwidth

uint8_t Adafruit_BusIO_Register::_addrwidth
private

◆ _buffer

uint8_t Adafruit_BusIO_Register::_buffer[4]
private

◆ _byteorder

uint8_t Adafruit_BusIO_Register::_byteorder
private

◆ _cached

uint32_t Adafruit_BusIO_Register::_cached = 0
private

◆ _i2cdevice

Adafruit_I2CDevice* Adafruit_BusIO_Register::_i2cdevice
private

◆ _spidevice

Adafruit_SPIDevice* Adafruit_BusIO_Register::_spidevice
private

◆ _spiregtype

Adafruit_BusIO_SPIRegType Adafruit_BusIO_Register::_spiregtype
private

◆ _width

uint8_t Adafruit_BusIO_Register::_width
private

The documentation for this class was generated from the following files: