Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: sx1276/arduino-mbed.cpp
- Revision:
- 70:1d496aae2819
- Parent:
- 69:d440a5b04708
diff -r d440a5b04708 -r 1d496aae2819 sx1276/arduino-mbed.cpp
--- a/sx1276/arduino-mbed.cpp Fri Jul 21 17:09:05 2017 +0200
+++ b/sx1276/arduino-mbed.cpp Sun Jul 23 15:44:57 2017 +0200
@@ -270,6 +270,16 @@
uint64_t ticker_ns;
static bool initTickerDone = false;
+uint32_t s_getTicker(void)
+{
+ long long ns = ns_getTicker();
+ ns /= (long long)1000000000; // to secs
+
+ int secs = ns;
+ return secs;
+}
+
+
uint32_t ms_getTicker(void)
{
uint32_t us = us_getTicker();
@@ -617,12 +627,22 @@
* when in sleep mode. */
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
#endif
-
+ uint32_t saved_ms = ms_getTicker();
+ SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; // disbale SysTick
+
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; // clear deep sleep
PM->SLEEP.reg = 2; // SYSTEM_SLEEPMODE_IDLE_2 IDLE 2 sleep mode.
__DSB(); // ensures the completion of memory accesses
__WFI(); // wait for interrupt
+
+ int count = ms_getTicker() - saved_ms;
+ if (count > 0) { // update the Arduino Systicks
+ for (int i = 0; i < count; i++) {
+ SysTick_Handler();
+ }
+ }
+ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; // enable SysTick
}
void deepsleep(void)
@@ -633,10 +653,14 @@
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
#endif
+ SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; // disbale SysTick
+
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // standby mode
-
+
__DSB(); // ensures the completion of memory accesses
__WFI(); // wait for interrupt
+
+ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; // enable SysTick
}