The following functions are used for advanced communications on using the I2C bus. These functions are useful if the user wishes to talk to a device that does not follow the Phillips I2C standard. One example is an EEPROM that first must be addressed and then read from with no restart in between.
Data must be sent or received a byte at a time. Also user must check function returns to verify the status of the bus before performing the next option.
◆ Master_I2CRead()
This function reads a single byte in master mode from the I2C bus.
Does not handle No ACK of last byte, which needs to have a I2C_SET_NO_ACK called before the last read.
- Parameters
-
val | A pointer to a byte location to store the read value. |
ticks_to_wait | The number of system time ticks before a timeout occurs. |
- Returns
- i2cMasterReturnValues
- See also
- Master_I2CStart()
-
Master_I2CStop()
-
Master_I2CSend()
◆ Master_I2CSend()
◆ Master_I2CStart()
uint8_t Master_I2CStart |
( |
uint8_t |
addr, |
|
|
bool |
Read_Not_Write, |
|
|
uint32_t |
ticks_to_wait = I2C_START_TIMEOUT |
|
) |
| |
Start of communication with a slave device.
- Parameters
-
addr | The 7-bit address of the slave device we wish to communicate with on the bus. |
Read_Not_Write | True to read, false to write. Note: You can use I2C_START_READ or I2C_START_WRITE as values. |
ticks_to_wait | The amount of time we will wait for a start transmission to complete this time includes waiting for a busy bus to become active plus the time it takes to receive an an ACK from the slave device. |
- Returns
- i2cMasterReturnValues
- See also
- Master_I2CStop()
-
Master_I2CSend()
-
Master_I2CRead()
◆ Master_I2CStop()
Will issue a stop signal if the module has master control of the I2C bus and will release the bus if we are a slave device.
- Parameters
-
ticks_to_wait | How long to wait to ensure the bus has been released. |
- Returns
- i2cMasterReturnValues
- See also
- Master_I2CStart()
-
Master_I2CSend()
-
Master_I2CRead()