From ab29608e0b351a03c4bf07c39c76a5901981c58c Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 14 Jan 2013 17:09:09 +0100 Subject: [PATCH] Modify servo_sample() to accept integer values. Current date stored in nanoseconds doesn't fit in 64-bit double format. Keep the offset and the time stamp in integer nanoseconds. Signed-off-by: Miroslav Lichvar --- pi.c | 8 ++++---- servo.c | 4 ++-- servo.h | 6 ++++-- servo_private.h | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pi.c b/pi.c index 9b3b09e..5fbce38 100644 --- a/pi.c +++ b/pi.c @@ -38,8 +38,8 @@ double configured_pi_offset = 0.0; struct pi_servo { struct servo servo; - double offset[2]; - double local[2]; + int64_t offset[2]; + uint64_t local[2]; double drift; double maxppb; double kp; @@ -55,8 +55,8 @@ static void pi_destroy(struct servo *servo) } static double pi_sample(struct servo *servo, - double offset, - double local_ts, + int64_t offset, + uint64_t local_ts, enum servo_state *state) { double ki_term, ppb = 0.0; diff --git a/servo.c b/servo.c index 97c2e60..a312ad1 100644 --- a/servo.c +++ b/servo.c @@ -35,8 +35,8 @@ void servo_destroy(struct servo *servo) } double servo_sample(struct servo *servo, - double offset, - double local_ts, + int64_t offset, + uint64_t local_ts, enum servo_state *state) { return servo->sample(servo, offset, local_ts, state); diff --git a/servo.h b/servo.h index 0d2ab71..4d4a8e7 100644 --- a/servo.h +++ b/servo.h @@ -20,6 +20,8 @@ #ifndef HAVE_SERVO_H #define HAVE_SERVO_H +#include + /** Opaque type */ struct servo; @@ -80,8 +82,8 @@ void servo_destroy(struct servo *servo); * @return The clock adjustment in parts per billion. */ double servo_sample(struct servo *servo, - double offset, - double local_ts, + int64_t offset, + uint64_t local_ts, enum servo_state *state); #endif diff --git a/servo_private.h b/servo_private.h index 2c710e5..f9c151f 100644 --- a/servo_private.h +++ b/servo_private.h @@ -26,7 +26,7 @@ struct servo { void (*destroy)(struct servo *servo); double (*sample)(struct servo *servo, - double offset, double local_ts, + int64_t offset, uint64_t local_ts, enum servo_state *state); };