/* param handle The RTOS LPI2C handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the LPI2C instance to initialize. param masterConfig Configuration structure to set-up LPI2C in master mode. param srcClock_Hz Frequency of input clock of the LPI2C module. return status of the operation.  */
status_t LPI2C_RTOS_Init(lpi2c_rtos_handle_t *handle, LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t srcClock_Hz)
/* param handle The RTOS LPI2C handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the LPI2C instance to initialize. param masterConfig Configuration structure to set-up LPI2C in master mode. param srcClock_Hz Frequency of input clock of the LPI2C module. return status of the operation.  */
status_t LPI2C_RTOS_Init(lpi2c_rtos_handle_t *handle, LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t srcClock_Hz)
{
    if (handle == NULL)
    {
        return kStatus_InvalidArgument;
    }
    if (base == NULL)
    {
        return kStatus_InvalidArgument;
    }
    (void)memset(handle, 0, sizeof(lpi2c_rtos_handle_t));
    handle->mutex = xSemaphoreCreateMutex();
    if (handle->mutex == NULL)
    {
        return kStatus_Fail;
    }
    handle->semaphore = xSemaphoreCreateBinary();
    if (handle->semaphore == NULL)
    {
        vSemaphoreDelete(handle->mutex);
        return kStatus_Fail;
    }
    handle->base = base;
    LPI2C_MasterInit(handle->base, masterConfig, srcClock_Hz);
    LPI2C_MasterTransferCreateHandle(base, &handle->drv_handle, LPI2C_RTOS_Callback, (void *)handle);
    return kStatus_Success;
}