1.33.16.63 SERCOMx_I2C_ReadByte Function

C

/* x = SERCOM instance number */

/* I2C slave mode */

uint8_t SERCOMx_I2C_ReadByte(void)	

Summary

Read the received I2C byte

Description

This function returns the I2C data byte.

Precondition

SERCOMx_I2C_Initialize must have been called for the associated SERCOM I2C instance

Parameters

None.

Returns

The data byte present in the data buffer

Example

bool APP_SERCOM_I2C_Callback ( SERCOM_I2C_SLAVE_TRANSFER_EVENT event, uintptr_t contextHandle )
{
    switch(event)
    {
        case SERCOM_I2C_SLAVE_TRANSFER_EVENT_ADDR_MATCH:
        // Handle address match event
        break;
        
        case SERCOM_I2C_SLAVE_TRANSFER_EVENT_RX_READY:
        
        // Read the received data byte
        rxData = SERCOM0_I2C_ReadByte();
        
        break;
        case SERCOM_I2C_SLAVE_TRANSFER_EVENT_TX_READY:
        
        // Provide data to I2C master
        SERCOM0_I2C_WriteByte(txData);
        
        break;
        
        case SERCOM_I2C_SLAVE_TRANSFER_EVENT_STOP_BIT_RECEIVED:
        // Handle stop bit received event
        break;
    }
}

Remarks

None.