System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: main.cpp
- Revision:
- 30:91af74a299e1
- Child:
- 31:7eaa5e881b56
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Nov 13 10:53:10 2014 +0000
@@ -0,0 +1,33 @@
+#include "IOobjects.h"
+#include "runTime.h"
+#include "outDiagnostics.h"
+
+int main() {
+ wdt.kick(0.11); // Kick the watchdog timer, set the timeout to 110ms
+ pc.baud(921600);
+ pc.printf("\r\n\r\nSys Mgmt Reset\r\n");
+ can.mode(FIFO); // Use FIFO mode
+ NVIC_SetPriority(TIMER3_IRQn, 2); // Decrease timer3 priority (mbed timer, rtos)
+ NVIC_SetPriority(UART0_IRQn, 1); // Decrease serial priority to give CAN higher priority
+
+ // Did a watchdog reset occur since last power cycle?
+ if (wdt.checkFlag()) {
+ data.watchdogReset = true;
+ pc.printf("Watchdog Reset\r\n");
+ }
+
+ // Start the 10Hz data thread
+ Thread gather_10Hz(runTime::thread_gather_10Hz, 0, osPriorityHigh);
+
+ // Start the 100Hz data timer (more time critical than thread)
+ Thread gather_100Hz(runTime::thread_gather_100Hz, 0, osPriorityRealtime);
+
+ // Start the serial, CAN threads
+ Thread serial_out(outDiagnostics::thread_serialOut, 0, osPriorityAboveNormal, 6000); // Allocate 6kB RAM stack
+ Thread can_out(outDiagnostics::thread_canOut, 0, osPriorityAboveNormal, 256); // Allocate 256B RAM stack
+
+ // Background task
+ while(1) {
+ // Service CAN and Xbee logic
+ }
+}
\ No newline at end of file
