/* retval #kStatus_Success Slave transfers were successfully started. retval #kStatus_LPI2C_Busy Slave transfers have already been started on this handle.  */
status_t LPI2C_SlaveTransferNonBlocking(LPI2C_Type *base, lpi2c_slave_handle_t *handle, uint32_t eventMask)
/* retval #kStatus_Success Slave transfers were successfully started. retval #kStatus_LPI2C_Busy Slave transfers have already been started on this handle.  */
status_t LPI2C_SlaveTransferNonBlocking(LPI2C_Type *base, lpi2c_slave_handle_t *handle, uint32_t eventMask)
{
    uint32_t status;
    assert(handle);
    if (handle->isBusy)
    {
        return kStatus_LPI2C_Busy;
    }
    status = LPI2C_SlaveGetStatusFlags(base);
    if ((status & kLPI2C_SlaveBusBusyFlag) && (!(status & kLPI2C_SlaveBusyFlag)))
    {
        return kStatus_LPI2C_Busy;
    }
    LPI2C_SlaveDisableInterrupts(base, kSlaveIrqFlags);
    memset(&handle->transfer, 0, sizeof(handle->transfer));
    handle->isBusy = true;
    handle->eventMask = eventMask | kLPI2C_SlaveTransmitEvent | kLPI2C_SlaveReceiveEvent;
    base->STAR = 0;
    LPI2C_SlaveClearStatusFlags(base, kSlaveClearFlags);
    LPI2C_SlaveEnableInterrupts(base, kSlaveIrqFlags);
    return kStatus_Success;
}