Logo
UNICENS V2.3.0-4567
User Manual and API Reference
Ucs_Return_t Ucs_I2c_WritePort ( Ucs_Inst_t self,
uint16_t  node_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.
Parameters
selfThe UNICENS instance pointer
node_addressAddress of the target device. Use the UCS_ADDR_LOCAL_NODE macro to target the local device.
The following address ranges are supported:
  • [0x10 ... 0x2FF]
  • [0x500 ... 0xFEF]
  • UCS_ADDR_LOCAL_NODE
port_handlePort resource handle.
 I2CPortHandle
modeThe write transfer mode.
 Mode
block_countThe 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.
 BlockCount
slave_addressThe 7-bit I2C slave address of the peripheral to be read.
 SlaveAddress
timeoutThe timeout for the I2C Port write.
 Timeout
data_lenThe 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. The maximum length of data is limited to 32 bytes.
data_ptrReference to the data to be written.
result_fptrRequired result callback function pointer.
Returns
Possible return values are shown in the table below.
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 is available.
UCS_RET_ERR_API_LOCKED API is currently locked.
UCS_RET_ERR_NOT_SUPPORTED API is not supported in the current Network Supervisor Mode.
UCS_RET_ERR_NOT_INITIALIZED UNICENS is not initialized.
 See also section Example for Ucs_I2c_WritePort for an example implementation.