/* param handle The RTOS SPI handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the SPI instance to initialize. param masterConfig Configuration structure to set-up SPI in master mode. param srcClock_Hz Frequency of input clock of the SPI module. return status of the operation.  */
status_t SPI_RTOS_Init(spi_rtos_handle_t *handle, SPI_Type *base, const spi_master_config_t *masterConfig, uint32_t srcClock_Hz)
/* param handle The RTOS SPI handle, the pointer to an allocated space for RTOS context. param base The pointer base address of the SPI instance to initialize. param masterConfig Configuration structure to set-up SPI in master mode. param srcClock_Hz Frequency of input clock of the SPI module. return status of the operation.  */
status_t SPI_RTOS_Init(spi_rtos_handle_t *handle, SPI_Type *base, const spi_master_config_t *masterConfig, uint32_t srcClock_Hz)
{
    status_t status;
    if (handle == NULL)
    {
        return kStatus_InvalidArgument;
    }
    if (base == NULL)
    {
        return kStatus_InvalidArgument;
    }
    (void)memset(handle, 0, sizeof(spi_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)SPI_MasterInit(handle->base, masterConfig, srcClock_Hz);
    status = SPI_MasterTransferCreateHandle(handle->base, &handle->drv_handle, SPI_RTOS_Callback, (void *)handle);
    return status;
}