1.11.12.5 1.12.12.5 1.13.11.5 1.15.11.5 1.16.9.5 1.17.9.5 1.18.10.5 1.19.9.5 1.20.9.5 1.21.10.5 1.22.14.5 1.23.13.5 1.24.11.5 I2Cx_TransferSetup Function
C
/* x = I2C instance number */
/* I2C master mode */
bool I2Cx_TransferSetup(I2C_TRANSFER_SETUP* setup, uint32_t srcClkFreq)
Summary
Dynamic setup of I2C Peripheral.
Description
This API is generally used when there are multiple clients on the same I2C bus having different I2C clock speed. In such a case, the I2Cx_TransferSetup API must be called to set the appropriate I2C bus speed before starting the I2C transfer for the I2C slave.
Precondition
I2Cx_Initialize must have been called for the associated I2C instance. The transfer status should not be busy.
Parameters
Param | Description |
---|---|
setup | Pointer to the structure containing the transfer setup. |
srcClkFreq | I2C Peripheral Clock Source Frequency. |
Returns
true - Transfer setup was updated Successfully.
false - Failure while updating transfer setup.
Example
I2C_TRANSFER_SETUP setup; setup.clkSpeed = 400000; // Make sure that the I2C is not busy before changing the I2C clock frequency if (I2Cx_IsBusy() == false) { if (I2Cx_TransferSetup( &setup, 0 ) == true) { // Transfer Setup updated successfully } }
Remarks
srcClkFreq overrides any change in the peripheral clock frequency. If configured to zero PLIB takes the peripheral clock frequency from MHC.