summaryrefslogtreecommitdiff
path: root/digital/io/src/getsamples.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io/src/getsamples.c')
-rw-r--r--digital/io/src/getsamples.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/digital/io/src/getsamples.c b/digital/io/src/getsamples.c
index 25c166e9..10dd0840 100644
--- a/digital/io/src/getsamples.c
+++ b/digital/io/src/getsamples.c
@@ -24,6 +24,9 @@
* }}} */
#include "getsamples.h"
#include "fsm.h"
+#include "trap.h" /* trap_* */
+
+#include "io.h" /* _BV */
/**
* 'Private' get samples data used internaly by the FSM.
@@ -34,10 +37,20 @@ struct getsamples_data_t getsamples_data_;
void
getsamples_start (int16_t approach_angle, uint8_t sample_bitfield)
{
+ uint8_t count;
/* Set parameters */
getsamples_data_.approach_angle = approach_angle;
getsamples_data_.sample_bitfield = sample_bitfield;
+ /* Remove unhandled traps */
+ /* garbage */
+ getsamples_data_.sample_bitfield &= ~_BV (garbage);
+ /* Trap upper than the trap_count */
+ for (count = 7; count >= trap_count; count--)
+ {
+ getsamples_data_.sample_bitfield &= ~_BV (count);
+ }
+
/* Start the get samples FSM */
fsm_init (&getsamples_fsm);
fsm_handle_event (&getsamples_fsm, GETSAMPLES_EVENT_start);