1.1.11.9 I2CSMBx_TransferDirGet Function

C

/* x = I2C SMBUS peripheral instance number */

/* I2C slave mode */
I2C_SLAVE_TRANSFER_DIR I2CSMBx_TransferDirGet(void)

Summary

Returns the I2C transfer direction.

Description

This function returns the I2C transfer direction.

Precondition

I2CSMBx_Initialize must have been called for the associated I2C instance.

Parameters

None.

Returns

I2C_SLAVE_TRANSFER_DIR_WRITE - I2C master is writing data to I2C slave

I2C_SLAVE_TRANSFER_DIR_READ - I2C master is reading data from I2C slave

Example

The below code snippet shows the use of the I2CSMBx_TransferDirGet API

I2C_SLAVE_TRANSFER_DIR transferDir;

bool APP_I2C_SLAVE_Callback ( I2C_SLAVE_TRANSFER_EVENT event, uintptr_t contextHandle )
{
    bool isSuccess = true;
    
    switch(event)
    {
        case I2C_SLAVE_TRANSFER_EVENT_ADDR_MATCH:
        
        transferDir = I2CSMB0_TransferDirGet();
        
        break;
        
        case I2C_SLAVE_TRANSFER_EVENT_RX_READY:
        // handle RX ready event by reading the received data
        break;
        
        case I2C_SLAVE_TRANSFER_EVENT_TX_READY:
        // handle TX ready event by writing data to I2C master
        break;
    }
}

Remarks