System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: main.cpp
- Revision:
- 34:18bcf276d3bf
- Parent:
- 33:6bc82b6b62e5
- Child:
- 36:0afc0fc8f86b
--- a/main.cpp Tue Jan 06 20:45:26 2015 +0000
+++ b/main.cpp Wed Jan 07 03:25:50 2015 +0000
@@ -1,7 +1,7 @@
#include "IOobjects.h"
#include "runTime.h"
#include "outDiagnostics.h"
-#include "serviceCAN.h"
+#include "inCommands.h"
int main() {
wdt.kick(); // Kick the watchdog timer
@@ -9,7 +9,11 @@
pc.format(8, SerialBase::None, 2); // 2 Stop bits, reduce bad serial packets
can.mode(FIFO);
- DigitalOut led1(LED1);
+ NVIC_SetPriority(TIMER3_IRQn, 4);
+ NVIC_SetPriority(UART0_IRQn, 0);
+ NVIC_SetPriority(CAN_IRQn, 3);
+ NVIC_SetPriority(TIMER0_IRQn, 1);
+ NVIC_SetPriority(PWM1_IRQn, 2);
bool normalReset = true;
// Did a watchdog reset occur since last power cycle?
@@ -17,7 +21,6 @@
wdt.clearFlag(); // Clear flag
data.watchdogReset = true;
pc.printf("Sys Mgmt Watchdog Reset\r\n");
- led1=1;
normalReset=false;
}
// Did a brownout reset occur since last power cycle?
@@ -30,23 +33,26 @@
if (normalReset) pc.printf("Sys Mgmt Reset\r\n");
// Start the 10Hz data thread
- // Thread gather(runTime::thread_gather, 0, osPriorityHigh);
+ Thread gather(runTime::thread_gather, 0, osPriorityHigh, 512);
// Start the 100Hz data timer (more time critical than thread)
- //RtosTimer sample(runTime::thread_sample, osTimerPeriodic);
- //sample.start(FAST_LOOP*1000);
+ RtosTimer sample(runTime::thread_sample, osTimerPeriodic);
+ sample.start(FAST_LOOP*1000);
// 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
+ Thread serial_out(outDiagnostics::thread_serialOut, 0, osPriorityAboveNormal, 2000); // Allocate 6kB RAM stack
+ Thread can_out(outDiagnostics::thread_canOut, 0, osPriorityAboveNormal, 512); // Allocate 256B RAM stack
- wdt.kick(WDT_TIME); // Startup complete, normal timeout
-
+ wdt.kick(1); // Startup complete, normal timeout
// Background task
while(1) {
// Service CAN and Xbee logic
- //if (canbus::serviceCAN());
- //canbus::receiveMsgXbee();
+ inCommands::serviceCAN();
+ inCommands::receiveMsgXbee();
+
+ int ret = inCommands::serviceSerial();
+ if (ret == -1) tempData.parseGoodChar = 'x';
+ if (ret == 1) tempData.parseGoodChar = 251;
wdt.kick();
}
}
\ No newline at end of file
