下面是我写的进入Sleep模式的代码,你把它添加到软件库中stm32f10x_pwr.c中
/*******************************************************************************
* Function Name : PWR_EnterSLEEPMode
* Description : Enters SLEEP mode.
* Input : - SysCtrl_Set: Select the Sleep mode entry mechanism,.
* This parameter can be one of the following values:
* - 0: MCU enters Sleep mode as soon as WFI or WFE instruction is executed.
* - 1: MCU enters Sleep mode as soon as it exits the lowest priority ISR.
*
* - PWR_STOPEntry: specifies if SLEEP mode in entered with WFI or WFE instruction.
* This parameter can be one of the following values:
* - PWR_SLEEPEntry_WFI: enter STOP mode with WFI instruction
* - PWR_SLEEPEntry_WFE: enter STOP mode with WFE instruction
* Output : None
* Return : None
*******************************************************************************/
void PWR_EnterSLEEPMode(u32 SysCtrl_Set, u8 PWR_SLEEPEntry)
{
if (SysCtrl_Set)
*(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPONEXIT_Set; // Set SLEEPONEXIT
else
*(vu32 *) SCB_SysCtrl &= ~SysCtrl_SLEEPONEXIT_Set;// Reset SLEEPONEXIT