/* Wait until there is room in the tx fifo.  */
static status_t LPI2C_MasterWaitForTxReady(LPI2C_Type *base)
/* Wait until there is room in the tx fifo.  */
static status_t LPI2C_MasterWaitForTxReady(LPI2C_Type *base)
{
    uint32_t status;
    size_t txCount;
    size_t txFifoSize = FSL_FEATURE_LPI2C_FIFO_SIZEn(base);
    do
    {
        status_t result;
        LPI2C_MasterGetFifoCounts(base, NULL, &txCount);
        txCount = txFifoSize - txCount;
        status = LPI2C_MasterGetStatusFlags(base);
        result = LPI2C_MasterCheckAndClearError(base, status);
        if (result)
        {
            return result;
        }
    } while (!txCount);
    return kStatus_Success;
}