/* param handle The RTOS LPI2C handle. param transfer Structure specifying the transfer parameters. return status of the operation.  */
status_t LPI2C_RTOS_Transfer(lpi2c_rtos_handle_t *handle, lpi2c_master_transfer_t *transfer)
/* param handle The RTOS LPI2C handle. param transfer Structure specifying the transfer parameters. return status of the operation.  */
status_t LPI2C_RTOS_Transfer(lpi2c_rtos_handle_t *handle, lpi2c_master_transfer_t *transfer)
{
    status_t status;
    if (xSemaphoreTake(handle->mutex, portMAX_DELAY) != pdTRUE)
    {
        return kStatus_LPI2C_Busy;
    }
    status = LPI2C_MasterTransferNonBlocking(handle->base, &handle->drv_handle, transfer);
    if (status != kStatus_Success)
    {
        (void)xSemaphoreGive(handle->mutex);
        return status;
    }
    (void)xSemaphoreTake(handle->semaphore, portMAX_DELAY);
    (void)xSemaphoreGive(handle->mutex);
    return handle->async_status;
}