Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
| 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:
- 0 if NAK was received, 1 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 configures 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 write stop Stop to be generated after the transfer is done 
- Returns:
- Number of written bytes
Generated on Tue Jul 12 2022 17:35:07 by
 1.7.2
 1.7.2