summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/main.c
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-25 00:20:37 +0200
committerJérémy Dufour2008-04-25 00:20:37 +0200
commit82d914b99afc71562d6fa36bcc98528947657e37 (patch)
treef5b1032f8bed5ee8d8a9c0c19bcb905cb0fb6488 /digital/io/src/main.c
parent4d88c551ef61836af59f86ca1dd41c47ed2ead9a (diff)
* 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).
Diffstat (limited to 'digital/io/src/main.c')
-rw-r--r--digital/io/src/main.c15
1 files changed, 10 insertions, 5 deletions
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 */
}