|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2014-3-17 21:04:16
|
显示全部楼层
main
#include "stm32f10x.h"
#include "exti.h"
#include "led.h"
//#include "key.h"
int main(void)
{
LED_GPIO_Config();
LED(ON);
EXTI_PE5_Config();
while(1)
{
};
}
exti.c
#include "exti.h"
/*
* 函数名:EXIT_PE5_Config();
*/
static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXIT_PE5_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE|RCC_APB2Periph_AFIO,ENABLE);
NVIC_Configuration();
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOE,&GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource5);
EXTI_InitStructure.EXTI_Line=EXTI_Line5;
EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
exti.h
#ifndef __EXTI_H
#define __EXTI_H
#include "stm32f10x.h"
void EXTI_PE5_Config(void);
#endif /* __EXTI_H */ |
|