PA1
void?NST1001_Init(void) { ????GPIO_InitTypeDef?GPIO_InitStructure?=?{0}; ????EXTI_InitTypeDef?EXTI_InitStructure?=?{0}; ????NVIC_InitTypeDef?NVIC_InitStructure?=?{0}; ????RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,?ENABLE); ????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_1; ????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz; ????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPU; ????GPIO_Init(GPIOA,?&GPIO_InitStructure); ????GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,?GPIO_PinSource1); ????EXTI_InitStructure.EXTI_Line?=?EXTI_Line1; ????EXTI_InitStructure.EXTI_Mode?=?EXTI_Mode_Interrupt; ????EXTI_InitStructure.EXTI_Trigger?=?EXTI_Trigger_Falling; ????EXTI_InitStructure.EXTI_LineCmd?=?ENABLE; ????EXTI_Init(&EXTI_InitStructure); ????NVIC_InitStructure.NVIC_IRQChannel?=?EXTI7_0_IRQn; ????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?0; ????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?1; ????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE; ????NVIC_Init(&NVIC_InitStructure); }
KEY1【PD3】
void?Key_Init(void) { ????GPIO_InitTypeDef?GPIO_InitStructure?=?{0}; ????EXTI_InitTypeDef?EXTI_InitStructure?=?{0}; ????NVIC_InitTypeDef?NVIC_InitStructure?=?{0}; ????RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,?ENABLE); ????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3; ????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz; ????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPU; ????GPIO_Init(GPIOD,?&GPIO_InitStructure); ????GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,?GPIO_PinSource3); ????EXTI_InitStructure.EXTI_Line?=?EXTI_Line3; ????EXTI_InitStructure.EXTI_Mode?=?EXTI_Mode_Interrupt; ????EXTI_InitStructure.EXTI_Trigger?=?EXTI_Trigger_Falling; ????EXTI_InitStructure.EXTI_LineCmd?=?ENABLE; ????EXTI_Init(&EXTI_InitStructure); ????NVIC_InitStructure.NVIC_IRQChannel?=?EXTI7_0_IRQn; ????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?0; ????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?1; ????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE; ????NVIC_Init(&NVIC_InitStructure); }
EXTICR = 0xC0
printf("%p\r\n",?AFIO->EXTICR);
7.3.2.2 外部中断配置寄存器 1(AFIO_EXTICR)?
偏移地址:0x08?
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved?
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0?
EXTI7[1:0] EXTI6[1:0] EXTI5[1:0] EXTI4[1:0] EXTI3[1:0] EXTI2[1:0] EXTI1[1:0] EXTI0[1:0] 位 名称 访问 描述 复位值 [31:16] Reserved RO 保留。 0?
[15:14] [13:12] [11:10] [9:8] [7:6] [5:4] [3:2] [1:0] EXTIx[1:0]
(x=0-7),外部中断输入引脚配置位。用以决 定外部中断引脚映射到哪个端口的引脚上。 00:PA 引脚的第 x 个引脚; 10:PC 引脚的第 x 个引脚; 11:PD 引脚的第 x 个引脚