Flotsam / Full-Project

Dependencies:   GPSLibrary GSM mbed-modifed Storage_Library Temp_Library Wakeup pH_Sensor

Revision:
7:92f2d8c79565
Parent:
6:10b0ff2803e5
--- a/main.cpp	Mon Nov 09 18:55:17 2015 +0000
+++ b/main.cpp	Mon Nov 09 19:35:59 2015 +0000
@@ -123,7 +123,17 @@
   pcSerial.printf("AI_Val: %f\n", temperatureValue);
   return temperatureValue;       // 22.5 mV / °C; Ratiometric measurement, conversion valid for 5 V!
 }
-      
+
+//Found this online and it claims that it resets ADC to work after deepsleep \_O_/
+void resetADC()
+{
+    // Enable the HSI (to clock the ADC)
+    RCC_OscInitTypeDef RCC_OscInitStruct;
+    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
+    RCC_OscInitStruct.HSIState       = RCC_HSI_ON;
+    RCC_OscInitStruct.PLL.PLLState   = RCC_PLL_NONE;
+    HAL_RCC_OscConfig(&RCC_OscInitStruct);  
+}  
 
 // n_queries is the number of times we query the GPS. We need something like 23000 characters.
 void GPSRead(int n_queries) {
@@ -188,6 +198,7 @@
 {
     if(msec > 0) WakeUp::set_ms(msec);
     deepsleep();
+    resetADC();
 }
 
 bool sendDataOverHTTP(char* url, char* data)
@@ -214,7 +225,6 @@
 int main()
 {
     setup();
-    
     changeGSMPowerState();
     setupGSM();
     //sendDataOverHTTP("http://requestb.in/10pbl2i1", "testing");