Add reset function to servo.

This will be used with clock sanity checking.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-10-22 18:57:14 +02:00 committed by Richard Cochran
parent 25cf96d4ca
commit cc7be3fc67
4 changed files with 21 additions and 0 deletions

8
pi.c
View File

@ -171,6 +171,13 @@ static void pi_sync_interval(struct servo *servo, double interval)
interval, s->kp, s->ki); interval, s->kp, s->ki);
} }
static void pi_reset(struct servo *servo)
{
struct pi_servo *s = container_of(servo, struct pi_servo, servo);
s->count = 0;
}
struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts) struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts)
{ {
struct pi_servo *s; struct pi_servo *s;
@ -182,6 +189,7 @@ struct servo *pi_servo_create(int fadj, int max_ppb, int sw_ts)
s->servo.destroy = pi_destroy; s->servo.destroy = pi_destroy;
s->servo.sample = pi_sample; s->servo.sample = pi_sample;
s->servo.sync_interval = pi_sync_interval; s->servo.sync_interval = pi_sync_interval;
s->servo.reset = pi_reset;
s->drift = fadj; s->drift = fadj;
s->maxppb = max_ppb; s->maxppb = max_ppb;
s->first_update = 1; s->first_update = 1;

View File

@ -46,3 +46,8 @@ void servo_sync_interval(struct servo *servo, double interval)
{ {
servo->sync_interval(servo, interval); servo->sync_interval(servo, interval);
} }
void servo_reset(struct servo *servo)
{
servo->reset(servo);
}

View File

@ -93,4 +93,10 @@ double servo_sample(struct servo *servo,
*/ */
void servo_sync_interval(struct servo *servo, double interval); void servo_sync_interval(struct servo *servo, double interval);
/**
* Reset a clock servo.
* @param servo Pointer to a servo obtained via @ref servo_create().
*/
void servo_reset(struct servo *servo);
#endif #endif

View File

@ -30,6 +30,8 @@ struct servo {
enum servo_state *state); enum servo_state *state);
void (*sync_interval)(struct servo *servo, double interval); void (*sync_interval)(struct servo *servo, double interval);
void (*reset)(struct servo *servo);
}; };
#endif #endif