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.
Dependencies: LPC1114_WakeInterruptIn
Fork of WakeUp by
Diff: Device/WakeUp_LPC11XX.cpp
- Revision:
- 12:779d866b8a2d
- Parent:
- 11:72db657fc572
- Child:
- 13:fd24cec76d5a
diff -r 72db657fc572 -r 779d866b8a2d Device/WakeUp_LPC11XX.cpp
--- a/Device/WakeUp_LPC11XX.cpp Wed Jul 30 09:53:58 2014 +0000
+++ b/Device/WakeUp_LPC11XX.cpp Wed Jul 30 15:07:08 2014 +0000
@@ -6,6 +6,7 @@
#include "WakeUp.h"
#include "WakeInterruptIn.h"
+#include "pinmap.h"
//Pin used, allowed pins = P0_1 (dp24, default), P0_8 (dp1) and P0_9 (dp2)
//By defining WakeUpPin in for example your main.cpp this can be overridden
@@ -106,6 +107,28 @@
void WakeUp::calibrate(void)
{
+ //Set oscillator for 20kHz
+ LPC_SYSCON->PDRUNCFG &= ~PDRUNCFG_WDTOSC_PD;
+ LPC_SYSCON->WDTOSCCTRL = 14 | (1<<5);
+
+ //Direct WDT to the CLKOUT pin (dp24), sample it back
+ DigitalIn din(dp24);
+ Timer timer;
+
+ LPC_SYSCON->CLKOUTDIV = 1;
+ LPC_SYSCON->CLKOUTCLKSEL = 0x2;
+ LPC_SYSCON->CLKOUTUEN = 0;
+ LPC_SYSCON->CLKOUTUEN = CLKOUTUEN_ENA;
+ pin_function(dp24, 1);
+
+ int count = 0;
+ timer.start();
+ while (timer.read_ms() < 100) {
+ while (din.read() == 0);
+ while (din.read() == 1);
+ count++;
+ }
+ cycles_per_ms = (float)count / 100.0f;
}
static inline void restore(void) {
