东亚 范
/
NucleoStandbyTest_WKUP
WAKE UP
Fork of NucleoStandbyTest by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "WakeUp.h" 00003 00004 DigitalOut myled(LED1); 00005 00006 void ClearWakeUp(void); 00007 00008 int main() 00009 { 00010 myled = 1; 00011 wait(0.2); 00012 myled = 0; 00013 wait(0.2); 00014 00015 //The low-power oscillator can be quite inaccurate on some targets 00016 //this function calibrates it against the main clock 00017 WakeUp::calibrate(); 00018 00019 00020 WakeUp::set_ms(5000); 00021 ClearWakeUp(); 00022 00023 printf("Entering Standby Mode\r\n"); 00024 00025 HAL_PWR_EnterSTANDBYMode(); 00026 00027 //This will never be executed 00028 printf("After sleep\r\n"); 00029 00030 } 00031 void ClearWakeUp(void) 00032 { 00033 PWR->CR |= PWR_CR_DBP; //Enable power domain 00034 RTC->WPR = 0xCA; //Disable RTC write protection 00035 RTC->WPR = 0x53; 00036 00037 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 00038 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); 00039 00040 RTC->WPR = 0xFF; //Enable RTC write protection 00041 PWR->CR &= ~PWR_CR_DBP; //Disable power domain 00042 }
Generated on Sat Jul 16 2022 07:51:38 by 1.7.2