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 <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-01-14 17:09:09 +01:00 committed by Richard Cochran
parent 8a23bf1d66
commit ab29608e0b
4 changed files with 11 additions and 9 deletions

8
pi.c
View File

@ -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;

View File

@ -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);

View File

@ -20,6 +20,8 @@
#ifndef HAVE_SERVO_H
#define HAVE_SERVO_H
#include <stdint.h>
/** 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

View File

@ -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);
};