Interface: tos.interfaces.I2CPacket
interface I2CPacket<typedef addr_size>
- Author:
-
Phil Buonadonna
-
Philip Levis
Commands
command error_t read(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t *data)
command error_t write(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t *data)
Events
event void readDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data)
event void writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data)
Commands - Details
read
command error_t read(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t *data)
- Parameters:
-
flags - Flags that may be logical ORed and defined by:
I2C_START - The START condition is transmitted at the beginning
of the packet if set.
I2C_STOP - The STOP condition is transmitted at the end of the
packet if set.
I2C_ACK_END - ACK the last byte if set. Otherwise NACK last byte. This
flag cannot be used with the I2C_STOP flag.
-
addr - The slave device address. Only used if I2C_START is set.
-
length - Length, in bytes, to be read
-
'uint8_t* COUNT(length) data' A point to a data buffer to read into
- Returns:
-
SUCCESS if bus available and request accepted.
write
command error_t write(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t *data)
- Parameters:
-
flags - Flags that may be logical ORed and defined by:
I2C_START - The START condition is transmitted at the beginning
of the packet if set.
I2C_STOP - The STOP condition is transmitted at the end of the
packet if set.
-
addr - The slave device address. Only used if I2C_START is set.
-
length - Length, in bytes, to be read
-
'uint8_t* COUNT(length) data' A point to a data buffer to read into
- Returns:
-
SUCCESS if bus available and request accepted.
Events - Details
readDone
event void readDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data)
- Parameters:
-
addr - The slave device address
-
length - Length, in bytes, read
-
'uint8_t* COUNT(length) data' Pointer to the received data buffer
-
success - SUCCESS if transfer completed without error.
writeDone
event void writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t *data)
- Parameters:
-
addr - The slave device address
-
length - Length, in bytes, written
-
'uint8_t* COUNT(length) data' Pointer to the data buffer written
-
success - SUCCESS if transfer completed without error.