From 82d914b99afc71562d6fa36bcc98528947657e37 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Fri, 25 Apr 2008 00:20:37 +0200 Subject: * digital/io/src - ensure event is reset after being posted ; - use 0xFF value for not an event rather than 0 (it prevents the dirty fix to add 1 to the event). --- digital/io/src/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'digital/io/src/main.c') diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 0baf8738..d768836e 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -66,7 +66,7 @@ enum team_color_e bot_color; /** * Post a event to the top FSM in the next iteration of main loop. */ -uint8_t main_post_event_for_top_fsm; +uint8_t main_post_event_for_top_fsm = 0xFF; /** * Initialize the main and all its subsystems. @@ -203,12 +203,17 @@ main_loop (void) FSM_HANDLE_EVENT (&gutter_fsm, GUTTER_EVENT_wait_finished); } /* Event generated at the end of the sub FSM to post to the top FSM */ - if (main_post_event_for_top_fsm) + if (main_post_event_for_top_fsm != 0xFF) { - /* Post the event */ - FSM_HANDLE_EVENT (&top_fsm, main_post_event_for_top_fsm - 1); + /* We must post the event at the end of this block because it + * will issue a continue and every instruction after will + * never be executed. */ + /* We need to save the event before reseting it */ + uint8_t save_event = main_post_event_for_top_fsm; /* Reset */ - main_post_event_for_top_fsm = 0; + main_post_event_for_top_fsm = 0xFF; + /* Post the event */ + FSM_HANDLE_EVENT (&top_fsm, save_event); } /* TODO: Check other sensors */ } -- cgit v1.2.3