RCC和GPIO初始化函数:
EXTI初始化函数:通用的函数,对KEY1/KEY2/KEY3进行使用
void hal_exti_init(事件编号,GPIOF组对应编号,触发方式)
GIC层初始化函数:通用的函数,对KEY1/KEY2/KEY3进行使用
void hal__GIC_init(中断id,优先级)
实验现象:
当按键1按下之后,1)打印一句话,并且需要打印出中断号 2)LED1灯的状态进行取反
当按键2按下之后,1)打印一句话,并且需要打印出中断号2)LED2灯的状态进行取反
当按键3按下之后,1)打印一句话,并且需要打印出中断号 2)LED3灯的状态进行取反
key.h
#ifndef __UART4_H__
#define __UART4_H__
#include "stm32mp1xx_rcc.h"
#include "stm32mp1xx_gpio.h"
#include "stm32mp1xx_exti.h"
#include "stm32mp1xx_gic.h"
void led_init();
void exti_init(unsigned int interrupt,unsigned int GPID ,unsigned int m);
void gic_init(unsigned int interrupt,unsigned int n);
#endif
key.c
#include "key.h"
extern void delay_ms(int ms);
void led_init()
{
//LED1 PE10
//LED2 PF10
//LED3 PE8
//使能GPIOE 和 GPIOF
RCC->MP_AHB4ENSETR |= (0x3 << 4);
//GPIOE初始化
//PE10 LED1
GPIOE->MODER &=(~(0x3<<20));
GPIOE->MODER |= (0x1<<20);
GPIOE->OTYPER &= (~(0x1 << 10));
GPIOE->OSPEEDR &= (~(0x3 << 20));
GPIOE->PUPDR &= (~(0x3 << 20));
//PF10 LED2
GPIOF->MODER &=(~(0x3<<20));
GPIOF->MODER |= (0x1<<20);
GPIOF->OTYPER &= (~(0x1 << 10));
GPIOF->OSPEEDR &= (~(0x3 << 20)