key.h
#ifndef __KEY1_H__
#define __KEY1_H__
#include "stm32mp1xx_gpio.h"
#include "stm32mp1xx_rcc.h"
#include "stm32mp1xx_exti.h"
#include "stm32mp1xx_gic.h"
//初始化
void key_init();
void key1_hang();
void key2_hang();
void key3_hang();
#endif
key.c
#include "key1.h"
//初始化
void key_init()
{
/*****GPIO章节初始化******/
//GPIOF时钟使能
RCC->MP_AHB4ENSETR |= (0x1 << 5);
//GPIOx_MODER寄存器功能:设置PF7,8,9引脚为输入模式
GPIOF->MODER &= ~(0x3 << 14);
GPIOF->MODER &= ~(0x3 << 16);
GPIOF->MODER &= ~(0x3 << 18);
/*****EXITI章节初始化******/
//EXTI_EXTICR寄存器控制GPIO组控制器和EXTI控制器进行连接
EXTI->EXTICR3 &= ~(0xff << 8);
EXTI->EXTICR3 |= (0x05 << 8);
EXTI->EXTICR2 &= ~(0xff << 24);
EXTI->EXTICR2 |= (0x05 << 24);
EXTI->EXT