1.41.5.58 FLEXCOMx_TWI_TransferSetup Function

C

/* x = FLEXCOM instance number */

/* TWI master mode */

bool FLEXCOMx_TWI_TransferSetup(FLEXCOM_TWI_TRANSFER_SETUP* setup, uint32_t srcClkFreq)	

Summary

Dynamic setup of FLEXCOM TWI Peripheral

Description

This API is generally used when there are multiple clients on the same TWI bus having different TWI clock speed. In such a case, the FLEXCOMx_TWI_TransferSetup API must be called to set the appropriate TWI bus speed before starting the TWI transfer for the TWI slave.

Precondition

FLEXCOMx_TWI_Initialize must have been called for the associated FLEXCOM TWI instance. The transfer status should not be busy.

Parameters

Param Description
setup Pointer to the structure containing the transfer setup
srcClkFreq FLEXCOM TWI Peripheral Clock Source Frequency

Returns

true - Transfer setup was updated successfully.

false - Failure while updating transfer setup.

Example

FLEXCOM_TWI_TRANSFER_SETUP setup;

setup.clkSpeed = 400000;

// Make sure that the TWI is not busy before changing the TWI clock frequency
if (FLEXCOM0_TWI_TWI_IsBusy() == false)
{
    if (FLEXCOM0_TWI_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.