Real-time bike tracker using Adafruit Ultimate GPS, Huzzah wifi, and Pubnub
Dependencies: MBed_Adafruit-GPS-Library mbed
Revision 4:e20e2500914f, committed 2017-04-21
- Comitter:
- ECE4180
- Date:
- Fri Apr 21 00:37:35 2017 +0000
- Parent:
- 3:ceca81e8ac2b
- Child:
- 5:786cb04aaecc
- Commit message:
- bootyful and we love you
Changed in this revision
Watchdog.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.h Fri Apr 21 00:37:35 2017 +0000 @@ -0,0 +1,17 @@ +class Watchdog { +public: +// Load timeout value in watchdog timer and enable + void kick(float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 + LPC_WDT->WDTC = s * (float)clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + kick(); + } +// "kick" or "feed" the dog - reset the watchdog timer +// by writing this required bit pattern + void kick() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } +}; \ No newline at end of file
--- a/main.cpp Fri Apr 21 00:07:54 2017 +0000 +++ b/main.cpp Fri Apr 21 00:37:35 2017 +0000 @@ -2,7 +2,7 @@ #include "MBed_Adafruit_GPS.h" #include "math.h" #include "PubNub.h" - +#include "Watchdog.h" string pubkey("pub-c-f9091d93-c3a8-41a6-80c2-c6e3f840504f"); string subkey("sub-c-f558e36c-130b-11e7-b59a-02ee2ddab7fe"); @@ -18,6 +18,8 @@ char tx_buffer[4096]; char rx_buffer[4096]; +Watchdog wdt; + Serial * gps_Serial; Serial pc (USBTX, USBRX); //Set-up for debugging @@ -62,6 +64,7 @@ int main() { + wdt.kick(8.0); pc.baud(115200); //Set PC baud rate pnub.huz.setssid("Verizon-SM-G900V-258B"); pnub.huz.setpwd("trnd533)"); @@ -94,16 +97,16 @@ wait(1); refresh_Timer.start(); //starts the clock on the timer while(true) { - c = myGPS.read(); //queries the GPS - + c = myGPS.read(); //queries the GPS + //if (c) { pc.printf("%c", c); } //this line will echo the GPS data if not paused //If GPS has data, parse it - - //check if we recieved a new message from GPS, if so, attempt to parse it, + + //check if we recieved a new message from GPS, if so, attempt to parse it, if ( myGPS.newNMEAreceived() ) { if ( !myGPS.parse(myGPS.lastNMEA()) ) { - continue; - } + continue; + } } //check if enough time has passed to warrant sending new GPS data @@ -127,5 +130,6 @@ pc.printf("No Satelite Fix\r\n"); } } + wdt.kick(); } } \ No newline at end of file