Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Watchdog.h@40:1324da35afd4, 2013-10-05 (annotated)
- Committer:
- uci1
- Date:
- Sat Oct 05 04:45:22 2013 +0000
- Revision:
- 40:1324da35afd4
- Parent:
- 22:f957c4f840ad
- Child:
- 62:4b59c1eb429f
first commit of major overhaul to 2013-2014 mbed code. NOT YET FULLY TESTED. too many changes to list (fix local file receive, fix rates, external comm packes, big SD cards, get to comm win w/o SD, v8 config frame, v4 files, SBD buffering changes...)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 0:664899e0b988 | 1 | #ifndef MB_Watchdog |
uci1 | 0:664899e0b988 | 2 | #define MB_Watchdog |
uci1 | 0:664899e0b988 | 3 | |
uci1 | 22:f957c4f840ad | 4 | #define WDFAILSAFE (1200u) |
uci1 | 22:f957c4f840ad | 5 | |
uci1 | 40:1324da35afd4 | 6 | // Adapted from Simon's Watchdog code from |
uci1 | 0:664899e0b988 | 7 | // http://mbed.org/forum/mbed/topic/508/ |
uci1 | 0:664899e0b988 | 8 | namespace Watchdog { |
uci1 | 0:664899e0b988 | 9 | |
uci1 | 0:664899e0b988 | 10 | // "kick" or "feed" the dog - reset the watchdog timer |
uci1 | 0:664899e0b988 | 11 | // by writing this required bit pattern |
uci1 | 12:d472f9811262 | 12 | inline |
uci1 | 0:664899e0b988 | 13 | void kick() { |
uci1 | 0:664899e0b988 | 14 | LPC_WDT->WDFEED = 0xAA; |
uci1 | 0:664899e0b988 | 15 | LPC_WDT->WDFEED = 0x55; |
uci1 | 0:664899e0b988 | 16 | } |
uci1 | 0:664899e0b988 | 17 | |
uci1 | 0:664899e0b988 | 18 | // Load timeout value in watchdog timer and enable |
uci1 | 12:d472f9811262 | 19 | inline |
uci1 | 0:664899e0b988 | 20 | void kick(const float s) { |
uci1 | 0:664899e0b988 | 21 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
uci1 | 0:664899e0b988 | 22 | // WD has a fixed /4 prescaler, PCLK default is /4 |
uci1 | 0:664899e0b988 | 23 | static const float clk = static_cast<float>(SystemCoreClock / 16); |
uci1 | 0:664899e0b988 | 24 | LPC_WDT->WDTC = s * clk; |
uci1 | 40:1324da35afd4 | 25 | // LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
uci1 | 40:1324da35afd4 | 26 | LPC_WDT->WDMOD |= 0x3; // Enabled and Reset |
uci1 | 0:664899e0b988 | 27 | kick(); |
uci1 | 0:664899e0b988 | 28 | } |
uci1 | 22:f957c4f840ad | 29 | |
uci1 | 40:1324da35afd4 | 30 | inline |
uci1 | 40:1324da35afd4 | 31 | bool didWatchdogReset() { |
uci1 | 40:1324da35afd4 | 32 | return ( (LPC_WDT->WDMOD) & 0x4 ); |
uci1 | 40:1324da35afd4 | 33 | } |
uci1 | 40:1324da35afd4 | 34 | |
uci1 | 40:1324da35afd4 | 35 | inline |
uci1 | 40:1324da35afd4 | 36 | void clearResetFlag() { |
uci1 | 40:1324da35afd4 | 37 | LPC_WDT->WDMOD &= ~(0x4); |
uci1 | 40:1324da35afd4 | 38 | } |
uci1 | 40:1324da35afd4 | 39 | |
uci1 | 22:f957c4f840ad | 40 | struct SnKickStarter { |
uci1 | 22:f957c4f840ad | 41 | SnKickStarter(const float s) { |
uci1 | 22:f957c4f840ad | 42 | Watchdog::kick(s); |
uci1 | 22:f957c4f840ad | 43 | } |
uci1 | 22:f957c4f840ad | 44 | }; |
uci1 | 0:664899e0b988 | 45 | |
uci1 | 0:664899e0b988 | 46 | }; |
uci1 | 0:664899e0b988 | 47 | |
uci1 | 0:664899e0b988 | 48 | |
uci1 | 0:664899e0b988 | 49 | #endif // MB_Watchdog |