This file defines the I2c interface for libmraa
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
rx_tx_buf[1] = GA_1_3_REG;
i2c->
write(rx_tx_buf, 2);
I2c |
( |
int |
bus, |
|
|
bool |
raw = false |
|
) |
| |
|
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.
- Parameters
-
bus | The i2c bus to use |
raw | Whether to disable pinmapper for your board |
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.
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
- Parameters
-
hz | Frequency to set the bus to in hz |
- Returns
- Result of operation
Set the slave to talk to, typically called before every read/write operation
- Parameters
-
address | Communicate to the i2c slave on this address |
- Returns
- Result of operation
Read exactly one byte from the bus
- Returns
- char read from the bus
int read |
( |
char * |
data, |
|
|
size_t |
length |
|
) |
| |
|
inline |
Read mutliple bytes from the bus
- Parameters
-
data | Buffer to write into |
length | Size of read |
- Returns
- length of the read or 0 if failed
std::string read |
( |
size_t |
length | ) |
|
|
inline |
Read length bytes from the bus, and return as a std::string note that this is not a null terminated string
- Parameters
-
length | Size of read to make |
- Returns
- pointer to std::string
Write one byte to the bus
- Parameters
-
data | Buffer to send on the bus |
length | Size of buffer to send |
- Returns
- Result of operation
Write to an i2c register
- Parameters
-
reg | Register to write to |
data | Value to write to register |
- Returns
- Result of operation
Write multiple bytes to the bus
- Parameters
-
data | The byte to send on the bus |
- Returns
- Result of operation
The documentation for this class was generated from the following file:
- /var/lib/jenkins/workspace/mraa-doc/api/mraa/i2c.hpp