/* param handle The RTOS LPSPI handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the LPSPI instance to initialize. param masterConfig Configuration structure to set-up LPSPI in master mode. param srcClock_Hz Frequency of input clock of the LPSPI module. return status of the operation.  */
status_t LPSPI_RTOS_Init(lpspi_rtos_handle_t *handle, LPSPI_Type *base, const lpspi_master_config_t *masterConfig, uint32_t srcClock_Hz)
/* param handle The RTOS LPSPI handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the LPSPI instance to initialize. param masterConfig Configuration structure to set-up LPSPI in master mode. param srcClock_Hz Frequency of input clock of the LPSPI module. return status of the operation.  */
status_t LPSPI_RTOS_Init(lpspi_rtos_handle_t *handle, LPSPI_Type *base, const lpspi_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(lpspi_rtos_handle_t));
    handle->mutex = xSemaphoreCreateMutex();
    if (handle->mutex == NULL)
    {
        return kStatus_Fail;
    }
    handle->event = xSemaphoreCreateBinary();
    if (handle->event == NULL)
    {
        vSemaphoreDelete(handle->mutex);
        return kStatus_Fail;
    }
    handle->base = base;
    (void)LPSPI_MasterInit(handle->base, masterConfig, srcClock_Hz);
    LPSPI_MasterTransferCreateHandle(handle->base, &handle->drv_handle, LPSPI_RTOS_Callback, (void *)handle);
    return kStatus_Success;
}