本人小白一枚,刚接触STM32,战舰开发板SPI实验中FLASH I/O口初始化代码里面 PD2和PG7这两个的推挽设置,没看明白,看硬件原理图,FLASH部分和这两个引脚没有连接啊(如下所示),求大神解释。
//初始化SPI FLASH的IO口
void SPI_Flash_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG, ENABLE );//PORTB时钟使能
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; // PB12 推挽
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_12);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; // PD2 推挽
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD,GPIO_Pin_2);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; // PG7 推挽
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_SetBits(GPIOG,GPIO_Pin_7);
SPI2_Init(); //初始化SPI
SPI2_SetSpeed(SPI_BaudRatePrescaler_2);//设置为18M时钟,高速模式
SPI_FLASH_TYPE=SPI_Flash_ReadID();//读取FLASH ID.
}
|