System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
main.cpp
- Committer:
- pspatel321
- Date:
- 2014-11-14
- Revision:
- 31:7eaa5e881b56
- Parent:
- 30:91af74a299e1
- Child:
- 32:e70407021ad2
File content as of revision 31:7eaa5e881b56:
#include "IOobjects.h"
#include "runTime.h"
#include "outDiagnostics.h"
#include "serviceCAN.h"
int main() {
wdt.kick(0.25); // 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); // Allocate 256B RAM stack
// Background task
while(1) {
// Service CAN and Xbee logic
if (canbus::serviceCAN());
}
}
