/* Config the SPI peripheral according to the specified parameters in the spiConfig.  */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
/* Config the SPI peripheral according to the specified parameters in the spiConfig.  */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
{
    spi->CTRL1 &= 0x3040;
    spi->CTRL1 |= (uint16_t)((uint32_t)spiConfig->direction | spiConfig->mode |
                   spiConfig->length | spiConfig->polarity |
                   spiConfig->phase | spiConfig->nss |
                   spiConfig->baudrateDiv | spiConfig->firstBit);
    spi->CRCPOLY = spiConfig->crcPolynomial;
}