mbed-os github
Dependencies: ADS1015 Faulhaber HTU21D_mod MS5837_potless Sensor_Head_RevB_3 USBDevice_dfu Utilsdfu beep
Fork of ARNSRS_testDFU by
Diff: main.cpp
- Revision:
- 37:f9461c6592f2
- Parent:
- 36:1f5e2247b073
- Child:
- 38:fe77b68eec37
diff -r 1f5e2247b073 -r f9461c6592f2 main.cpp --- a/main.cpp Thu Mar 08 15:38:06 2018 +0000 +++ b/main.cpp Tue Mar 13 18:21:49 2018 +0000 @@ -228,10 +228,40 @@ { Mode_SECU(); DEBUG("----------------ARRET DE L'APPAREIL--------------------\r\n"); + + // préparation deepsleep + + /* + //première méthode mais je ne sais pas ce que ça consomme et il faut normalement reduire le frequence d'horloge avant + //il est possible que ça génère un plantage et la rtc ne fonctionnera pas? + HAL_PWREx_EnableLowPowerRunMode(); + DEBUG("----------------LOW POWER RUN MODE--------------------\r\n"); + + bool isDSallowed; + isDSallowed = sleep_manager_can_deep_sleep(); + DEBUG(" Deep sleep autorisé ? %i\r\n", isDSallowed); + wait(1.0); - DEBUG(" Deep sleep autorisé : %i\r\n", sleep_manager_can_deep_sleep()); - wait(1.0); - sleep_manager_sleep_auto(); + DEBUG("\n\r Deepsleep tentative normale !(bouton bleu pour ressortir)\n"); + wait(0.1); + + sleep_manager_sleep_auto(); // ne marche pas, je ne sais pas pk + */ + + + DEBUG("\n\r Deepsleep méthode offensive !\n"); + + HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2); + // Clear wake up Flag + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2); + // Enable wakeup pin WKUP2 + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW); + // Set RTC back-up register RTC_BKP31R to indicate + //later on that system has entered shutdown mode + WRITE_REG( RTC->BKP31R, 0x1 ); + //Enter shutdown mode + DEBUG("\n\r Attention c'est du brutal ! bouton bleu pour ressort.... ZZZZZZZ ZZZZZ !!!\n"); + HAL_PWREx_EnterSHUTDOWNMode(); } //Fonction test de valeur d'entrée digitale @@ -562,8 +592,13 @@ int main() { + + HAL_Init(); button.fall(&pressed); + + __HAL_RCC_PWR_CLK_ENABLE(); + HAL_PWR_EnableBkUpAccess(); int count = 0;