servo_params.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Otto-von-Guericke-Universität Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef SERVO_PARAMS_H
20 #define SERVO_PARAMS_H
21 
22 #include "board.h"
23 #include "macros/units.h"
24 #include "periph/gpio.h"
25 #include "periph/pwm.h"
26 #include "periph/timer.h"
27 #include "saul_reg.h"
28 #include "servo.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 #ifndef SERVO_PWM_PARAM_DEV
44 #define SERVO_PWM_PARAM_DEV PWM_DEV(0)
45 #endif
46 
47 #ifndef SERVO_PWM_PARAM_RES
53 #define SERVO_PWM_PARAM_RES UINT16_MAX
54 #endif
55 
56 #ifndef SERVO_PWM_PARAM_FREQ
62 #define SERVO_PWM_PARAM_FREQ 50
63 #endif
64 
65 #ifndef SERVO_PWM_PARAMS
69 #define SERVO_PWM_PARAMS {\
70  .pwm = SERVO_PWM_PARAM_DEV, \
71  .freq = SERVO_PWM_PARAM_FREQ, \
72  .res = SERVO_PWM_PARAM_RES, \
73  }
74 #endif
81 {
83 };
84 
89 #ifndef SERVO_TIMER_PARAM_DEV
95 #define SERVO_TIMER_PARAM_DEV TIMER_DEV(1)
96 #endif
97 
98 #ifndef SERVO_TIMER_PARAM_TIMER_FREQ
104 #define SERVO_TIMER_PARAM_TIMER_FREQ MHZ(1)
105 #endif
106 
107 #ifndef SERVO_TIMER_PARAM_SERVO_FREQ
113 #define SERVO_TIMER_PARAM_SERVO_FREQ 50
114 #endif
115 
116 #ifndef SERVO_TIMER_PARAM_TIMER_CTX
130 #define SERVO_TIMER_PARAM_TIMER_CTX (&servo_timer_default_ctx)
131 #endif
132 
133 #ifndef SERVO_TIMER_PARAMS
137 #define SERVO_TIMER_PARAMS {\
138  .timer = SERVO_TIMER_PARAM_DEV, \
139  .timer_freq = SERVO_TIMER_PARAM_TIMER_FREQ, \
140  .servo_freq = SERVO_TIMER_PARAM_SERVO_FREQ, \
141  .ctx = SERVO_TIMER_PARAM_TIMER_CTX, \
142  }
143 #endif
150 {
152 };
153 
158 #ifndef SERVO_PARAM_PWM_PARAMS
164 #define SERVO_PARAM_PWM_PARAMS (&servo_pwm_params[0])
165 #endif
166 
167 #ifndef SERVO_PARAM_TIMER_PARAMS
173 #define SERVO_PARAM_TIMER_PARAMS (&servo_timer_params[0])
174 #endif
175 
176 #ifndef SERVO_PARAM_PWM_CHAN
182 #define SERVO_PARAM_PWM_CHAN 0
183 #endif
184 
185 #ifndef SERVO_PARAM_TIMER_CHAN
191 #define SERVO_PARAM_TIMER_CHAN 1
192 #endif
193 
194 #ifndef SERVO_PARAM_PIN
200 #define SERVO_PARAM_PIN GPIO_UNDEF
201 #endif
202 
203 #ifndef SERVO_PARAM_MIN_US
209 #define SERVO_PARAM_MIN_US 900UL
210 #endif
211 
212 #ifndef SERVO_PARAM_MAX_US
218 #define SERVO_PARAM_MAX_US 2100UL
219 #endif
220 
221 #ifndef SERVO_PARAMS
225 #ifdef MODULE_SERVO_PWM
226 #define SERVO_PARAMS {\
227  .pwm = SERVO_PARAM_PWM_PARAMS, \
228  .min_us = SERVO_PARAM_MIN_US, \
229  .max_us = SERVO_PARAM_MAX_US, \
230  .pwm_chan = SERVO_PARAM_PWM_CHAN, \
231  }
232 #endif
233 #ifdef MODULE_SERVO_TIMER
234 #define SERVO_PARAMS {\
235  .timer = SERVO_PARAM_TIMER_PARAMS, \
236  .servo_pin = SERVO_PARAM_PIN, \
237  .min_us = SERVO_PARAM_MIN_US, \
238  .max_us = SERVO_PARAM_MAX_US, \
239  .timer_chan = SERVO_PARAM_TIMER_CHAN, \
240  }
241 #endif
242 #endif
248 static const servo_params_t servo_params[] =
249 {
250  SERVO_PARAMS
251 };
252 
253 #ifndef SERVO_SAULINFO
257 #define SERVO_SAULINFO { .name = "servo" }
258 #endif
259 
264 {
266 };
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* SERVO_PARAMS_H */
Low-level GPIO peripheral driver interface definitions.
Low-level timer peripheral driver interface definitions.
Low-level PWM peripheral driver interface definitions.
SAUL registry interface definition.
High-level driver for easy handling of servo motors.
static const servo_params_t servo_params[]
Parameters for controlling a servo.
Definition: servo_params.h:248
#define SERVO_SAULINFO
Servo SAUL info.
Definition: servo_params.h:257
#define SERVO_TIMER_PARAMS
TIMER parameters for controlling a servo.
Definition: servo_params.h:137
servo_timer_ctx_t servo_timer_default_ctx
Default servo timer context.
static const servo_pwm_params_t servo_pwm_params[]
Servo PWM parameters.
Definition: servo_params.h:80
#define SERVO_PWM_PARAMS
PWM parameters for controlling a servo.
Definition: servo_params.h:69
static const servo_timer_params_t servo_timer_params[]
Servo timer parameters.
Definition: servo_params.h:149
static const saul_reg_info_t servo_saul_info[]
Allocate and configure entries to the SAUL registry.
Definition: servo_params.h:263
Additional data to collect for each entry.
Definition: saul_reg.h:49
Configuration parameters for a servo.
Definition: servo.h:120
PWM configuration parameters for a servos.
Definition: servo.h:83
Memory needed for book keeping when using periph_timer_periodic based servo driver.
Definition: servo.h:97
Timer configuration parameters for a servos.
Definition: servo.h:110
Unit helper macros.