mraa
0.4.5
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
This file defines the i2c/Iic interface for libmraa. A context represents a bus and that bus may contain multiple addresses or i2c slaves. 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.
Go to the source code of this file.
Functions | |
mraa_i2c_context | mraa_i2c_init (int bus) |
mraa_i2c_context | mraa_i2c_init_raw (unsigned int bus) |
mraa_result_t | mraa_i2c_frequency (mraa_i2c_context dev, int hz) |
int | mraa_i2c_read (mraa_i2c_context dev, uint8_t *data, int length) |
uint8_t | mraa_i2c_read_byte (mraa_i2c_context dev) |
mraa_result_t | mraa_i2c_write (mraa_i2c_context dev, const uint8_t *data, int length) |
mraa_result_t | mraa_i2c_write_byte (mraa_i2c_context dev, const uint8_t data) |
mraa_result_t | mraa_i2c_address (mraa_i2c_context dev, int address) |
mraa_result_t | mraa_i2c_stop (mraa_i2c_context dev) |
Typedefs | |
typedef struct _i2c * | mraa_i2c_context |
mraa_i2c_context mraa_i2c_init | ( | int | bus | ) |
Initialise i2c context, using board defintions
bus | i2c bus to use |
mraa_i2c_context mraa_i2c_init_raw | ( | unsigned int | bus | ) |
Initialise i2c context, passing in spi bus to use.
bus | The i2c bus to use i.e. /dev/i2c-2 would be "2" |
mraa_result_t mraa_i2c_frequency | ( | mraa_i2c_context | dev, |
int | hz | ||
) |
Sets the frequency of the i2c context
dev | The i2c context |
hz | The bus frequency in hertz |
int mraa_i2c_read | ( | mraa_i2c_context | dev, |
uint8_t * | data, | ||
int | length | ||
) |
Read from an i2c context
dev | The i2c context |
data | pointer to the byte array to read data in to |
length | max number of bytes to read |
uint8_t mraa_i2c_read_byte | ( | mraa_i2c_context | dev | ) |
Read a single byte from the i2c context
dev | The i2c context |
mraa_result_t mraa_i2c_write | ( | mraa_i2c_context | dev, |
const uint8_t * | data, | ||
int | length | ||
) |
Write to an i2c context
dev | The i2c context |
data | pointer to the byte array to be written |
length | the number of bytes to transmit |
mraa_result_t mraa_i2c_write_byte | ( | mraa_i2c_context | dev, |
const uint8_t | data | ||
) |
Write a single byte to an i2c context
dev | The i2c context |
data | The byte to write |
mraa_result_t mraa_i2c_address | ( | mraa_i2c_context | dev, |
int | address | ||
) |
Sets the i2c context address.
dev | The i2c context |
address | The address to set for the slave (ignoring the least signifcant bit). If set to 0, the slave will only respond to the general call address. |
mraa_result_t mraa_i2c_stop | ( | mraa_i2c_context | dev | ) |
De-inits an mraa_i2c_context device
dev | The i2c context |
typedef struct _i2c* mraa_i2c_context |
Opaque pointer definition to the internal struct _i2c