System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
main.cpp@30:91af74a299e1, 2014-11-13 (annotated)
- Committer:
- pspatel321
- Date:
- Thu Nov 13 10:53:10 2014 +0000
- Revision:
- 30:91af74a299e1
- Child:
- 31:7eaa5e881b56
Parth's edits for the week.; DC-DC completed and fixed, IMD updated, LatchMonitor and Temperature added. Serial dashboard updated. File structure changed Everything tested. Compiles and runs.; Still need to write CAN in/out interface.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pspatel321 | 30:91af74a299e1 | 1 | #include "IOobjects.h" |
pspatel321 | 30:91af74a299e1 | 2 | #include "runTime.h" |
pspatel321 | 30:91af74a299e1 | 3 | #include "outDiagnostics.h" |
pspatel321 | 30:91af74a299e1 | 4 | |
pspatel321 | 30:91af74a299e1 | 5 | int main() { |
pspatel321 | 30:91af74a299e1 | 6 | wdt.kick(0.11); // Kick the watchdog timer, set the timeout to 110ms |
pspatel321 | 30:91af74a299e1 | 7 | pc.baud(921600); |
pspatel321 | 30:91af74a299e1 | 8 | pc.printf("\r\n\r\nSys Mgmt Reset\r\n"); |
pspatel321 | 30:91af74a299e1 | 9 | can.mode(FIFO); // Use FIFO mode |
pspatel321 | 30:91af74a299e1 | 10 | NVIC_SetPriority(TIMER3_IRQn, 2); // Decrease timer3 priority (mbed timer, rtos) |
pspatel321 | 30:91af74a299e1 | 11 | NVIC_SetPriority(UART0_IRQn, 1); // Decrease serial priority to give CAN higher priority |
pspatel321 | 30:91af74a299e1 | 12 | |
pspatel321 | 30:91af74a299e1 | 13 | // Did a watchdog reset occur since last power cycle? |
pspatel321 | 30:91af74a299e1 | 14 | if (wdt.checkFlag()) { |
pspatel321 | 30:91af74a299e1 | 15 | data.watchdogReset = true; |
pspatel321 | 30:91af74a299e1 | 16 | pc.printf("Watchdog Reset\r\n"); |
pspatel321 | 30:91af74a299e1 | 17 | } |
pspatel321 | 30:91af74a299e1 | 18 | |
pspatel321 | 30:91af74a299e1 | 19 | // Start the 10Hz data thread |
pspatel321 | 30:91af74a299e1 | 20 | Thread gather_10Hz(runTime::thread_gather_10Hz, 0, osPriorityHigh); |
pspatel321 | 30:91af74a299e1 | 21 | |
pspatel321 | 30:91af74a299e1 | 22 | // Start the 100Hz data timer (more time critical than thread) |
pspatel321 | 30:91af74a299e1 | 23 | Thread gather_100Hz(runTime::thread_gather_100Hz, 0, osPriorityRealtime); |
pspatel321 | 30:91af74a299e1 | 24 | |
pspatel321 | 30:91af74a299e1 | 25 | // Start the serial, CAN threads |
pspatel321 | 30:91af74a299e1 | 26 | Thread serial_out(outDiagnostics::thread_serialOut, 0, osPriorityAboveNormal, 6000); // Allocate 6kB RAM stack |
pspatel321 | 30:91af74a299e1 | 27 | Thread can_out(outDiagnostics::thread_canOut, 0, osPriorityAboveNormal, 256); // Allocate 256B RAM stack |
pspatel321 | 30:91af74a299e1 | 28 | |
pspatel321 | 30:91af74a299e1 | 29 | // Background task |
pspatel321 | 30:91af74a299e1 | 30 | while(1) { |
pspatel321 | 30:91af74a299e1 | 31 | // Service CAN and Xbee logic |
pspatel321 | 30:91af74a299e1 | 32 | } |
pspatel321 | 30:91af74a299e1 | 33 | } |