summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-20 16:04:44 +0200
committerJérémy Dufour2008-04-20 16:04:44 +0200
commit74e1ec414baeb80a37be3bc922a958aad60bb8e9 (patch)
tree29f8a2ef415bd8c59edceeecad5eb927ad9381ef /digital
parenta40c4ce480ae17fe63459865821eb713333e4536 (diff)
* digital/io/src
- use parameters to call the get samples FSM start function rather than a structure.
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/getsamples.c19
-rw-r--r--digital/io/src/getsamples.h26
-rw-r--r--digital/io/src/getsamples_cb.c13
-rw-r--r--digital/io/src/top_cb.c15
4 files changed, 31 insertions, 42 deletions
diff --git a/digital/io/src/getsamples.c b/digital/io/src/getsamples.c
index 8cff594e..03ce8982 100644
--- a/digital/io/src/getsamples.c
+++ b/digital/io/src/getsamples.c
@@ -30,17 +30,22 @@
#include "io.h"
/**
- * Get samples shared data.
+ * The approach angle to face the distributor.
*/
-struct getsamples_data_t getsamples_data_;
+int16_t approach_angle_;
+
+/**
+ * The samples bit field to collect.
+ */
+uint8_t sample_bitfield_;
/* Start the get samples FSM. */
void
-getsamples_start (struct getsamples_data_t data)
+getsamples_start (int16_t approach_angle, uint8_t sample_bitfield)
{
/* Set parameters */
- getsamples_data_.approach_angle = data.approach_angle;
- getsamples_data_.sample_bitfield = data.sample_bitfield;
+ approach_angle_ = approach_angle;
+ sample_bitfield_ = sample_bitfield;
/* Start the get samples FSM */
fsm_init (&getsamples_fsm);
@@ -56,12 +61,12 @@ getsamples_configure_classifier (void)
for (trap_num = 0; trap_num < trap_count; trap_num++)
{
/* Is the bit set? */
- if (bit_is_set (getsamples_data_.sample_bitfield, trap_num))
+ if (bit_is_set (sample_bitfield_, trap_num))
{
/* Configure the classifier */
trap_setup_path_to_box (trap_num);
/* Reset this bit */
- getsamples_data_.sample_bitfield &= ~_BV (trap_num);
+ sample_bitfield_ &= ~_BV (trap_num);
/* Stop here */
return;
}
diff --git a/digital/io/src/getsamples.h b/digital/io/src/getsamples.h
index 81d5ca6a..bf127d29 100644
--- a/digital/io/src/getsamples.h
+++ b/digital/io/src/getsamples.h
@@ -26,28 +26,16 @@
* }}} */
/**
- * Get samples FSM associated data.
- */
-struct getsamples_data_t
-{
- /**
- * The angle to approach the distributor.
- */
- int16_t approach_angle;
- /**
- * Bit field to indicate where to put the sample.
- * If bit 0 is set to 1, a sample will be put into the out_right_box. If
- * set to 0, the out_right_box will not be used to store a sample.
- */
- uint8_t sample_bitfield;
-};
-
-/**
* Start the get samples FSM.
- * @param data get sample data initial configuration.
+ * @param approach_angle the angle of approach to face the distributor
+ * @param sample_bitfield a bit-field to indicate where to put the collected
+ * samples. For example, if the bit 0 is set to 1, the sample took will be put
+ * into the box id 0 (out_right_box). Otherwise, if this bit is set to 0, the
+ * out_right box will not be use to store the sample. This parameter is also
+ * used to know the number of samples to collect from the distributor.
*/
void
-getsamples_start (struct getsamples_data_t data);
+getsamples_start (int16_t approach_angle, uint8_t sample_bitfield);
/**
* Configure the classifier (using the trap and the internal bit field) for
diff --git a/digital/io/src/getsamples_cb.c b/digital/io/src/getsamples_cb.c
index 8f7abefb..e60bf2f8 100644
--- a/digital/io/src/getsamples_cb.c
+++ b/digital/io/src/getsamples_cb.c
@@ -34,9 +34,14 @@
#include "playground.h" /* PG_* */
/**
- * Get samples shared data.
+ * The approach angle to face the distributor.
*/
-extern struct getsamples_data_t getsamples_data_;
+extern int16_t approach_angle_;
+
+/**
+ * The samples bit field to collect.
+ */
+extern uint8_t sample_bitfield_;
/*
* FACE_DISTRIBUTOR =bot_move_succeed=>
@@ -89,7 +94,7 @@ fsm_branch_t
getsamples__TAKE_SAMPLES__arm_pass_noted_position (void)
{
/* More samples? */
- if (getsamples_data_.sample_bitfield)
+ if (sample_bitfield_)
{
/* Compute notifier */
uint16_t arm_current_position = asserv_get_arm_position ();
@@ -120,7 +125,7 @@ fsm_branch_t
getsamples__IDLE__start (void)
{
/* Face the distributor */
- asserv_goto_angle (getsamples_data_.approach_angle);
+ asserv_goto_angle (approach_angle_);
return getsamples_next (IDLE, start);
}
diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c
index c1624569..7935beed 100644
--- a/digital/io/src/top_cb.c
+++ b/digital/io/src/top_cb.c
@@ -102,11 +102,8 @@ fsm_branch_t
top__GO_TO_ADVERSE_ICE_DISTRIBUTOR__move_fsm_finished (void)
{
/* Start the get samples FSM with the correct angle */
- struct getsamples_data_t data;
/* TODO: where to put the ice?! */
- data.sample_bitfield = 0;
- data.approach_angle = PG_DISTRIBUTOR_ICE_ADVERSE_A;
- getsamples_start (data);
+ getsamples_start (PG_DISTRIBUTOR_ICE_ADVERSE_A, 0);
return top_next (GO_TO_ADVERSE_ICE_DISTRIBUTOR, move_fsm_finished);
}
@@ -119,11 +116,8 @@ fsm_branch_t
top__GO_TO_OUR_ICE_DISTRIBUTOR__move_fsm_finished (void)
{
/* Start the get samples FSM with the correct angle */
- struct getsamples_data_t data;
/* TODO: where to put the ice?! */
- data.sample_bitfield = 0;
- data.approach_angle = PG_DISTRIBUTOR_ICE_OUR_A;
- getsamples_start (data);
+ getsamples_start (PG_DISTRIBUTOR_ICE_OUR_A, 0);
return top_next (GO_TO_OUR_ICE_DISTRIBUTOR, move_fsm_finished);
}
@@ -136,11 +130,8 @@ fsm_branch_t
top__GO_TO_SAMPLE_DISTRIBUTOR__move_fsm_finished (void)
{
/* Start the get samples FSM with the correct angle */
- struct getsamples_data_t data;
/* TODO: where to put the samples?! */
- data.sample_bitfield = 0;
- data.approach_angle = PG_DISTRIBUTOR_SAMPLE_OUR_A;
- getsamples_start (data);
+ getsamples_start (PG_DISTRIBUTOR_SAMPLE_OUR_A, 0);
return top_next (GO_TO_SAMPLE_DISTRIBUTOR, move_fsm_finished);
}