/* This function make SPI module be ready to transfer.  */
uint32_t SPI_Open(SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock)
/* This function make SPI module be ready to transfer.  */
uint32_t SPI_Open(SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock)
{
    uint32_t u32RetValue = 0U;
    if (u32DataWidth == 32U)
    {
        u32DataWidth = 0U;
    }
    if (u32MasterSlave == SPI_MASTER)
    {
        spi->SSCTL = SPI_SS_ACTIVE_LOW;
        spi->CTL = u32MasterSlave | (u32DataWidth << SPI_CTL_DWIDTH_Pos) | (u32SPIMode) | SPI_CTL_SPIEN_Msk;
        spi->CLKDIV = (150000000U / u32BusClock) - 1U;
    }
    else
    {
        spi->SSCTL = SPI_SS_ACTIVE_LOW;
        spi->CTL = u32MasterSlave | (u32DataWidth << SPI_CTL_DWIDTH_Pos) | (u32SPIMode) | SPI_CTL_SPIEN_Msk;
        spi->CLKDIV = 1U;
    }
    return u32RetValue;
}