要求按key1键led1灯亮,再按一次灭
按key2键led2灯亮,再按一次灭
按key3键led3灯亮,再按一次灭
main.c
#include "key.h"
#include "led.h"
int main()
{
key_gpio_rcc_init();
//KEY1初始化
hal_exit_init(EXTI9_INPUT_EVENT, CPIOGROUP, Falling);//1表示是下降沿 触发
hal_gic_init(KEY1_SWI_ID,IPR_EXIT9);
//KEY2初始化
hal_exit_init(EXTI7_INPUT_EVENT, CPIOGROUP, Falling);//1表示是下降沿 触发
hal_gic_init(KEY2_SWI_ID, IPR_EXIT7);
//KEY3初始化
hal_exit_init(EXTI8_INPUT_EVENT, CPIOGROUP, Falling);//1表示是下降沿 触发
hal_gic_init(KEY3_SWI_ID, IPR_EXIT8);
//led灯初始化
all_led_init();
while (1)
{
//当按键按下之后,触发irq异常源
//执行中断处理函数
}
return 0;
}
key.c
#include "key.h"
///KEY1--->PF9
//RCC/GPIO/EXTI章节初始化
void key_gpio_rcc_init()
{
//RCC章节初始化
//KEY1------>PF9
//KEY2------>PF7
//KEY3------>PF8
//1.设置GPIOF组使能 MP_AHB4ENSETR[5] = 1
RCC->MP_AHB4ENSETR |= (0x1 << 5);
//GPIO章节初始化
//1.设置PF9,PF7,PF8引脚为输入模式 MOD