本节我们来进行STM32F769程序研究及分析,首先我们从官网下载最新STM32CubeF7 固件包,固件包版本为STM32Cube_FW_F7_V1.4.0 ,解压固件包打开文件下如下所示,
依次打开找到我们的演示程序GPIO,如下所示
打开工程,如下
先打开read.txt文件,看看文件对于工程的描述,
- GPIO/GPIO_EXTI/Inc/stm32f7xx_hal_conf.h HAL configuration file
- GPIO/GPIO_EXTI/Inc/stm32f7xx_it.h Interrupt handlers header file
- GPIO/GPIO_EXTI/Inc/main.h Header for main.c module
- GPIO/GPIO_EXTI/Src/stm32f7xx_it.c Interrupt handlers
- GPIO/GPIO_EXTI/Src/main.c Main program
- GPIO/GPIO_EXTI/Src/system_stm32f7xx.c STM32F7xx system source file
从而开始根据以往经验从main分析程序,
int main(void)
{
/* Enable the CPU Cache */
CPU_CACHE_Enable();//使能CPU Cache
/* STM32F7xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();//初始化HAL库
/* Configure the system clock to 216 MHz */
SystemClock_Config();//配置系统时钟为216MHz
/* -1- Initialize LED2 */
BSP_LED_Init(LED2);//初始化控制LED2的GPIO
/* -2- Configure EXTI0 (connected to PA.00 pin) in interrupt mode */
EXTI0_IRQHandler_Config();//配置PA.00接到外部中断0
/* Infinite loop */
while (1)
{
}
}
void BSP_LED_Init(Led_TypeDef Led)
{
GPIO_InitTypeDef gpio_init_structure;
LEDx_GPIO_CLK_ENABLE();//使能LED对应GPIO得时钟
/* Configure the GPIO_LED pin */
gpio_init_structure.Pin = GPIO_PIN[Led];//选择GPIO引脚
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;//GPIO模式为推挽输出
gpio_init_structure.Pull = GPIO_PULLUP;//GPIO上拉
gpio_init_structure.Speed = GPIO_SPEED_HIGH;//GPIO速度为高速
HAL_GPIO_Init(GPIO_PORT[Led], &gpio_init_structure);//初始化GPIO结构体
}
static void EXTI0_IRQHandler_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOC clock */
__HAL_RCC_GPIOA_CLK_ENABLE();//使能GPIOA时钟
/* Configure PC.13 pin as input floating */
GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING;//GPIO上升沿中断
GPIO_InitStructure.Pull = GPIO_NOPULL;//GPIO不上拉
GPIO_InitStructure.Pin = GPIO_PIN_0;//选择GPIO0
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化PA0
/* Enable and set EXTI line 0 Interrupt to the lowest priority */
HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0);设置中断向量优先级
HAL_NVIC_EnableIRQ(EXTI0_IRQn);使能外部中断
}
将程序编译下载到MCU中,按下USER按键,绿色等亮,再按下,绿色等灭。
点击此处,查看STM32F769I开发板官方资源。 本帖最后由 qwerghf 于 2016-12-17 16:14 编辑