The unified diff between revisions [253c6510..] and [65df00aa..] 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 [253c65100e2208e0b8c93178896f5aab89e4ec0b] # new_revision [65df00aa2705ce33fd74f4dd706d2879fe99b2b0] # # patch "main.c" # from [d5ad069a51eff072171a593f4f480b1e8aab11bb] # to [5c11844a2fa7481ccddb49faaace19b7c21a1c7f] # ============================================================ --- main.c d5ad069a51eff072171a593f4f480b1e8aab11bb +++ main.c 5c11844a2fa7481ccddb49faaace19b7c21a1c7f @@ -159,21 +159,44 @@ void average_sample(void) putstr(")\r\n"); } -int main(void) { - int i; +void timer_event_handler(void) +{ + wmp_start_sample(); +} +void menu_handler(void); + +int main(void) { init_interrupt(); init_uart(); init_i2c(); init_pins(); init_timer(); + + event_register(EVENT_UART_INPUT, menu_handler); + + event_register(EVENT_I2C_COMPLETE, wmp_event_handler); + + event_register(EVENT_TIMER, timer_event_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> "); - while (!getch(&c)) - FP0XVAL ^= 0x04000000; + FP0XVAL ^= 0x04000000; + event_dispatch(); + } + + return 0; +} + +void menu_handler(void) +{ + int i; + char c; + + while (getch(&c)) { if (c == 0x0a) continue; putch(c); @@ -254,18 +277,13 @@ int main(void) { break; case 'P': putstr("Initialising timer... "); - timer_set_period(10000*TIMER_MS); + timer_set_period(10*TIMER_MS); reply("done"); break; - case 'E': - event_dispatch(); - reply("done"); - break; default: reply("Unrecognised command."); break; } + putstr("prompt> "); } - - return 0; }