Jump to main content

##

# 2.56.15 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