1.34.25.4 TWIHSx_TransferSetup Function
C
/* x = TWIHS instance number */
/* TWIHS master mode */
bool TWIHSx_TransferSetup(TWIHS_TRANSFER_SETUP* setup, uint32_t srcClkFreq)
Summary
Dynamic setup of TWIHS Peripheral.
Description
This API is generally used when there are multiple clients on the same TWIHS bus having different clock speed. In such a case, the TWIHSx_TransferSetup API must be called to set the appropriate bus speed before starting the transfer for the I2C slave.
Precondition
TWIHSx_Initialize must have been called for the associated TWIHS instance. The transfer status should not be busy.
Parameters
Param | Description |
---|---|
setup | Pointer to the structure containing the transfer setup. |
srcClkFreq | TWIHS Peripheral Clock Source Frequency. |
Returns
true - Transfer setup was updated Successfully.
false - Failure while updating transfer setup.
Example
TWIHS_TRANSFER_SETUP setup; setup.clkSpeed = 400000; // Make sure that the TWIHS is not busy before changing the TWIHS clock frequency if (TWIHS1_IsBusy() == false) { if (TWIHS1_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.