#include "stm32f10x.h"
void LED_GPIO_Config(void);
void interrupt_Init(void);
void key_Init(void);
int main(void)
{
LED_GPIO_Config();
interrupt_Init();
key_Init();
GPIO_SetBits(GPIOD,GPIO_Pin_7);
while(1);
}
void LED_GPIO_Config(void)
{
GPIO_InitTypeDef LED;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
LED.GPIO_Mode=GPIO_Mode_Out_PP;
LED.GPIO_Pin=GPIO_Pin_7;
LED.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&LED);
}
void interrupt_Init(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);
GPIO_InitTypeDef GPIO_IntStructure;
GPIO_IntStructure.GPIO_Mode=GPIO_Mode_IPU;
GPIO_IntStructure.GPIO_Pin=GPIO_Pin_0;
GPIO_IntStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_IntStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource5);
EXTI_InitTypeDef EXTI_IntStructure;
EXTI_IntStructure.EXTI_Line=EXTI_Line5;
EXTI_IntStructure.EXTI_LineCmd=ENABLE;
EXTI_IntStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_IntStructure.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Init(&EXTI_IntStructure);
NVIC_InitTypeDef NVIC_IntStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_IntStructure.NVIC_IRQChannel=EXTI9_5_IRQn;
NVIC_IntStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_IntStructure.NVIC_IRQChannelPreemptionPriority=1;
NVIC_IntStructure.NVIC_IRQChannelSubPriority=1;
NVIC_Init(&NVIC_IntStructure);
}
void key_Init(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitTypeDef GPIO_Inite;
GPIO_Inite.GPIO_Mode=GPIO_Mode_IPU;
GPIO_Inite.GPIO_Pin=GPIO_Pin_5;
GPIO_Inite.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_Inite);
}