代码
# include "stm32mp1xx_gic.h"
# include "stm32mp1xx_exti.h"
extern void printf ( const char * fmt, . . . ) ;
unsigned int i = 0 ;
void do_irq ( void )
{ unsigned int irqno= GICC-> IAR& 0x3ff ; switch ( irqno) { case 99 : printf ( "key1_intc\n" ) ; GICD-> ICPENDR[ 3 ] |= ( 0X1 << 3 ) ; EXTI-> FPR1 |= ( 0X1 << 9 ) ; break ; case 97 : printf ( "key2_intc\n" ) ; GICD-> ICPENDR[ 3 ] |= ( 0X1 << 1 ) ; EXTI-> FPR1 |= ( 0X1 << 7 ) ; break ; case 98 : printf ( "key3_intc\n" ) ; GICD-> ICPENDR[ 3 ] |= ( 0X1 << 2 ) ; EXTI-> FPR1 |= ( 0X1 << 8 ) ; break ; default : break ; } GICC-> EOIR |= irqno;
}
# include "key_inc.h" void key1_it_config ( ) { RCC-> MP_AHB4ENSETR |= ( 0x1 << 5 ) ; GPIOF-> MODER &= ( ~ ( 0x3 << 18 ) ) ; EXTI-> EXTICR3 &= ( ~ ( 0XFF << 8 ) ) ; EXTI-> EXTICR3|= ( 0X05 << 8 ) ; EXTI-> FTSR1 |= ( 0x1 << 9 ) ; EXTI-> C1IMR1 |= ( 0x1 << 9 ) ; GICD-> ISENABLER[ 3 ] |= ( 0x1 << 3 ) ; GICD-> IPRIORITYR[ 24 ] &= ( ~ ( 0x1f << 27 ) ) ; GICD-> ITARGETSR[ 24 ] |= ( 0x1 << 24 ) ; GICD-> CTRL |= 0X1 ; GICC-> PMR |= ( 0x1f << 3 ) ; GICC-> CTRL |= 0x1 ; } void key2_it_config ( ) { RCC-> MP_AHB4ENSETR |= ( 0x1 << 5 ) ; GPIOF-> MODER &= ( ~ ( 0x3 << 14 ) ) ; EXTI-> EXTICR2 &= ( ~ ( 0XFF << 24 ) ) ; EXTI-> EXTICR2|= ( 0X05 << 24 ) ; EXTI-> FTSR1 |= ( 0x1 << 7 ) ; EXTI-> C1IMR1 |= ( 0x1 << 7 ) ; GICD-> ISENABLER[ 3 ] |= ( 0x1 << 1 ) ; GICD-> IPRIORITYR[ 24 ] &= ( ~ ( 0x1f << 11 ) ) ; GICD-> ITARGETSR[ 24 ] |= ( 0x1 << 8 ) ; GICD-> CTRL |= 0X1 ; GICC-> PMR |= ( 0x1f << 3 ) ; GICC-> CTRL |= 0x1 ; } void key3_it_config ( ) { RCC-> MP_AHB4ENSETR |= ( 0x1 << 5 ) ; GPIOF-> MODER &= ( ~ ( 0x3 << 16 ) ) ; EXTI-> EXTICR3 &= ( ~ ( 0XFF ) ) ; EXTI-> EXTICR3|= ( 0X05 ) ; EXTI-> FTSR1 |= ( 0x1 << 8 ) ; EXTI-> C1IMR1 |= ( 0x1 << 8 ) ; GICD-> ISENABLER[ 3 ] |= ( 0x1 << 2 ) ; GICD-> IPRIORITYR[ 24 ] &= ( ~ ( 0x1f << 19 ) ) ; GICD-> ITARGETSR[ 24 ] |= ( 0x1 << 16 ) ; GICD-> CTRL |= 0X1 ; GICC-> PMR |= ( 0x1f << 3 ) ; GICC-> CTRL |= 0x1 ; }
实现结果