本帖最后由 tonly0212 于 2013-1-11 10:25 编辑
进低功耗之前只做了这些处理,因为PA口要做按键,用于外部中断唤醒,所以没有做处理,
有不妥的地方吗?
/* Private functions ---------------------------------------------------------*/
void befor_goto_stop(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOE, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC |
RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO , DISABLE);
}
int main(void)
{
/* Enable PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Enable WKUP pin */
// PWR_WakeUpPinCmd(ENABLE);
PWR_BackupAccessCmd(ENABLE);
EXTI_Configuration();
NVIC_Configuration();
/* Configure RTC clock source and prescaler */
RTC_Configuration();
while (1)
{
if(Power_flag==0)
{
befor_goto_stop();
/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
// PWR_EnterSTANDBYMode();
PWR_EnterSTOPMod(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);
}
}
}
|