Improve handling of arming, providing LED blink codes if the arming fails.
Also, implement a software watchdog to make sure that the main real-time modules are actually being run. Provide a panic facility, also giving blink codes to indicate the panic reason.
This commit is contained in:
15
main.c
15
main.c
@@ -6,8 +6,9 @@
|
||||
#include "uart.h"
|
||||
#include "interrupt.h"
|
||||
#include "event.h"
|
||||
#include "stick.h"
|
||||
#include "led.h"
|
||||
#include "status.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
#define PINSEL0 (*((volatile unsigned int *) 0xE002C000))
|
||||
#define PINSEL1 (*((volatile unsigned int *) 0xE002C004))
|
||||
@@ -179,13 +180,12 @@ void timer_event_handler(void)
|
||||
void menu_handler(void);
|
||||
|
||||
int main(void) {
|
||||
armed = FALSE;
|
||||
|
||||
init_interrupt();
|
||||
init_uart();
|
||||
init_i2c();
|
||||
init_pins();
|
||||
init_timer();
|
||||
init_status();
|
||||
|
||||
event_register(EVENT_UART_INPUT, menu_handler);
|
||||
|
||||
@@ -197,11 +197,7 @@ int main(void) {
|
||||
|
||||
putstr("prompt> ");
|
||||
|
||||
led_set(FALSE);
|
||||
timer_delay_ms(1000);
|
||||
led_set(TRUE);
|
||||
timer_delay_ms(1000);
|
||||
led_set(FALSE);
|
||||
if (!wmp_init())
|
||||
putstr("WMP initialisation failed\r\n");
|
||||
|
||||
@@ -209,12 +205,15 @@ int main(void) {
|
||||
timer_set_period(5*TIMER_MS);
|
||||
wmp_start_zero();
|
||||
|
||||
led_set_pattern(led_pattern_active);
|
||||
led_init();
|
||||
|
||||
init_watchdog();
|
||||
|
||||
/* Good luck! */
|
||||
while (1) {
|
||||
led_update();
|
||||
event_dispatch();
|
||||
watchdog_check();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user