26.3.3.7 i2c_m_sync_cmd_write
Sync version of write command to I2C slave.
int32_t i2c_m_sync_cmd_write(
struct i2c_m_sync_desc * i2c,
uint8_t reg,
uint8_t * buffer,
uint8_t length
)
This function will write the value to a specified register in the I2C slave device and then wait for this operation to be done.
The sequence of this routine is sta->address(write)->ack->reg address->ack->resta->address(write)->ack->reg value->nack->stt
Parameters
- i2c
-
Type: struct i2c_m_sync_desc Struct *
An I2C descriptor, which is used to communicate through I2C
- reg
-
Type: uint8_t
The internal address/register of the I2C slave device
- buffer
-
Type: uint8_t *
The buffer holding data to write to the I2C slave device
- length
-
Type: uint8_t
The length (in bytes) to write to the I2C slave device
Returns
Type: int32_t
Whether successfully write to the device
- <0
-
The passed parameters were invalid or write fail
- 0
-
Writing to register is completed successfully