/* Invoke event from I2C_SlaveTransferHandleIRQ(). 
Sets the event type to transfer structure and invokes the event callback, if it has been enabled by eventMask. */
static void I2C_SlaveInvokeEvent(I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_event_t event)
/* Invoke event from I2C_SlaveTransferHandleIRQ(). 
Sets the event type to transfer structure and invokes the event callback, if it has been enabled by eventMask. */
static void I2C_SlaveInvokeEvent(I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_event_t event)
{
    handle->transfer.event = event;
    if ((handle->callback) && (handle->transfer.eventMask & event))
    {
        handle->callback(base, &handle->transfer, handle->userData);
        if (false == handle->isBusy)
        {
            if (((handle->transfer.txData) && (handle->transfer.txSize)) ||
                ((handle->transfer.rxData) && (handle->transfer.rxSize)))
            {
                handle->isBusy = true;
            }
        }
        if ((event == kI2C_SlaveReceiveEvent) || (event == kI2C_SlaveTransmitEvent))
        {
            handle->transfer.transferredCount = 0;
        }
    }
}