TEST

Dependencies:   TMRh20_v2 mbed-dev ssRadio WakeUp

Revision:
1:499ddde5f76c
Parent:
0:827df48824f9
diff -r 827df48824f9 -r 499ddde5f76c main.cpp
--- a/main.cpp	Fri Oct 06 20:22:14 2017 +0000
+++ b/main.cpp	Sat Oct 14 22:41:48 2017 +0000
@@ -1,4 +1,5 @@
 #include "ssRadio.h"
+#include "WakeUp.h"
 
 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
 SSRadio *radio;
@@ -40,6 +41,8 @@
     //pc.printf("Working.");
   }
   
+  WakeUp::calibrate();
+  
   while (1) { loop(); }
 }
 
@@ -48,13 +51,21 @@
 void loop() {
   // put your main code here, to run repeatedly:
   
-  long now = us_ticker_read() / 1000;
-  if (now - last > 1000) {
+  WakeUp::set_ms(2000);
+  //deepsleep();
+  // Stop HAL tick to avoid to exit sleep in 1ms
+  HAL_SuspendTick();
+  // Request to enter SLEEP mode
+  HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
+  // Restart HAL tick
+  HAL_ResumeTick();
+            
+  radio->sendData((uint8_t*)"Hello", 6, 6);
+  radio->loop();
+  
+  //long now = us_ticker_read() / 1000;
+  //if (now - last > 1000) {}
     //pc.printf("Hello");
-    radio->sendData((uint8_t*)"Hello", 6, 6);
-    last = now;
-  }
   
-  radio->loop();
 }
  
\ No newline at end of file