Updated
Revision 0:a6a942dd5b03, committed 2019-01-05
- Comitter:
- Swabey89
- Date:
- Sat Jan 05 15:02:58 2019 +0000
- Commit message:
- Updated
Changed in this revision
Watchdog.cpp | Show annotated file Show diff for this revision Revisions of this file |
Watchdog.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r a6a942dd5b03 Watchdog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.cpp Sat Jan 05 15:02:58 2019 +0000 @@ -0,0 +1,83 @@ +#include "Watchdog.h" + +void watchdog(void) +{ + while(true) + { + Thread::wait(WATCHDOG_TIME); + + if(threadstates) + { + producer_thread.terminate(); + consumer_thread.terminate(); + serial_thread.terminate(); + SDqueue_thread.terminate(); + LCDqueue_thread.terminate(); + network_thread.terminate(); + printf_thread.terminate(); + + pc->printf("THREAD PSW: 0x%x\r\n\n", threadstates); + pc->printf("PRODUCER CONSUMER SERIAL SD CARD LCD NETWORK \r\n"); + pc->printf("%d %d %d %d %d %d\r\n\n", threadstates&PRODUCER, (threadstates&CONSUMER)>>1, (threadstates&SERIAL)>>2, (threadstates&SD)>>3, (threadstates&LCD)>>4, (threadstates&NETWORK)>>5); + + + switch (threadstates) + { + case (PRODUCER) : + pc->printf("PRODUCER THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("PRODUCER\nDEADLOCK"); + break; + + case (CONSUMER) : + pc->printf("CONSUMER THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("CONSUMER\nDEADLOCK"); + break; + + case (SERIAL) : + pc->printf("SERIAL THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("SERIAL\nDEADLOCK"); + break; + + case (SD) : + pc->printf("SD CARD THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("SD CARD\nDEADLOCK"); + break; + + case (LCD) : + pc->printf("LCD THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("LCD\nDEADLOCK"); + break; + + case (NETWORK) : + pc->printf("NETWORK THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("NETWORK\nDEADLOCK"); + break; + + default: + pc->printf("MULTIPLE THREAD DEADLOCK\r\n\n"); + lcd.cls(); + lcd.printf("DEADLOCK"); + break; + } + + for (int i = 0;i<50;i++) + { + redLED = 1; + wait(0.05); + redLED = 0; + wait(0.05); + } + NVIC_SystemReset(); + } + else if (logging) + { + printQueue.call(puts,"WATCHDOG RAN WITH NO DEADLOCKED THREADS\r\n"); + } + } +}
diff -r 000000000000 -r a6a942dd5b03 Watchdog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.h Sat Jan 05 15:02:58 2019 +0000 @@ -0,0 +1,18 @@ +#ifndef __WATCHDOG__ +#define __WATCHDOG__ + +#include "main.h" +#include "sample_hardware.hpp" + +#define WATCHDOG_TIME 10000 + +#define PRODUCER 1<<0 +#define CONSUMER 1<<1 +#define SERIAL 1<<2 +#define SD 1<<3 +#define LCD 1<<4 +#define NETWORK 1<<5 + +extern void watchdog(void); + +#endif