servo.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  * Copyright (C) 2015 Eistec AB
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
23 #ifndef SERVO_H
24 #define SERVO_H
25 
26 #include "periph/pwm.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct {
37  int channel;
38  unsigned int min;
39  unsigned int max;
40  unsigned int scale_nom;
41  unsigned int scale_den;
42 } servo_t;
43 
73 int servo_init(servo_t *dev, pwm_t pwm, int pwm_channel, unsigned int min, unsigned int max);
74 
89 void servo_set(const servo_t *dev, unsigned int pos);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif /* SERVO_H */
96 
servo_init
int servo_init(servo_t *dev, pwm_t pwm, int pwm_channel, unsigned int min, unsigned int max)
Initialize a servo motor by assigning it a PWM device and channel.
servo_t
Descriptor struct for a servo.
Definition: servo.h:35
servo_t::min
unsigned int min
minimum pulse width, in us
Definition: servo.h:38
servo_t::channel
int channel
the channel the servo is connected to
Definition: servo.h:37
servo_set
void servo_set(const servo_t *dev, unsigned int pos)
Set the servo motor to a specified position.
servo_t::scale_den
unsigned int scale_den
timing scale factor, to adjust for an inexact PWM frequency, denominator
Definition: servo.h:41
servo_t::device
pwm_t device
the PWM device driving the servo
Definition: servo.h:36
servo_t::max
unsigned int max
maximum pulse width, in us
Definition: servo.h:39
servo_t::scale_nom
unsigned int scale_nom
timing scale factor, to adjust for an inexact PWM frequency, nominator
Definition: servo.h:40
pwm.h
Low-level PWM peripheral driver interface definitions.
pwm_t
unsigned int pwm_t
Default PWM type definition.
Definition: pwm.h:92