void SPI1_init(void) //SPI1口初始化
{
GPIO_InitTypeDef GPIO_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); //使能GPIOA时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); //使能SPI1时钟
//Configure SPI1 pins: SCK, MISO and MOSI
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; //管脚SPI复用 (<STM32F4为>PA5:SPI1_SCK,PA6:SPI1_MISO,PA7:SPI1_MOSI)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //复用
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //推挽输出
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //上拉
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); //配置到管脚
GPIO_PinAFConfig(GPIOA,5,GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA,6,GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA,7,GPIO_AF_SPI1);
//SPI模块配置
SPI_