mbed-os github

Dependencies:   ADS1015 Faulhaber HTU21D_mod MS5837_potless Sensor_Head_RevB_3 USBDevice_dfu Utilsdfu beep

Fork of ARNSRS_testDFU by POTLESS

Revision:
38:fe77b68eec37
Parent:
37:f9461c6592f2
Child:
39:65ff3c4f9675
--- a/main.cpp	Tue Mar 13 18:21:49 2018 +0000
+++ b/main.cpp	Mon Mar 19 18:55:49 2018 +0000
@@ -153,6 +153,7 @@
 
 //Interruption user button
 InterruptIn button(USER_BUTTON);
+InterruptIn vpile_off_on(PA_0); // TODO mettre un define sur PA_0
 volatile int  GO = 0;
 
 void Affichage()
@@ -189,6 +190,12 @@
     if (GO > 1) NVIC_SystemReset();
 }
 
+void retour_alim()
+{
+ DEBUG("-------------- interruption retour alim en cours ---------------\r\n");
+ NVIC_SystemReset();
+}
+
 //Passage en mode SECU
 void Mode_SECU()
 {
@@ -251,11 +258,18 @@
     
     DEBUG("\n\r Deepsleep méthode offensive !\n");
     
-    HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
+    HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2); // pour PC_13
     // Clear wake up Flag 
     __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);  
     // Enable wakeup pin WKUP2 
-    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW);
+    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW); // low parce qu'on veut que ça redémarre avec le user button TODO à passer sur High pour que ça redémarrage avec l'arrivée du hus sur l'USB
+    /*
+    HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); // pour PA_0
+    // Clear wake up Flag 
+    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);  
+    // Enable wakeup pin WKUP2 
+    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH); // high car on veut que ça redémarre à l'arrivée du jus
+    */
     // Set RTC back-up register RTC_BKP31R to indicate 
     //later on that system has entered shutdown mode  
     WRITE_REG( RTC->BKP31R, 0x1 );
@@ -594,8 +608,11 @@
 {
     
     HAL_Init();  
+    
+    V_USB.mode(PullDown); // on force à zero tant que l'alim par les piles n'est pas en place
 
     button.fall(&pressed);
+    vpile_off_on.rise (&retour_alim);
     
     __HAL_RCC_PWR_CLK_ENABLE(); 
     HAL_PWR_EnableBkUpAccess();