1.34.25.7 TWIHSx_ReadByte Function

C

/* x = TWIHS instance number */

/* TWIHS slave mode */
uint8_t TWIHSx_ReadByte(void)

Summary

Read the received TWIHS byte

Description

This function returns the TWIHS data byte.

Precondition

TWIHSx_Initialize must have been called for the associated TWIHS instance.

Parameters

None.

Returns

The data byte present in the data buffer.

Example

void APP_TWIHS_Callback ( TWIHS_SLAVE_TRANSFER_EVENT event, uintptr_t contextHandle )
{
    switch(event)
    {
        case TWIHS_SLAVE_TRANSFER_EVENT_ADDR_MATCH:
        // Handle address match event
        break;
        
        case TWIHS_SLAVE_TRANSFER_EVENT_RX_READY:
        
        // Read the received data byte
        rxData = TWIHS1_ReadByte();
        
        break;
        case TWIHS_SLAVE_TRANSFER_EVENT_TX_READY:
        
        // Provide data to TWI master
        TWIHS1_WriteByte(txData);
        
        break;
        
        case TWIHS_SLAVE_TRANSFER_EVENT_TRANSMISSION_COMPLETE:
        // Handle stop bit received event
        break;
    }
}

Remarks

None.