/* Config the SPI peripheral according to the specified parameters in the adcConfig.  */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
/* Config the SPI peripheral according to the specified parameters in the adcConfig.  */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
{
    spi->CTRL1_B.MSMCFG = spiConfig->mode;
    spi->CTRL2_B.DSCFG   = spiConfig->length;
    spi->CTRL1_B.CPHA  = spiConfig->phase;
    spi->CTRL1_B.CPOL  = spiConfig->polarity;
    spi->CTRL1_B.SSEN = spiConfig->slaveSelect;
    spi->CTRL1_B.LSBSEL = spiConfig->firstBit;
    spi->CTRL1 &=(uint16_t)~0xC400;
    spi->CTRL1 |= (uint32_t)spiConfig->direction;
    spi->CTRL1_B.BRSEL = spiConfig->baudrateDiv;
    spi->CRCPOLY |= spiConfig->crcPolynomial;
}