The unified diff between revisions [cc8258a6..] and [a39fe798..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'main.c'
# # old_revision [cc8258a6c3643514892e84cf24fed008bc6f9660] # new_revision [a39fe7980c8f14b70401f4c97f3e10232dce016a] # # patch "main.c" # from [0a896cdc054a7e9fc0211de74469c22eef83a867] # to [38594d91649f88377c87a52973d831d9ffeafb70] # ============================================================ --- main.c 0a896cdc054a7e9fc0211de74469c22eef83a867 +++ main.c 38594d91649f88377c87a52973d831d9ffeafb70 @@ -4,6 +4,7 @@ #include "timer.h" #include "uart.h" #include "interrupt.h" +#include "event.h" #define PINSEL0 (*((volatile unsigned char *) 0xE002C000)) #define FP0XDIR (*((volatile unsigned int *) 0x3FFFC000)) @@ -158,20 +159,35 @@ void average_sample(void) putstr(")\r\n"); } -int main(void) { - int i; +void menu_handler(void); +int main(void) { init_interrupt(); init_uart(); init_i2c(); init_pins(); init_timer(); + + event_register(EVENT_UART_INPUT, menu_handler); + putstr("Your entire life has been a mathematical error... a mathematical error I'm about to correct!\r\n"); + putstr("prompt> "); + while (1) { - char c; - putstr("prompt> "); - c = getch(); + FP0XVAL ^= 0x04000000; + event_dispatch(); + } + + return 0; +} + +void menu_handler(void) +{ + int i; + char c; + + while (getch(&c)) { if (c == 0x0a) continue; putch(c); @@ -255,11 +271,14 @@ int main(void) { timer_set_period(10000*TIMER_MS); reply("done"); break; + case 'E': + event_dispatch(); + reply("done"); + break; default: reply("Unrecognised command."); break; } + putstr("prompt> "); } - - return 0; }