1.11.12.7 I2Cx_ReadByte Function

C

/* x = I2C instance number */

/* I2C slave mode */
uint8_t I2Cx_ReadByte(void)

Summary

Read the received I2C byte

Description

This function returns the I2C data byte.

Precondition

I2Cx_Initialize must have been called for the associated I2C instance.

Parameters

None.

Returns

The data byte present in the data buffer.

Example

bool APP_I2C_SLAVE_Callback ( I2C_SLAVE_TRANSFER_EVENT event, uintptr_t contextHandle )
{
    switch(event)
    {
        case I2C_SLAVE_TRANSFER_EVENT_ADDR_MATCH:
        // Handle address match event
        break;
        
        case I2C_SLAVE_TRANSFER_EVENT_RX_READY:
        
        // Read the received data byte
        rxData = I2C1_ReadByte();
        
        break;
        case I2C_SLAVE_TRANSFER_EVENT_TX_READY:
        
        // Provide data to I2C master
        I2C1_WriteByte(txData);
        
        break;
        
        case I2C_SLAVE_TRANSFER_EVENT_STOP_BIT_RECEIVED:
        // Handle stop bit received event
        break;
    }
}

Remarks

None.