Jump to main content

##

# 2.112.7 I2CSMBx_TransferSetup Function

## C

    /* x = I2C SMBUS peripheral instance number */

    /* I2C master mode */
    bool I2CSMBx_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 I2CSMBx_TransferSetup API must be called to set the appropriate I2C bus speed before starting the I2C transfer for the I2C slave.

## Precondition

I2CSMBx_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 (I2CSMB0_IsBusy() == false)
    {
        if (I2CSMB0_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 MCC.