Class for communicating with a device via generic read/write functions.
More...
#include <Adafruit_GenericDevice.h>
|
| | Adafruit_GenericDevice (void *obj, busio_genericdevice_read_t read_func, busio_genericdevice_write_t write_func, busio_genericdevice_readreg_t readreg_func=nullptr, busio_genericdevice_writereg_t writereg_func=nullptr) |
| | Create a Generic device with the provided read/write functions. More...
|
| |
| bool | begin (void) |
| | Simple begin function (doesn't do much at this time) More...
|
| |
| void | end (void) |
| | Marks the GenericDevice as no longer in use. More...
|
| |
| bool | read (uint8_t *buffer, size_t len) |
| | Read data into a buffer. More...
|
| |
| bool | write (const uint8_t *buffer, size_t len) |
| | Write a buffer of data. More...
|
| |
| bool | readRegister (uint8_t *addr_buf, uint8_t addrsiz, uint8_t *buf, uint16_t bufsiz) |
| | Read from a register location. More...
|
| |
| bool | writeRegister (uint8_t *addr_buf, uint8_t addrsiz, const uint8_t *buf, uint16_t bufsiz) |
| | Write to a register location. More...
|
| |
|
|
busio_genericdevice_read_t | _read_func |
| | Function pointer for reading raw data from the device.
|
| |
|
busio_genericdevice_write_t | _write_func |
| | Function pointer for writing raw data to the device.
|
| |
|
busio_genericdevice_readreg_t | _readreg_func |
| | Function pointer for reading a 'register' from the device.
|
| |
|
busio_genericdevice_writereg_t | _writereg_func |
| | Function pointer for writing a 'register' to the device.
|
| |
| bool | _begun |
| |
Class for communicating with a device via generic read/write functions.
◆ Adafruit_GenericDevice()
| Adafruit_GenericDevice::Adafruit_GenericDevice |
( |
void * |
obj, |
|
|
busio_genericdevice_read_t |
read_func, |
|
|
busio_genericdevice_write_t |
write_func, |
|
|
busio_genericdevice_readreg_t |
readreg_func = nullptr, |
|
|
busio_genericdevice_writereg_t |
writereg_func = nullptr |
|
) |
| |
Create a Generic device with the provided read/write functions.
- Parameters
-
| obj | Pointer to object instance |
| read_func | Function pointer for reading raw data |
| write_func | Function pointer for writing raw data |
| readreg_func | Function pointer for reading registers (optional) |
| writereg_func | Function pointer for writing registers (optional) |
◆ begin()
| bool Adafruit_GenericDevice::begin |
( |
void |
| ) |
|
Simple begin function (doesn't do much at this time)
- Returns
- true always
◆ end()
| void Adafruit_GenericDevice::end |
( |
void |
| ) |
|
Marks the GenericDevice as no longer in use.
- Note
- : Since this is a GenericDevice, if you are using this with a Serial object, this does NOT disable serial communication or release the RX/TX pins. That must be done manually by calling Serial.end().
◆ read()
| bool Adafruit_GenericDevice::read |
( |
uint8_t * |
buffer, |
|
|
size_t |
len |
|
) |
| |
Read data into a buffer.
- Parameters
-
| buffer | Pointer to buffer to read data into |
| len | Number of bytes to read |
- Returns
- true if read was successful, otherwise false
◆ write()
| bool Adafruit_GenericDevice::write |
( |
const uint8_t * |
buffer, |
|
|
size_t |
len |
|
) |
| |
Write a buffer of data.
- Parameters
-
| buffer | Pointer to buffer of data to write |
| len | Number of bytes to write |
- Returns
- true if write was successful, otherwise false
◆ readRegister()
| bool Adafruit_GenericDevice::readRegister |
( |
uint8_t * |
addr_buf, |
|
|
uint8_t |
addrsiz, |
|
|
uint8_t * |
buf, |
|
|
uint16_t |
bufsiz |
|
) |
| |
Read from a register location.
- Parameters
-
| addr_buf | Buffer containing register address |
| addrsiz | Size of register address in bytes |
| buf | Buffer to store read data |
| bufsiz | Size of data to read in bytes |
- Returns
- true if read was successful, otherwise false
◆ writeRegister()
| bool Adafruit_GenericDevice::writeRegister |
( |
uint8_t * |
addr_buf, |
|
|
uint8_t |
addrsiz, |
|
|
const uint8_t * |
buf, |
|
|
uint16_t |
bufsiz |
|
) |
| |
Write to a register location.
- Parameters
-
| addr_buf | Buffer containing register address |
| addrsiz | Size of register address in bytes |
| buf | Buffer containing data to write |
| bufsiz | Size of data to write in bytes |
- Returns
- true if write was successful, otherwise false
◆ _begun
| bool Adafruit_GenericDevice::_begun |
|
protected |
whether we have initialized yet (in case the function needs to do something)
The documentation for this class was generated from the following files: