The friendly Operating System for the Internet of Things
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(servo_t *dev, unsigned int pos);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif /* SERVO_H */
96 
int channel
the channel the servo is connected to
Definition: servo.h:37
Low-level PWM peripheral driver interface definitions.
pwm_t device
the PWM device driving the servo
Definition: servo.h:36
Descriptor struct for a servo.
Definition: servo.h:35
unsigned int max
maximum pulse width, in us
Definition: servo.h:39
unsigned int scale_den
timing scale factor, to adjust for an inexact PWM frequency, denominator
Definition: servo.h:41
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.
unsigned int scale_nom
timing scale factor, to adjust for an inexact PWM frequency, nominator
Definition: servo.h:40
void servo_set(servo_t *dev, unsigned int pos)
Set the servo motor to a specified position.
unsigned int min
minimum pulse width, in us
Definition: servo.h:38
unsigned int pwm_t
Default PWM type definition.
Definition: pwm.h:97