M2M_T_HW_I2C_RESULT m2m_hw_i2c_read(UINT16 address, UINT8 reg_addr, UINT8 *
buffer, UINT8 len)
Description: the function reads data from an I2C device.
Parameters:
address: address of the I2C device, with the LSB used as read\write command. It does not
matter if the LSB is set to 0 or to 1. 10 bits address is supported
reg_addr: register address where the first byte is read
buffer: pointer to the buffer that will be filled with the data read from I2C device (in
hexadecimal format)
len: number of bytes to read, see M2M_HW_I2C_MAX_BUF_LEN.
Return
value:
refer to
M2M_T_HW_I2C_RESULT enum
Output
data:
on success:
"buffer" points to the buffer filled with the data read from the I2C
device.
Example of "address" parameter format:
Suppose that the I2C device has the address 7 bits long, for example: 0x0F. The I2C device address must be shifted to left by one bit as shown below. It is up to the function to set the bit 0 in accordance with the command.
|
I2C device address |
Writing command | ||||||
"address" parameter |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
x |
bits |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |