mraa
2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
An i2c context represents a master on an i2c bus and that context can communicate to multiple i2c slaves by configuring the 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.
Go to the source code of this file.
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 the i2c 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, |
mraa_i2c_mode_t | mode | ||
) |
Sets the frequency of the i2c context. Most platforms do not support this.
dev | The i2c context |
mode | The bus mode |
int mraa_i2c_read | ( | mraa_i2c_context | dev, |
uint8_t * | data, | ||
int | length | ||
) |
Simple bulk 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 |
int mraa_i2c_read_byte | ( | mraa_i2c_context | dev | ) |
Simple read for a single byte from the i2c context
dev | The i2c context |
int mraa_i2c_read_byte_data | ( | mraa_i2c_context | dev, |
const uint8_t | command | ||
) |
Read a single byte from i2c context, from designated register
dev | The i2c context |
command | The register |
int mraa_i2c_read_word_data | ( | mraa_i2c_context | dev, |
const uint8_t | command | ||
) |
Read a single word from i2c context, from designated register
dev | The i2c context |
command | The register |
int mraa_i2c_read_bytes_data | ( | mraa_i2c_context | dev, |
uint8_t | command, | ||
uint8_t * | data, | ||
int | length | ||
) |
Bulk read from i2c context, starting from designated register
dev | The i2c context |
command | The register |
data | pointer to the byte array to read data in to |
length | max number of bytes to read |
mraa_result_t mraa_i2c_write | ( | mraa_i2c_context | dev, |
const uint8_t * | data, | ||
int | length | ||
) |
Write length bytes to the bus, the first byte in the array is the command/register to write
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_write_byte_data | ( | mraa_i2c_context | dev, |
const uint8_t | data, | ||
const uint8_t | command | ||
) |
Write a single byte to an i2c context
dev | The i2c context |
data | The byte to write |
command | The register |
mraa_result_t mraa_i2c_write_word_data | ( | mraa_i2c_context | dev, |
const uint16_t | data, | ||
const uint8_t | command | ||
) |
Write a single word to an i2c context
dev | The i2c context |
data | The word to write |
command | The register |
mraa_result_t mraa_i2c_address | ( | mraa_i2c_context | dev, |
uint8_t | address | ||
) |
Sets the i2c slave address.
dev | The i2c context |
address | The address to set for the slave (7-bit 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