summaryrefslogtreecommitdiff
path: root/digital
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
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')
-rw-r--r--digital/io/src/getsamples_cb.c2
-rw-r--r--digital/io/src/gutter_cb.c2
-rw-r--r--digital/io/src/main.c15
-rw-r--r--digital/io/src/move_cb.c2
4 files changed, 13 insertions, 8 deletions
diff --git a/digital/io/src/getsamples_cb.c b/digital/io/src/getsamples_cb.c
index 48b3a520..69a886ea 100644
--- a/digital/io/src/getsamples_cb.c
+++ b/digital/io/src/getsamples_cb.c
@@ -117,7 +117,7 @@ fsm_branch_t
getsamples__CLOSE_INPUT_HOLE__arm_move_succeed (void)
{
/* Tell the top FSM we have finished */
- main_post_event_for_top_fsm = TOP_EVENT_get_samples_fsm_finished + 1;
+ main_post_event_for_top_fsm = TOP_EVENT_get_samples_fsm_finished;
return getsamples_next (CLOSE_INPUT_HOLE, arm_move_succeed);
}
diff --git a/digital/io/src/gutter_cb.c b/digital/io/src/gutter_cb.c
index 22696c20..5abf7bcb 100644
--- a/digital/io/src/gutter_cb.c
+++ b/digital/io/src/gutter_cb.c
@@ -98,6 +98,6 @@ gutter__DROP_BALLS__wait_finished (void)
/* Close the rear panel */
trap_close_rear_panel ();
/* Tell the top FSM we have finished */
- main_post_event_for_top_fsm = TOP_EVENT_gutter_fsm_finished + 1;
+ main_post_event_for_top_fsm = TOP_EVENT_gutter_fsm_finished;
return gutter_next (DROP_BALLS, wait_finished);
}
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 */
}
diff --git a/digital/io/src/move_cb.c b/digital/io/src/move_cb.c
index e7069c37..a54f9420 100644
--- a/digital/io/src/move_cb.c
+++ b/digital/io/src/move_cb.c
@@ -87,7 +87,7 @@ move__DESIRED_POSITION__blocked (void)
fsm_branch_t
move__DESIRED_POSITION__reached (void)
{
- main_post_event_for_top_fsm = TOP_EVENT_move_fsm_finished + 1;
+ main_post_event_for_top_fsm = TOP_EVENT_move_fsm_finished;
return move_next (DESIRED_POSITION, reached);
}