| Ucs_Return_t Ucs_I2c_WritePort | ( | Ucs_Inst_t * | self, |
| uint16_t | destination_address, | ||
| uint16_t | port_handle, | ||
| Ucs_I2c_TrMode_t | mode, | ||
| uint8_t | block_count, | ||
| uint8_t | slave_address, | ||
| uint16_t | timeout, | ||
| uint8_t | data_len, | ||
| uint8_t * | data_ptr, | ||
| Ucs_I2c_WritePortResCb_t | result_fptr | ||
| ) |
Writes a block of bytes to an I2C device at a specified I2C address.
| This function corresponds with the INIC function INIC.I2CPortWrite. |
| self | The UNICENS instance pointer | ||
| destination_address | Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device. The following address ranges are supported:
| ||
| port_handle | Port resource handle.
| ||
| mode | The write transfer mode.
| ||
| block_count | The number of blocks to be written to the I2C address. If parameter mode is not set to Burst Mode, the value of block_count has to be set to 0. Otherwise the valid range of this parameter goes from 1 to 30.
| ||
| slave_address | The 7-bit I2C slave address of the peripheral to be read.
| ||
| timeout | The timeout for the I2C Port write.
| ||
| data_len | The total number of bytes to be written to the addressed I2C peripheral. Even if parameter mode is set to Burst Mode, the data_len shall correspond to the whole size of the burst transfer. That is, the data_len shall equal the size of a block times the block_count value. | ||
| data_ptr | Reference to the data to be written. | ||
| result_fptr | Required result callback function pointer. |
| Value | Description |
|---|---|
| UCS_RET_SUCCESS | No error |
| UCS_RET_ERR_PARAM | At least one parameter is wrong |
| UCS_RET_ERR_BUFFER_OVERFLOW | No message buffer available |
| UCS_RET_ERR_API_LOCKED | API is currently locked |
| UCS_RET_ERR_NOT_INITIALIZED | UNICENS is not initialized |
Example