void SPI_Ini
tial( void )
{
//Set as default
SPI_DeInit( );
//Set the priority of the SPI
SPI_Init();
//Config the GPIOs for SPI bus
SPI_GPIO_Init();
}
void SPI_DeInit(void)
{
SPI1_CR1 = 0x00;
SPI1_CR2 = 0x00;
SPI1_ICR = 0x00;
SPI1_SR = 0x02;
}
void SPI_Init(void)
{
SYSCFG_RMPCR1 |= 0x80; //选择复用SPI接口为PA2,PA3,PC5
SPI1_CR1 = 0x00; //先发送MSB,波特率000,SCK空闲为低,数据采样第一个时钟边沿开始
SPI1_CR2 = 0x03;
SPI1_CR1 |= 0x40; //启动SPI总线
SPI1_CRCPR = 0x07;
SPI1_CR1 |= 0x40;
}
void SPI_GPIO_Init(void)
{
PA_DDR |= ~(1<