/* Deinitializes the spi peripheral registers to their default reset values.  */
void SPI_DeInit(SPI_TypeDef *spi)
/* Deinitializes the spi peripheral registers to their default reset values.  */
void SPI_DeInit(SPI_TypeDef *spi)
{
    switch (*(vu32*)&spi) {
        case (u32)SPI2:
            RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI2, ENABLE);
            RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI2, DISABLE);
            break;
        case (u32)SPI3:
            RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI3, ENABLE);
            RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI3, DISABLE);
            break;
        case (u32)SPI1:
            RCC_APB2PeriphResetCmd(RCC_APB2ENR_SPI1, ENABLE);
            RCC_APB2PeriphResetCmd(RCC_APB2ENR_SPI1, DISABLE);
            break;
        default:
            break;
    }
}