TEST
Dependencies: TMRh20_v2 mbed-dev ssRadio WakeUp
Revision 1:499ddde5f76c, committed 2017-10-14
- Comitter:
- gume
- Date:
- Sat Oct 14 22:41:48 2017 +0000
- Parent:
- 0:827df48824f9
- Commit message:
- Sleep added
Changed in this revision
WakeUp.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 827df48824f9 -r 499ddde5f76c WakeUp.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WakeUp.lib Sat Oct 14 22:41:48 2017 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Sissors/code/WakeUp/#65c04a02ad45
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