![]() |
SparkFun Toolkit
v1.0.5-6-g34ffa30
Core Functionality Library
|
This class implements the IBus interface for an SPI Implementation on Arduino. More...
#include <sfTkArdSPI.h>
Public Member Functions | |
sfTkArdSPI (void) | |
Constructor for Arduino SPI bus object of the toolkit. More... | |
sfTkArdSPI (uint8_t csPin) | |
Constructor for Arduino SPI bus object of the toolkit. More... | |
sfTkArdSPI (sfTkArdSPI const &rhs) | |
Copy constructor for Arduino SPI bus object of the toolkit. More... | |
sfTkArdSPI & | operator= (const sfTkArdSPI &rhs) |
Assignment copy operator for Arduino SPI bus object of the toolkit. More... | |
sfTkError_t | init (bool bInit=false) |
Method sets up the required SPI settings. More... | |
sfTkError_t | init (uint8_t csPin, bool bInit=false) |
Method sets up the required SPI settings. More... | |
sfTkError_t | init (SPIClass &spiPort, SPISettings &busSPISettings, uint8_t csPin, bool bInit=false) |
Method sets up the required SPI settings. More... | |
sfTkError_t | writeRegion (const uint8_t *data, size_t length) |
Write an array of data to the device without indexing to a register. More... | |
sfTkError_t | writeRegister (uint8_t *devReg, size_t regLength, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's address. More... | |
sfTkError_t | writeRegister (uint16_t devReg, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's address. More... | |
sfTkError_t | writeRegister (uint16_t devReg, const uint16_t *data, size_t length) |
Writes a number of uint16s starting at the given register's address. More... | |
sfTkError_t | readRegister (uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, size_t &readBytes, uint32_t read_delay=0) |
Reads data from a specified register of an I2C device. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint8_t *data, size_t numBytes, size_t &readBytes) |
Reads a block of data from the given register. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint16_t *data, size_t length, size_t &readWords) |
Reads a block of data from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, size_t &readBytes, uint32_t read_delay=0)=0 |
Reads an array of bytes to a register on the target address. Supports any address size. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint8_t &data) |
Read a single byte from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint16_t &data) |
Read a single word (16 bit) from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint32_t &data) |
Read a 32 bit value from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes) |
Reads data from a specified register. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint8_t &value) |
Overloaded function to read a 8-bit value from the given 16-bit register address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint16_t &value) |
Overloaded function to read a 16-bit value from the given 16-bit register address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint32_t &value) |
Overloaded function to read a 32-bit value from the given 16-bit register address. More... | |
sfTkError_t | readRegister (uint16_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes) |
Reads a specified number of bytes from a given register with a 16bit address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint16_t *data, size_t length, size_t &read16) |
Reads a 16-bit block of data from the given 16-bit register address. More... | |
virtual sfTkError_t | writeRegister (uint8_t *devReg, size_t regLength, const uint8_t *data, size_t length)=0 |
Writes an array of bytes to a register on the target address. Supports any address size. More... | |
sfTkError_t | writeRegister (uint8_t devReg, uint8_t data) |
Write a single byte (8 bit) to the given register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint16_t data) |
Write a single word (16 bit) to the given register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's address. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's 16-bit address. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint8_t data) |
Writes a 8-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint16_t data) |
Writes a 16-bit data value to a specified device 16bit register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint16_t *data, size_t length) |
Writes a number of uint16's starting at the given register's 16-bit address. More... | |
![]() | |
sfTkISPI () | |
Constructor for the SPI bus. More... | |
sfTkISPI (uint8_t csPin) | |
Constructor for the SPI bus. More... | |
virtual void | setCS (uint8_t devCS) |
setter for the CS Pin More... | |
virtual uint8_t | cs (void) |
getter for the cs pin More... | |
virtual uint8_t | type (void) |
Get the type of the object. More... | |
![]() | |
sfTkIBus () | |
Constructor. More... | |
virtual sfTkError_t | writeRegister (uint8_t *devReg, size_t regLength, const uint8_t *data, size_t length)=0 |
Writes an array of bytes to a register on the target address. Supports any address size. More... | |
virtual sfTkError_t | writeData (uint8_t data) |
Writes a 8-bit data value. More... | |
sfTkError_t | writeUInt8 (uint8_t data) |
Writes a 8-bit data value. More... | |
virtual sfTkError_t | writeData (uint16_t data) |
Send a 16 bit value to the device. More... | |
sfTkError_t | writeUInt16 (uint16_t data) |
Send a 16 bit value to the device. More... | |
virtual sfTkError_t | writeData (uint32_t data) |
Writes a 32-bit data value. More... | |
sfTkError_t | writeUInt32 (uint32_t data) |
Writes a 32-bit data value. More... | |
virtual sfTkError_t | writeData (const uint8_t *data, size_t length) |
Writes an array. More... | |
sfTkError_t | writeRegister (uint8_t devReg, uint8_t data) |
Write a single byte (8 bit) to the given register. More... | |
sfTkError_t | writeRegisterUInt8 (uint8_t reg, uint8_t data) |
Write a single byte (8 bit) to the given register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint16_t data) |
Write a single word (16 bit) to the given register. More... | |
sfTkError_t | writeRegisterUInt16 (uint8_t reg, uint16_t data) |
Write a single word (16 bit) to the given register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
sfTkError_t | writeRegisterUInt32 (uint8_t reg, uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint8_t devReg, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's address. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint8_t *data, size_t length) |
Writes a number of bytes starting at the given register's 16-bit address. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint8_t data) |
Writes a 8-bit data value to a specified device register. More... | |
sfTkError_t | writeRegisterUInt8 (uint16_t reg, const uint8_t data) |
Writes a 8-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint16_t data) |
Writes a 16-bit data value to a specified device 16bit register. More... | |
sfTkError_t | writeRegisterUInt16 (uint16_t reg, const uint16_t data) |
Writes a 16-bit data value to a specified device 16bit register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
sfTkError_t | writeRegisterUInt32 (uint16_t reg, const uint32_t data) |
Writes a 32-bit data value to a specified device register. More... | |
virtual sfTkError_t | writeRegister (uint16_t devReg, const uint16_t *data, size_t length) |
Writes a number of uint16's starting at the given register's 16-bit address. More... | |
virtual sfTkError_t | readRegister (uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, size_t &readBytes, uint32_t read_delay=0)=0 |
Reads an array of bytes to a register on the target address. Supports any address size. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint8_t &data) |
Read a single byte from the given register. More... | |
sfTkError_t | readRegisterUInt8 (uint8_t devReg, uint8_t &data) |
Read a single byte from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint16_t &data) |
Read a single word (16 bit) from the given register. More... | |
sfTkError_t | readRegisterUInt16 (uint8_t devReg, uint16_t &data) |
Read a single word (16 bit) from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint32_t &data) |
Read a 32 bit value from the given register. More... | |
sfTkError_t | readRegisterUInt32 (uint8_t devReg, uint32_t &data) |
Read a 32 bit value from the given register. More... | |
virtual sfTkError_t | readRegister (uint8_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes) |
Reads data from a specified register. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint8_t &value) |
Overloaded function to read a 8-bit value from the given 16-bit register address. More... | |
sfTkError_t | readRegisterUInt8 (uint16_t devReg, uint8_t &data) |
Overloaded function to read a 8-bit value from the given 16-bit register address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint16_t &value) |
Overloaded function to read a 16-bit value from the given 16-bit register address. More... | |
sfTkError_t | readRegisterUInt16 (uint16_t devReg, uint16_t &data) |
Overloaded function to read a 16-bit value from the given 16-bit register address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint32_t &value) |
Overloaded function to read a 32-bit value from the given 16-bit register address. More... | |
sfTkError_t | readRegisterUInt32 (uint16_t devReg, uint32_t &data) |
Overloaded function to read a 32-bit value from the given 16-bit register address. More... | |
sfTkError_t | readRegister (uint16_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes) |
Reads a specified number of bytes from a given register with a 16bit address. More... | |
virtual sfTkError_t | readRegister (uint16_t reg, uint16_t *data, size_t length, size_t &read16) |
Reads a 16-bit block of data from the given 16-bit register address. More... | |
virtual uint8_t | type (void) |
Get the type of the object. More... | |
void | setByteOrder (sfTkByteOrder order) |
Set the byte order for multi-byte data transfers. More... | |
sfTkByteOrder | byteOrder (void) |
Get the current byte order. More... | |
Protected Attributes | |
SPIClass * | _spiPort |
SPISettings | _sfeSPISettings |
![]() | |
sfTkByteOrder | _byteOrder |
Additional Inherited Members | |
![]() | |
static constexpr uint8_t | kNoCSPin = 0 |
A constant for no CS pin. More... | |
This class implements the IBus interface for an SPI Implementation on Arduino.
|
inline |
Constructor for Arduino SPI bus object of the toolkit.
|
inline |
Constructor for Arduino SPI bus object of the toolkit.
csPin | The CS Pin for the device |
|
inline |
Copy constructor for Arduino SPI bus object of the toolkit.
rhs | source of the copy operation |
sfTkError_t sfTkArdSPI::init | ( | bool | bInit = false | ) |
Method sets up the required SPI settings.
bInit | Init the device - default is false. |
sfTkError_t | - ksfTkErrOk on success |
sfTkError_t sfTkArdSPI::init | ( | SPIClass & | spiPort, |
SPISettings & | busSPISettings, | ||
uint8_t | csPin, | ||
bool | bInit = false |
||
) |
Method sets up the required SPI settings.
spiPort | Port for SPI communication. |
busSPISettings | Settings for speed, endianness, and spi mode of the SPI bus. |
csPin | The CS Pin for the device |
bInit | This flag tracks whether the bus has been initialized. |
sfTkError_t | - ksfTkErrOk on success |
sfTkError_t sfTkArdSPI::init | ( | uint8_t | csPin, |
bool | bInit = false |
||
) |
Method sets up the required SPI settings.
csPin | The CS Pin for the device |
bInit | Init the device - default is false. |
sfTkError_t | - ksfTkErrOk on success |
|
inline |
Assignment copy operator for Arduino SPI bus object of the toolkit.
rhs | The right hand side of the assignment. |
|
inline |
Reads a specified number of bytes from a given register with a 16bit address.
This function reads data from a 16-bit register and stores it in the provided buffer.
devReg | The 16-bit register address to read from. Byteswapped if needed. |
data | Pointer to the buffer where the read data will be stored. |
numBytes | The number of bytes to read from the register. |
readBytes | Reference to a variable where the number of bytes actually read will be stored. |
|
inlinevirtual |
Overloaded function to read a 16-bit value from the given 16-bit register address.
This function reads a 16-bit value from the specified 16-bit register address.
reg | The device's 16-bit register's address. The address is byteswapped if needed. | |
[out] | value | The 16-bit value read from the register. The value is byte swapped if needed. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Reads a 16-bit block of data from the given 16-bit register address.
reg | The device's 16 bit register's address. Byteswapped if needed | |
data | Data area to read into - byteswapped if needed | |
length | - length of data (16 bit element count) | |
[out] | read16 | - number of 16 bit words read |
int | returns ksfTkErrOk on success, or ksfTkErrFail code |
Reimplemented from sfTkIBus.
|
virtual |
Reads a block of data from the given register.
reg | The device's register's 16 bit address. | |
[out] | data | Data buffer to read into |
length | - Length of data to read/size of data buffer | |
[out] | readWords | - Number of words read |
sfTkError_t | - true on success |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Overloaded function to read a 32-bit value from the given 16-bit register address.
This function reads a 32-bit value from the specified 16-bit register address.
reg | The device's 16-bit register's address. The address is byteswapped if needed. | |
[out] | value | The 32-bit value read from the register. The value is byte swapped if needed. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Overloaded function to read a 8-bit value from the given 16-bit register address.
This function reads a 8-bit value from the specified 16-bit register address.
reg | The device's 16-bit register's address. The address is byteswapped if needed | |
[out] | value | The 8-bit value read from the register. |
Reimplemented from sfTkIBus.
|
virtual |
Reads a block of data from the given register.
reg | The device's register's 16 bit address. | |
[out] | data | Data buffer to read into |
numBytes | - Length of data to read/size of data buffer | |
[out] | readBytes | - Number of bytes read |
sfTkError_t | - true on success |
|
virtual |
Reads data from a specified register of an I2C device.
devReg | Pointer to the register address to read from. |
regLength | Length of the register address. |
data | Pointer to the buffer where the read data will be stored. |
numBytes | Number of bytes to read from the register. |
readBytes | Reference to a variable where the number of bytes actually read will be stored. |
read_delay | After sending the address, delay in milliseconds before reading the data |
Implements sfTkIBus.
|
virtual |
Reads an array of bytes to a register on the target address. Supports any address size.
devReg | The device's register's address - can be any size |
regLength | The length of the register address |
data | The data to buffer to read into |
numBytes | The length of the data buffer |
readBytes[out] | The number of bytes read |
read_delay | After sending the address, delay in milliseconds before reading the data |
Implements sfTkIBus.
|
inlinevirtual |
Read a single word (16 bit) from the given register.
devReg | The device's register's address. |
data | Data to read.– the data value is byteswapped if needed |
sfTkError_t | - ksfTkErrOk on successful execution. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Read a 32 bit value from the given register.
devReg | The device's register's address. |
data | Data to read. The data value is byteswapped if needed |
sfTkError_t | - ksfTkErrOk on successful execution. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Read a single byte from the given register.
devReg | The device's register's address. |
data | Data to read. |
sfTkError_t | - ksfTkErrOk on successful execution. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Reads data from a specified register.
This function reads a specified number of bytes from a given register and stores the data in the provided buffer.
devReg | The register address to read from. |
data | Pointer to the buffer where the read data will be stored. |
numBytes | The number of bytes to read from the register. |
readBytes | Reference to a variable where the number of bytes actually read will be stored. |
Reimplemented from sfTkIBus.
sfTkError_t sfTkArdSPI::writeRegion | ( | const uint8_t * | data, |
size_t | length | ||
) |
Write an array of data to the device without indexing to a register.
data | Data to write |
length | Length of Data |
sfTkError_t | - ksfTkErrOk on success |
|
virtual |
Writes a number of uint16s starting at the given register's address.
devReg | The device's register's address. |
data | Data to write. |
length | - length of data |
sfTkError_t | - ksfTkErrOk on success |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a number of uint16's starting at the given register's 16-bit address.
devReg | The device's register's address. |
data | 16 bit Data to write. This value is byteswapped if the byteorder set is different than the systems byteorder |
length | - length of data |
sfTkError_t | ksfTkErrOk on successful execution |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a 16-bit data value to a specified device 16bit register.
This function writes a 16-bit data value to a specified device register. If the system byte order differs from the byte order expected by the device, the data value is byte-swapped before being written.
devReg | The 16 bit register address to write to. |
data | The 16-bit data value to write. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a 32-bit data value to a specified device register.
This function writes a 32-bit data value to a specified device register. If the system byte order differs from the byte order expected by the device, the data value is byte-swapped before being written.
devReg | The register address to write to. |
data | The 32-bit data value to write. This value is byteswapped if the byteorder set is different that the systems byteorder |
Reimplemented from sfTkIBus.
|
virtual |
Writes a number of bytes starting at the given register's address.
devReg | The device's register's address. |
data | Data to write. |
length | - length of data |
sfTkError_t | - ksfTkErrOk on success |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a number of bytes starting at the given register's 16-bit address.
devReg | The device's register's 16 bit address. If the byteorder is different than the systems, the address is byteswapped |
data | Data to write. |
length | - length of data |
sfTkError_t | ksfTkErrOk on successful execution |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a 8-bit data value to a specified device register.
This function writes a 16-bit data value to a specified device register. If the system byte order differs from the byte order expected by the device, the data value is byte-swapped before being written.
devReg | The device's register's 16 bit address. If the byteorder is different than the systems, the address is byteswapped |
data | The 8-bit data value to write. |
Reimplemented from sfTkIBus.
|
virtual |
Writes a number of bytes starting at the given register's address.
devReg | The device's register's address. |
regLength | Size of the address - value of 1 or 2 are only accepted |
data | Data to write. |
length | - length of data |
sfTkError_t | - ksfTkErrOk on success |
Implements sfTkIBus.
|
virtual |
Writes an array of bytes to a register on the target address. Supports any address size.
devReg | The device's register's address - can be any size, If nullptr, address is not sent |
regLength | The length of the register address. If 0, address is not sent |
data | The data to write |
length | The length of the data buffer |
Implements sfTkIBus.
|
inlinevirtual |
Write a single word (16 bit) to the given register.
devReg | The device's register's address. |
data | Data to write. Note - if byte order differs, swap the data before writing. |
sfTkError_t | - ksfTkErrOk on successful execution. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a 32-bit data value to a specified device register.
This function writes a 32-bit data value to a specified device register. If the system byte order differs from the byte order expected by the device, the data value is byte-swapped before being written.
devReg | The register address to write to. |
data | The 32-bit data value to write. |
Reimplemented from sfTkIBus.
|
inlinevirtual |
Writes a number of bytes starting at the given register's address.
devReg | The device's register's address. |
data | Data to write. |
length | - length of data |
sfTkError_t | ksfTkErrOk on successful execution |
Reimplemented from sfTkIBus.
|
inline |
Write a single byte (8 bit) to the given register.
devReg | The device's register's address. |
data | Data to write. Note - if byte order differs, swap the data before writing. |
sfTkError_t | - ksfTkErrOk on successful execution. |
|
protected |
This object's spi settings are used for every transaction.
|
protected |
Pointer to the spi port being used