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.
Fork of WakeUp by
Diff: WakeUp_KLxxZ.cpp
- Revision:
- 5:89dae784c38f
- Parent:
- 3:2c62a668f265
- Child:
- 6:815bef56e136
--- a/WakeUp_KLxxZ.cpp Sun Jan 12 14:58:22 2014 +0000
+++ b/WakeUp_KLxxZ.cpp Thu Feb 20 18:12:42 2014 +0000
@@ -1,4 +1,4 @@
-#if defined TARGET_KL25Z || defined TARGET_KL46Z
+#if defined TARGET_KLXX
#include "WakeUp.h"
#include "us_ticker_api.h"
@@ -8,6 +8,7 @@
static uint16_t remainder_count;
static uint32_t oldvector;
+static uint8_t oldPSR;
void restore(void);
@@ -18,15 +19,17 @@
//Check if it is running, in that case, store current values
remainder_count = 0;
- if (NVIC_GetVector(LPTimer_IRQn) != (uint32_t)WakeUp::irq_handler)
+ if (NVIC_GetVector(LPTimer_IRQn) != (uint32_t)WakeUp::irq_handler) {
oldvector = NVIC_GetVector(LPTimer_IRQn);
+ oldPSR = LPTMR0->PSR;
- if (LPTMR0->CSR & LPTMR_CSR_TIE_MASK) {
- //Write first to sync value
- LPTMR0->CNR = 0;
- uint16_t countval = LPTMR0->CNR;
- if (countval < LPTMR0->CMR)
- remainder_count = countval - LPTMR0->CMR;
+ if (LPTMR0->CSR & LPTMR_CSR_TIE_MASK) {
+ //Write first to sync value
+ LPTMR0->CNR = 0;
+ uint16_t countval = LPTMR0->CNR;
+ if (countval < LPTMR0->CMR)
+ remainder_count = countval - LPTMR0->CMR;
+ }
}
LPTMR0->CSR = 0;
@@ -95,8 +98,7 @@
NVIC_EnableIRQ(LPTimer_IRQn);
/* Clock at (1)MHz -> (1)tick/us */
- LPTMR0->PSR = LPTMR_PSR_PCS(3); // OSCERCLK -> 8MHz
- LPTMR0->PSR |= LPTMR_PSR_PRESCALE(2); // divide by 8
+ LPTMR0->PSR = oldPSR;
if (remainder_count) {
/* Set the compare register */
