mbed library sources
Fork of mbed-src by
I2C Configuration Functions
Functions | |
void | i2c_init (i2c_t *obj, PinName sda, PinName scl) |
Initialize the I2C peripheral. | |
void | i2c_frequency (i2c_t *obj, int hz) |
Configure the I2C frequency. | |
int | i2c_start (i2c_t *obj) |
Send START command. | |
int | i2c_stop (i2c_t *obj) |
Send STOP command. | |
int | i2c_read (i2c_t *obj, int address, char *data, int length, int stop) |
Blocking reading data. | |
int | i2c_write (i2c_t *obj, int address, const char *data, int length, int stop) |
Blocking sending data. | |
void | i2c_reset (i2c_t *obj) |
Reset I2C peripheral. | |
int | i2c_byte_read (i2c_t *obj, int last) |
Read one byte. | |
int | i2c_byte_write (i2c_t *obj, int data) |
Write one byte. |
Function Documentation
int i2c_byte_read | ( | i2c_t * | obj, |
int | last | ||
) |
Read one byte.
- Parameters:
-
obj The i2c object last Acknoledge
- Returns:
- The read byte
int i2c_byte_write | ( | i2c_t * | obj, |
int | data | ||
) |
Write one byte.
- Parameters:
-
obj The i2c object data Byte to be written
- Returns:
- 1 if NAK was received, 0 if ACK was received, 2 for timeout.
void i2c_frequency | ( | i2c_t * | obj, |
int | hz | ||
) |
Configure the I2C frequency.
- Parameters:
-
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 configure its specifieds pins.
- Parameters:
-
obj The i2c object sda The sda pin scl The scl pin
int i2c_read | ( | i2c_t * | obj, |
int | address, | ||
char * | data, | ||
int | length, | ||
int | stop | ||
) |
Blocking reading data.
- Parameters:
-
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
- Returns:
- Number of read bytes
void i2c_reset | ( | i2c_t * | obj ) |
Reset I2C peripheral.
TODO: The action here. Most of the implementation sends stop().
- Parameters:
-
obj The i2c object
int i2c_start | ( | i2c_t * | obj ) |
Send START command.
- Parameters:
-
obj The i2c object
int i2c_stop | ( | i2c_t * | obj ) |
Send STOP command.
- Parameters:
-
obj The i2c object
int i2c_write | ( | i2c_t * | obj, |
int | address, | ||
const char * | data, | ||
int | length, | ||
int | stop | ||
) |
Blocking sending data.
- Parameters:
-
obj The i2c object address 7-bit address (last bit is 0) data The buffer for sending length Number of bytes to wrte stop Stop to be generated after the transfer is done
- Returns:
- Number of written bytes
Generated on Wed Jul 13 2022 01:02:35 by 1.7.2