cortex-a7核按键中断实验

key.h

#ifndef __KEY_H__
#define __KEY_H__
#include "stm32mp1xx_rcc.h"
#include "stm32mp1xx_gpio.h"
#include "stm32mp1xx_exti.h"
#include "stm32mp1xx_gic.h"
/*************KEY----PF9*************/
//初始化EXTI层
void pf9_exti_init();
//初始化GICD
void pf9_gicd_init();
//初始化GICC
void pf9_gicc_init();
#endif

 key.c

#include "key.h"
//初始化EXTI层
void pf9_exti_init()
{
	//rcc章节初始化
	//1.设置gpiof组时钟使能
	RCC->MP_AHB4ENSETR |=(0x1 <<5);
	//GPIO初始化
	//1.设置pf9引脚为输入模式
	GPIOF->MODER &=(~(0x3 << 18));
	GPIOF->MODER &=(~(0x3 << 14));
	GPIOF->MODER &=(~(0x3 << 16));
	//EXTI初始化
	//1.设置pf9引脚和EXIT9控制器连接
	EXTI->EXTICR3 &=(~(0xff << 8));
	EXTI->EXTICR3 |=(0x05 << 8);
	EXTI->EXTICR2 &=(~(0xff << 24));
	EXTI->EXTICR2 |=(0x05 << 24);
	EXTI->EXTICR3 &=(~(0xf

你可能感兴趣的:(单片机,stm32,嵌入式硬件)