DlnI2cMasterSetFrequency() Function

The DlnI2cMasterSetFrequency() function configures the clock frequency for the specified I2C port.

Syntax
C/C++
DLN_RESULT DlnI2cMasterSetFrequency(
   HDLN handle,
   uint8_t port,
   uint32_t frequency,
   uint32_t* actualFrequency
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the I2C master port.

frequency

I2C frequency value, specified in Hz. You may specify any value within the range, supported by your DLN adapter. This range can be retrieved using the respective function. If you enter an incompatible value, it will be approximated as the closest lower frequency value, supported by the adapter.

actualFrequency

A pointer to an unsigned 32-bit integer that receives the actual frequency applied by this function. The frequency is specified in Hz. If the frequency specified in frequency parameter is supported, the actual frequency will be equal to it. Otherwise, the closest lower value will be applied. If NULL is specified in this parameter, the actual frequency value will not be returned. You can still use the DlnI2cMasterGetFrequency() function to check the actual frequency.

Return Value
DLN_RES_SUCCESS (0x00)

The function set the I2C master port clock frequency value successfully.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnI2cMasterGetPortCount() function to find the maximum possible port number.

DLN_RES_BUSY (0xB6)

The function cannot change frequency while the I2C master port is busy transferring.

DLN_RES_VALUE_ROUNDED (0x21)

The function approximated the frequency value to the closest supported value.

Remarks

The DlnI2cMasterSetFrequency() function is defined in the dln_i2c_master.h file.