Interface: moteiv.tos.platform.msp430.MSP430I2CPacket

interface MSP430I2CPacket

MSP430I2CPacket provides commands for reading and writing a series of bytes across an I2C interface.

You must acquire a handle for the I2C interface before using it, otherwise your operations will fail. Use the I2CResourceC generic component to request the resource when it is needed.

Author:
Joe Polastre, Moteiv Corporation <info@moteiv.com>

Commands
command result_t readPacket(uint8_t rh, uint16_t addr, uint8_t length, uint8_t *data) Read a packet from the device at address addr on the I2C bus.
command result_t writePacket(uint8_t rh, uint16_t addr, uint8_t length, uint8_t *data) Write a packet to a device at address addr on the I2C bus.

Events
event void readPacketDone(uint16_t addr, uint8_t length, uint8_t *data, result_t success) Notification that the read operation has completed.
event void writePacketDone(uint16_t addr, uint8_t length, uint8_t *data, result_t success) Notification that the write operation has completed.

Commands - Details

readPacket

command result_t readPacket(uint8_t rh, uint16_t addr, uint8_t length, uint8_t *data)

Read a packet from the device at address addr on the I2C bus.

Parameters:
rh - Resource handle for the I2C bus is required before use.
addr - Address of the slave I2C device.
length - Number of bytes to read from the device.
data - Pointer to the location where data should be stored.
Returns:
SUCCESS if the operation has successfully started.

writePacket

command result_t writePacket(uint8_t rh, uint16_t addr, uint8_t length, uint8_t *data)

Write a packet to a device at address addr on the I2C bus.

Parameters:
rh - Resource handle for the I2C bus is required before use.
addr - Address of the slave I2C device.
length - Number of bytes to write to the device.
data - Pointer to the location of data to send.
Returns:
SUCCESS if the operation has successfully started.

Events - Details

readPacketDone

event void readPacketDone(uint16_t addr, uint8_t length, uint8_t *data, result_t success)

Notification that the read operation has completed. Check the result value to see if it was successful.

Parameters:
addr - Address of the slave I2C device.
length - Number of bytes to write to the device.
data - Pointer to the location where data should be stored.
success - Result of the operation.

writePacketDone

event void writePacketDone(uint16_t addr, uint8_t length, uint8_t *data, result_t success)

Notification that the write operation has completed. Check the result value to see if it was successful.

Parameters:
addr - Address of the slave I2C device.
length - Number of bytes to write to the device.
data - Pointer to the location of data to send.
success - Result of the operation.