summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Dufour2008-03-22 16:17:43 +0100
committerJérémy Dufour2008-03-22 16:17:43 +0100
commit66f04f914d617be8e8c5178cab0c965017db1ea1 (patch)
treeaa1efaf7f60e73c9fda6bdd301d90c12c8f37189
parentb6e28f0de9c2f02fe2cb5c3f8244f6b2199673b9 (diff)
* digital/io/src
- compute the number of TIC of a servos update cycle (rather than using a pre-defined one).
-rw-r--r--digital/io/src/servo.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/digital/io/src/servo.c b/digital/io/src/servo.c
index 19f97a63..0051fac5 100644
--- a/digital/io/src/servo.c
+++ b/digital/io/src/servo.c
@@ -51,9 +51,10 @@
* whole cycle to last.
* The formula used is:
* time_of_a_cycle * AVR_frequency / timer_counter_prescaler
- * We want a time of 20ms.
+ * We want a time of 20ms (20/1000).
+ * See @a servo_init to know the prescaler value of the timer/counter.
*/
-#define SERVO_TIC_CYCLE 1152
+static const uint16_t servo_tic_cyle_ = ((20/1000) * AC_FREQ / 256);
/** @} */
@@ -134,7 +135,7 @@ SIGNAL (SIG_OVERFLOW2)
overflow */
static int8_t servo_overflow_count = -1;
/* Time spent by each servo motor at high state during a whole cycle */
- static uint16_t servo_high_time_cycle = SERVO_TIC_CYCLE;
+ static uint16_t servo_high_time_cycle = servo_tic_cyle_;
/* State machine actions */
switch (servo_updating_id_)
@@ -190,7 +191,7 @@ SIGNAL (SIG_OVERFLOW2)
servo_updating_id_ = 0;
/* Re-initialize the counter of time spent by each servo motor
* at high state */
- servo_high_time_cycle = SERVO_TIC_CYCLE;
+ servo_high_time_cycle = servo_tic_cyle_;
}
}
break;