mraa
0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
An I2c object represents an i2c master and can talk multiple i2c slaves by selecting the correct address It is considered best practice to make sure the address is correct before doing any calls on i2c, in case another application or even thread changed the addres on that bus. Multiple instances of the same bus can exist.
Public Member Functions | |
I2c (int bus, bool raw=false) | |
~I2c () | |
mraa_result_t | frequency (mraa_i2c_mode_t mode) |
mraa_result_t | address (uint8_t address) |
uint8_t | readByte () |
int | read (uint8_t *data, int length) |
uint8_t | readReg (uint8_t reg) |
uint16_t | readWordReg (uint8_t reg) |
mraa_result_t | writeByte (uint8_t data) |
mraa_result_t | write (const uint8_t *data, int length) |
mraa_result_t | writeReg (uint8_t reg, uint8_t data) |
mraa_result_t | writeWordReg (uint8_t reg, uint16_t data) |
|
inline |
Instantiates an i2c bus. Multiple instances of the same bus can exist and the bus is not guarranteed to be on the correct address before read/write.
bus | The i2c bus to use |
raw | Whether to disable pinmapper for your board |
|
inline |
Closes the I2c Bus used. This does not guarrantee the bus will not be usable by anyone else or communicates this disconnect to any slaves.
|
inline |
Sets the i2c Frequency for communication. Your board may not support the set frequency. Anyone can change this at any time and this will affect every slave on the bus
mode | Frequency to set the bus to |
|
inline |
Set the slave to talk to, typically called before every read/write operation
address | Communicate to the i2c slave on this address |
|
inline |
Read exactly one byte from the bus
|
inline |
Read length bytes from the bus into *data pointer
@param data Data to read into @param length Size of read in bytes to make @return length of read, should match length
|
inline |
Read byte from an i2c register
reg | Register to read from |
|
inline |
Read word from an i2c register
reg | Register to read from |
|
inline |
Write a byte on the bus
data | The byte to send on the bus |
|
inline |
Write length bytes to the bus, the first byte in the array is the command/register to write
data | Buffer to send on the bus, first byte is i2c command |
length | Size of buffer to send |
|
inline |
Write a byte to an i2c register
reg | Register to write to |
data | Value to write to register |
|
inline |
Write a word to an i2c register
reg | Register to write to |
data | Value to write to register |