/* param handle The RTOS LPSPI handle. param transfer Structure specifying the transfer parameters. return status of the operation.  */
status_t LPSPI_RTOS_Transfer(lpspi_rtos_handle_t *handle, lpspi_transfer_t *transfer)
/* param handle The RTOS LPSPI handle. param transfer Structure specifying the transfer parameters. return status of the operation.  */
status_t LPSPI_RTOS_Transfer(lpspi_rtos_handle_t *handle, lpspi_transfer_t *transfer)
{
    status_t status;
    if (xSemaphoreTake(handle->mutex, portMAX_DELAY) != pdTRUE)
    {
        return kStatus_LPSPI_Busy;
    }
    status = LPSPI_MasterTransferNonBlocking(handle->base, &handle->drv_handle, transfer);
    if (status != kStatus_Success)
    {
        (void)xSemaphoreGive(handle->mutex);
        return status;
    }
    if (xSemaphoreTake(handle->event, portMAX_DELAY) != pdTRUE)
    {
        return kStatus_LPSPI_Error;
    }
    status = handle->async_status;
    (void)xSemaphoreGive(handle->mutex);
    if (status == kStatus_LPSPI_Idle)
    {
        status = kStatus_Success;
    }
    return status;
}