summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/getsamples.c
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-28 13:33:52 +0200
committerJérémy Dufour2008-04-28 13:33:52 +0200
commit5ef11e951e6b056aee44d64d5c1b9451b0753997 (patch)
tree2da0f2f038ae9929b055cdaf1fd14efd64c2e5fb /digital/io/src/getsamples.c
parentdbe02fe3879d5d09ff68643438ac894156de2670 (diff)
* digital/io/src
- add protection in get samples against 'stupid' parameter for the bitfield value.
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);