1.11.12.6 1.12.12.6 1.13.11.6 1.15.11.6 1.16.9.6 1.17.9.6 1.18.10.6 1.19.9.6 1.20.9.6 1.21.10.6 1.22.14.6 1.23.13.6 1.24.11.6 I2Cx_TransferDirGet Function

C

/* x = I2C instance number */

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

Summary

Returns the I2C transfer direction.

Description

This function returns the I2C transfer direction.

Precondition

I2Cx_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 I2Cx_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 = I2C1_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

None.