1.27.25.2 1.34.25.2 1.35.18.2 TWIHSx_WriteByte Function

C

/* x = TWIHS instance number */

/* TWIHS slave mode */
void TWIHSx_WriteByte(uint8_t wrByte)

Summary

Write a data byte to TWI master

Description

This function writes a data byte to be sent to the TWIHS master

Precondition

TWIHSx_Initialize must have been called for the associated TWIHS instance.

Parameters

Param Description
wrByte Data byte to be written.

Returns

None

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