Real-time bike tracker using Adafruit Ultimate GPS, Huzzah wifi, and Pubnub
Dependencies: MBed_Adafruit-GPS-Library mbed
Watchdog.h@6:5bc3eeabdca3, 2017-04-23 (annotated)
- Committer:
- ECE4180
- Date:
- Sun Apr 23 15:24:21 2017 +0000
- Revision:
- 6:5bc3eeabdca3
- Parent:
- 4:e20e2500914f
For Notebook Page
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ECE4180 | 4:e20e2500914f | 1 | class Watchdog { |
ECE4180 | 4:e20e2500914f | 2 | public: |
ECE4180 | 4:e20e2500914f | 3 | // Load timeout value in watchdog timer and enable |
ECE4180 | 4:e20e2500914f | 4 | void kick(float s) { |
ECE4180 | 4:e20e2500914f | 5 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
ECE4180 | 4:e20e2500914f | 6 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
ECE4180 | 4:e20e2500914f | 7 | LPC_WDT->WDTC = s * (float)clk; |
ECE4180 | 4:e20e2500914f | 8 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
ECE4180 | 4:e20e2500914f | 9 | kick(); |
ECE4180 | 4:e20e2500914f | 10 | } |
ECE4180 | 4:e20e2500914f | 11 | // "kick" or "feed" the dog - reset the watchdog timer |
ECE4180 | 4:e20e2500914f | 12 | // by writing this required bit pattern |
ECE4180 | 4:e20e2500914f | 13 | void kick() { |
ECE4180 | 4:e20e2500914f | 14 | LPC_WDT->WDFEED = 0xAA; |
ECE4180 | 4:e20e2500914f | 15 | LPC_WDT->WDFEED = 0x55; |
ECE4180 | 4:e20e2500914f | 16 | } |
ECE4180 | 4:e20e2500914f | 17 | }; |