From 895382110b97cde108df418a888a70fe3f40639a Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Sun, 20 Apr 2008 19:54:48 +0200 Subject: * digital/io/src - keep structure removed from r384. --- digital/io/src/getsamples.c | 13 ++++--------- digital/io/src/getsamples.h | 21 +++++++++++++++++++++ digital/io/src/getsamples_cb.c | 17 ++++++----------- 3 files changed, 31 insertions(+), 20 deletions(-) (limited to 'digital/io') diff --git a/digital/io/src/getsamples.c b/digital/io/src/getsamples.c index 17dee9e8..25c166e9 100644 --- a/digital/io/src/getsamples.c +++ b/digital/io/src/getsamples.c @@ -26,22 +26,17 @@ #include "fsm.h" /** - * The approach angle to face the distributor. + * 'Private' get samples data used internaly by the FSM. */ -int16_t approach_angle_; - -/** - * The samples bit field to collect. - */ -uint8_t sample_bitfield_; +struct getsamples_data_t getsamples_data_; /* Start the get samples FSM. */ void getsamples_start (int16_t approach_angle, uint8_t sample_bitfield) { /* Set parameters */ - approach_angle_ = approach_angle; - sample_bitfield_ = sample_bitfield; + getsamples_data_.approach_angle = approach_angle; + getsamples_data_.sample_bitfield = sample_bitfield; /* Start the get samples FSM */ fsm_init (&getsamples_fsm); diff --git a/digital/io/src/getsamples.h b/digital/io/src/getsamples.h index e24056e2..70a76696 100644 --- a/digital/io/src/getsamples.h +++ b/digital/io/src/getsamples.h @@ -27,6 +27,27 @@ #include "common.h" +/** + * Get samples FSM associated data. + */ +struct getsamples_data_t +{ + /** + * The angle to approach to face the distributor. + */ + int16_t approach_angle; + /** + * 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. + */ + uint8_t sample_bitfield; +}; + + /** * Start the get samples FSM. * @param approach_angle the angle of approach to face the distributor diff --git a/digital/io/src/getsamples_cb.c b/digital/io/src/getsamples_cb.c index 22fdc959..3ade76a7 100644 --- a/digital/io/src/getsamples_cb.c +++ b/digital/io/src/getsamples_cb.c @@ -36,14 +36,9 @@ #include "io.h" /** - * The approach angle to face the distributor. + * 'Private' get samples data used internaly by the FSM. */ -extern int16_t approach_angle_; - -/** - * The samples bit field to collect. - */ -extern uint8_t sample_bitfield_; +extern struct getsamples_data_t getsamples_data_; /** * Configure the classifier (using the trap and the internal bit field) for @@ -63,12 +58,12 @@ getsamples_configure_classifier (void) for (trap_num = 0; trap_num < trap_count; trap_num++) { /* Is the bit set? */ - if (bit_is_set (sample_bitfield_, trap_num)) + if (bit_is_set (getsamples_data_.sample_bitfield, trap_num)) { /* Configure the classifier */ trap_setup_path_to_box (trap_num); /* Reset this bit */ - sample_bitfield_ &= ~_BV (trap_num); + getsamples_data_.sample_bitfield &= ~_BV (trap_num); /* Stop here */ return; } @@ -126,7 +121,7 @@ fsm_branch_t getsamples__TAKE_SAMPLES__arm_pass_noted_position (void) { /* More samples? */ - if (sample_bitfield_) + if (getsamples_data_.sample_bitfield) { /* Compute notifier */ uint16_t arm_current_position = asserv_get_arm_position (); @@ -157,7 +152,7 @@ fsm_branch_t getsamples__IDLE__start (void) { /* Face the distributor */ - asserv_goto_angle (approach_angle_); + asserv_goto_angle (getsamples_data_.approach_angle); return getsamples_next (IDLE, start); } -- cgit v1.2.3