/* 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_B.MSMCFG = spiConfig->mode;
    spi->CTRL1_B.ISSEL = spiConfig->mode;
    spi->CTRL1_B.DFLSEL = spiConfig->length;
    spi->CTRL1_B.CPHA = spiConfig->phase;
    spi->CTRL1_B.CPOL = spiConfig->polarity;
    spi->CTRL1_B.SSEN = spiConfig->nss;
    spi->CTRL1_B.LSBSEL = spiConfig->firstBit;
    spi->CTRL1_B.BMEN = spiConfig->direction & 0x0001;
    spi->CTRL1_B.BMOEN = (spiConfig->direction & 0x0010) >> 4;
    spi->CTRL1_B.RXOMEN = (spiConfig->direction & 0x0100) >> 8;
    spi->CTRL1_B.BRSEL = spiConfig->baudrateDiv;
    spi->CRCPOLY_B.CRCPOLY = spiConfig->crcPolynomial;
}