From 4d88c551ef61836af59f86ca1dd41c47ed2ead9a Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Thu, 24 Apr 2008 23:47:40 +0200 Subject: * digital/io/src - when a sub FSM finished, it posts an event for the top FSM which will be notified in the next main loop iteration (rather than the actual one). --- digital/io/src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'digital/io/src/main.c') diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 81928cd6..0baf8738 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -63,6 +63,11 @@ static void main_loop (void); */ 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; + /** * Initialize the main and all its subsystems. */ @@ -197,6 +202,14 @@ 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) + { + /* Post the event */ + FSM_HANDLE_EVENT (&top_fsm, main_post_event_for_top_fsm - 1); + /* Reset */ + main_post_event_for_top_fsm = 0; + } /* TODO: Check other sensors */ } } -- cgit v1.2.3