Functions | |
void | i2c_init (i2c_t *obj, PinName sda, PinName scl) |
Initialize the I2C peripheral. More... | |
void | i2c_frequency (i2c_t *obj, int hz) |
Configure the I2C frequency. More... | |
int | i2c_start (i2c_t *obj) |
Send START command. More... | |
int | i2c_stop (i2c_t *obj) |
Send STOP command. More... | |
int | i2c_read (i2c_t *obj, int address, char *data, int length, int stop) |
Blocking reading data. More... | |
int | i2c_write (i2c_t *obj, int address, const char *data, int length, int stop) |
Blocking sending data. More... | |
void | i2c_reset (i2c_t *obj) |
Reset I2C peripheral. More... | |
int | i2c_byte_read (i2c_t *obj, int last) |
Read one byte. More... | |
int | i2c_byte_write (i2c_t *obj, int data) |
Write one byte. More... | |
const PinMap * | i2c_master_sda_pinmap (void) |
Get the pins that support I2C SDA. More... | |
const PinMap * | i2c_master_scl_pinmap (void) |
Get the pins that support I2C SCL. More... | |
const PinMap * | i2c_slave_sda_pinmap (void) |
Get the pins that support I2C SDA. More... | |
const PinMap * | i2c_slave_scl_pinmap (void) |
Get the pins that support I2C SCL. More... | |
int i2c_byte_read | ( | i2c_t * | obj, |
int | last | ||
) |
Read one byte.
obj | The I2C object |
last | Acknoledge |
int i2c_byte_write | ( | i2c_t * | obj, |
int | data | ||
) |
Write one byte.
obj | The I2C object |
data | Byte to be written |
void i2c_frequency | ( | i2c_t * | obj, |
int | hz | ||
) |
Configure the I2C frequency.
obj | The I2C object |
hz | Frequency in Hz |
void i2c_init | ( | i2c_t * | obj, |
PinName | sda, | ||
PinName | scl | ||
) |
Initialize the I2C peripheral.
It sets the default parameters for I2C peripheral, and configures its specifieds pins.
obj | The I2C object |
sda | The sda pin |
scl | The scl pin |
const PinMap* i2c_master_scl_pinmap | ( | void | ) |
const PinMap* i2c_master_sda_pinmap | ( | void | ) |
int i2c_read | ( | i2c_t * | obj, |
int | address, | ||
char * | data, | ||
int | length, | ||
int | stop | ||
) |
Blocking reading data.
obj | The I2C object |
address | 7-bit address (last bit is 1) |
data | The buffer for receiving |
length | Number of bytes to read |
stop | Stop to be generated after the transfer is done |
void i2c_reset | ( | i2c_t * | obj | ) |
Reset I2C peripheral.
TODO: The action here. Most of the implementation sends stop()
obj | The I2C object |
const PinMap* i2c_slave_scl_pinmap | ( | void | ) |
const PinMap* i2c_slave_sda_pinmap | ( | void | ) |
int i2c_start | ( | i2c_t * | obj | ) |
Send START command.
obj | The I2C object |
int i2c_stop | ( | i2c_t * | obj | ) |
Send STOP command.
obj | The I2C object |
int i2c_write | ( | i2c_t * | obj, |
int | address, | ||
const char * | data, | ||
int | length, | ||
int | stop | ||
) |
Blocking sending data.
obj | The I2C object |
address | 7-bit address (last bit is 0) |
data | The buffer for sending |
length | Number of bytes to write |
stop | Stop to be generated after the transfer is done |