[mw_shl_code=c,true]#include "standby.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "misc.h"
#include "key.h"
#include "delay.h"
#include "led.h"
#include "stm32f10x_pwr.h"
void StanByMode_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
NVIC_InitTypeDef NVIC_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOA,&GPIO_InitStruct);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
EXTI_InitStruct.EXTI_Line = EXTI_Line0;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);
NVIC_InitStruct.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
}
void Sys_Standby(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_WakeUpPinCmd(ENABLE);
PWR_EnterSTANDBYMode();
}
void EXTI0_IRQHandeler(void)
{
EXTI_ClearITPendingBit(EXTI_Line0);
if(KEY) //#define KEY GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0)
{
delay_ms(10);
if(KEY)
{
Sys_Standby();
}
}
}[/mw_shl_code]
问题是这样的:我现在在做原子老大的待机实验,以上为我自己编写的代码,主函数就是红灯闪烁,按理说当我按下wk_up按键时应该进入休眠状态,再按一下复位,但是现在当我按下按键时,程序直接卡死在那,也就是说直接定格在灯闪烁的某个状态,只能复位,我想问问各位这种情况如何解决,已快崩溃!!!
|