/* param handle The RTOS I2C handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the I2C instance to initialize. param masterConfig Configuration structure to set-up I2C in master mode. param srcClock_Hz Frequency of input clock of the I2C module. return status of the operation.  */
status_t I2C_RTOS_Init(i2c_rtos_handle_t *handle, I2C_Type *base, const i2c_master_config_t *masterConfig, uint32_t srcClock_Hz)
/* param handle The RTOS I2C handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the I2C instance to initialize. param masterConfig Configuration structure to set-up I2C in master mode. param srcClock_Hz Frequency of input clock of the I2C module. return status of the operation.  */
status_t I2C_RTOS_Init(i2c_rtos_handle_t *handle, I2C_Type *base, const i2c_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(i2c_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;
    I2C_MasterInit(handle->base, masterConfig, srcClock_Hz);
    I2C_MasterTransferCreateHandle(base, &handle->drv_handle, I2C_RTOS_Callback, (void *)handle);
    return kStatus_Success;
}