Prosper Van / Mbed 2 deprecated quadCommand7v2

Dependencies:   mbed PID Sensorv2 xbeeCom

Committer:
oprospero
Date:
Wed Oct 15 04:59:58 2014 +0000
Revision:
0:853ffcef6c67
Child:
1:e4439be6e1b9
sensor update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oprospero 0:853ffcef6c67 1 //The section commented out is the ideal way to set the actual Watchdog timer.
oprospero 0:853ffcef6c67 2
oprospero 0:853ffcef6c67 3 #ifdef DEBUG_WATCHDOG
oprospero 0:853ffcef6c67 4 #include "mbed.h"
oprospero 0:853ffcef6c67 5 Serial wd(USBTX, USBRX);
oprospero 0:853ffcef6c67 6 #define NL "\n\r"
oprospero 0:853ffcef6c67 7 #define PRINT wd.printf //Serial.print(x)
oprospero 0:853ffcef6c67 8 #define PRINTF wd.printf //Serial.print(x, y)
oprospero 0:853ffcef6c67 9 #define PRINTLN(x) PRINT(x);PRINT(NL)
oprospero 0:853ffcef6c67 10 #else
oprospero 0:853ffcef6c67 11 #define PRINT(x)
oprospero 0:853ffcef6c67 12 #define PRINTF(...)
oprospero 0:853ffcef6c67 13 #define PRINTLN(x)
oprospero 0:853ffcef6c67 14 #endif
oprospero 0:853ffcef6c67 15
oprospero 0:853ffcef6c67 16 class Watchdog {
oprospero 0:853ffcef6c67 17 public:
oprospero 0:853ffcef6c67 18 Ticker dog;
oprospero 0:853ffcef6c67 19 int hang;
oprospero 0:853ffcef6c67 20 int check;
oprospero 0:853ffcef6c67 21 Watchdog(float time)
oprospero 0:853ffcef6c67 22 {
oprospero 0:853ffcef6c67 23 check = 1;
oprospero 0:853ffcef6c67 24 hang = 0;
oprospero 0:853ffcef6c67 25 }
oprospero 0:853ffcef6c67 26 Watchdog()
oprospero 0:853ffcef6c67 27 {
oprospero 0:853ffcef6c67 28 check = 1;
oprospero 0:853ffcef6c67 29 hang = 0;
oprospero 0:853ffcef6c67 30 }
oprospero 0:853ffcef6c67 31
oprospero 0:853ffcef6c67 32 void enable(float time)
oprospero 0:853ffcef6c67 33 {
oprospero 0:853ffcef6c67 34 dog.attach(this,&Watchdog::checker, time);
oprospero 0:853ffcef6c67 35 kick();
oprospero 0:853ffcef6c67 36 }
oprospero 0:853ffcef6c67 37
oprospero 0:853ffcef6c67 38 void kick()
oprospero 0:853ffcef6c67 39 {
oprospero 0:853ffcef6c67 40 hang = rand();
oprospero 0:853ffcef6c67 41 //reset timer
oprospero 0:853ffcef6c67 42 // SIM->SRVCOP = 0x55;
oprospero 0:853ffcef6c67 43 // SIM->SRVCOP = 0xAA;
oprospero 0:853ffcef6c67 44 }
oprospero 0:853ffcef6c67 45
oprospero 0:853ffcef6c67 46 void kick(float s) {
oprospero 0:853ffcef6c67 47 // SIM->COPC = 0xCu;
oprospero 0:853ffcef6c67 48 kick();
oprospero 0:853ffcef6c67 49 }
oprospero 0:853ffcef6c67 50
oprospero 0:853ffcef6c67 51 void disable()
oprospero 0:853ffcef6c67 52 {
oprospero 0:853ffcef6c67 53 // SIM->COPC = 0;
oprospero 0:853ffcef6c67 54 }
oprospero 0:853ffcef6c67 55
oprospero 0:853ffcef6c67 56 void checker()
oprospero 0:853ffcef6c67 57 {
oprospero 0:853ffcef6c67 58 if (hang == check)
oprospero 0:853ffcef6c67 59 {
oprospero 0:853ffcef6c67 60
oprospero 0:853ffcef6c67 61 NVIC_SystemReset();
oprospero 0:853ffcef6c67 62 }
oprospero 0:853ffcef6c67 63 check = hang;
oprospero 0:853ffcef6c67 64 }
oprospero 0:853ffcef6c67 65 };