|
void | FlxCard::i2c_read (const char *device_str, u_char reg_addr, u_char *value, int nbytes=1) |
|
void | FlxCard::i2c_write (const char *device_str, u_char reg_addr, u_char data) |
|
void | FlxCard::i2c_write (const char *device_str, u_char reg_addr, u_char *data, int nbytes) |
|
void | FlxCard::i2c_write_byte (u_char dev_addr, u_char byte) |
|
void | FlxCard::i2c_write_byte (u_char dev_addr, u_char reg_addr, u_char byte) |
|
u_char | FlxCard::i2c_read_byte (u_char dev_addr, u_char reg_addr) |
|
bool | FlxCard::i2c_flush (u_int *count=0) |
|
void | FlxCard::i2c_write_bytes (uint8_t dev_addr, uint8_t reg_addr, int nbytes, uint8_t *bytes) |
|
void | FlxCard::i2c_read_bytes (uint8_t dev_addr, uint8_t reg_addr, int nbytes, uint8_t *bytes) |
|
A set of functions that interact with the onboard I2C bus.
◆ i2c_read()
void FlxCard::i2c_read |
( |
const char * | device_str, |
|
|
u_char | reg_addr, |
|
|
u_char * | value, |
|
|
int | nbytes = 1 ) |
These methods read and write 8-bit data words from/to a named I2C device.
Errors In case of an error, an exception is thrown.
- Parameters
-
*device_str | A string of the form “p1:p2:p3:addr”: see table below for details. Alternatively the string can be the name of the I2C endpoint device You must use the predefined names: find out by running "flx-i2c list" |
reg_addr | The address of the register within the device |
data | The data that is to be written to the register |
value | A pointer to a value that will be filled with the data read from the I2C device |
Description of the sub-parameters in parameter device_str:
Sub-parameter | Description |
p1 | The port number on the primary I2C switch to select; run "flx-i2c list" to find out where the I2C device you want to access, is located in the I2C tree |
p2 | In case of cascaded switches the secondary switch's port number to select |
p3 | In case of cascaded switches this is the third switch's port number |
addr | The I2C address of the endpoint device behind the switch(es) |
As an alternative to a string of the format defined above, parameter device_str can a symbolic name of an I2C endpoint device; get a listing of all available I2C devices on all platforms by running "flx-i2c list all".
◆ i2c_write()
void FlxCard::i2c_write |
( |
const char * | device_str, |
|
|
u_char | reg_addr, |
|
|
u_char | data ) |
◆ i2c_write_byte() [1/2]
void FlxCard::i2c_write_byte |
( |
u_char | dev_addr, |
|
|
u_char | byte ) |
These methods read or write one byte of data to/from an I2C address. In case the I2C is stuck the method will abort after 1 second with a time-out error. Before transferring the byte the methods call private function i2c_wait_not_full() in order to make sure that the I2C interface is not busy.
Errors In case of an error, an exception is thrown.
- Parameters
-
dev_addr | The address of the I2C device |
byte | The byte that is to be written to the I2C device |
◆ i2c_write_byte() [2/2]
void FlxCard::i2c_write_byte |
( |
u_char | dev_addr, |
|
|
u_char | reg_addr, |
|
|
u_char | byte ) |
- Parameters
-
dev_addr | The address of the I2C device |
reg_addr | The register address inside the I2C device |
byte | The byte that is to be written to the register in the I2C device |
◆ i2c_read_byte()
u_char FlxCard::i2c_read_byte |
( |
u_char | dev_addr, |
|
|
u_char | reg_addr ) |
- Parameters
-
dev_addr | The address of the I2C device |
reg_addr | The register address inside the I2C device to read from |
◆ i2c_flush()
bool FlxCard::i2c_flush |
( |
u_int * | count = 0 | ) |
|
Can be used to flush the I2C read FIFO. Up to 16 bytes are flushed, the exact number returned optionally in 'count'. Errors Returns false if after 16 bytes flushed the FIFO is still not empty.
- Parameters
-
count | Number of bytes flushed |
◆ i2c_write_bytes()
void FlxCard::i2c_write_bytes |
( |
uint8_t | dev_addr, |
|
|
uint8_t | reg_addr, |
|
|
int | nbytes, |
|
|
uint8_t * | bytes ) |
Read or write one or two bytes of data to/from an I2C address plus register address.