Basic implementation of watchdog
Dependencies: STM_ResetSupervisor USBDevice
Diff: main.cpp
- Revision:
- 2:50b1371247da
- Parent:
- 1:38b385f34687
--- a/main.cpp Tue Jun 25 23:49:40 2019 +0000 +++ b/main.cpp Sun Oct 06 02:59:58 2019 +0000 @@ -1,29 +1,37 @@ #include "mbed.h" -#include <ros.h> -#include <nav_msgs/Odometry.h> //contains both the twist and pose -#include "Watchdog.h" +#include "ResetSupervisor.h" int i = 1; -Serial pc(USBTX, USBRX, 57600); //Serial Monitor +#include "USBSerial.h" +/******************** Comms *********************/ +USBSerial pc; +FileHandle* mbed::mbed_override_console(int) +{ + return &pc; +} + +Supervisor foreman; int main(void) { - Watchdog dog; - dog.Configure(1); - pc.printf("I'm resetting!\n", dog.WatchdogCausedReset()); + wait(1); + + foreman.initWD(5); // turn on the Watchdog Timer and set it for 5 seconds + if(foreman.resetReason() == RCC_FLAG_IWDGRST) + pc.printf("Watchdog Reset!\n"); - while(i++) + while(1) { - pc.printf("Hello! I'm working! Iteration: %d \n", i); - wait(0.9); - - if (i == 10) { - wait(0.6); - } - - - dog.Service(); - //return 0; + pc.printf("Hello! I'm working! Iteration: %d \n", i); + wait(1); + + if (i == 10) { + wait(10); + } + + + foreman.pingWD(); + i++; } } \ No newline at end of file