1.11.12.9 1.12.12.9 1.13.11.9 1.15.11.9 1.16.9.9 1.17.9.9 1.18.10.9 1.19.9.9 1.20.9.9 1.21.10.9 1.22.14.9 1.23.13.9 1.24.11.9 I2Cx_LastByteAckStatusGet Function

C

/* x = I2C instance number */

/* I2C slave mode */
I2C_SLAVE_ACK_STATUS I2Cx_LastByteAckStatusGet(void)

Summary

Returns the ACK status of the last byte written to the I2C master.

Description

This function returns the ACK status of the last byte written to the I2C master.

Precondition

I2Cx_Initialize must have been called for the associated I2C instance.

Parameters

None.

Returns

I2C_SLAVE_ACK_STATUS_RECEIVED_ACK - I2C master acknowledged the last byte

I2C_SLAVE_ACK_STATUS_RECEIVED_NAK - I2C master sent NAK

Example

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:
        if (I2C1_LastByteAckStatusGet() == I2C_SLAVE_ACK_STATUS_RECEIVED_ACK)
        {
            // Last byte is ACK'd by I2C master. Continue writing more data.
            I2C1_WriteByte(data);
        }
        else
        {
            // Last byte is NAK'd by I2C master. Transfer complete.
        }
        break;
    }
}

Remarks

None