Point Labs / Mbed OS Example_WatchDog_Timer

Dependencies:   STM_ResetSupervisor USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ResetSupervisor.h"
00003 
00004 int i = 1;
00005 
00006 #include "USBSerial.h"
00007 
00008 /******************** Comms *********************/
00009 USBSerial pc;
00010 FileHandle* mbed::mbed_override_console(int)
00011 {   
00012     return &pc;
00013 }
00014 
00015 Supervisor foreman;
00016 int main(void)
00017 {
00018     wait(1);
00019 
00020     foreman.initWD(5); // turn on the Watchdog Timer and set it for 5 seconds
00021     if(foreman.resetReason() == RCC_FLAG_IWDGRST)
00022         pc.printf("Watchdog Reset!\n");
00023     
00024     while(1)
00025     {
00026         pc.printf("Hello! I'm working! Iteration: %d \n", i);
00027         wait(1);
00028         
00029         if (i == 10) {
00030             wait(10);
00031         }
00032         
00033         
00034         foreman.pingWD();
00035         i++;
00036     }
00037 }