Loading...
Searching...
No Matches
servo_params.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Otto-von-Guericke-Universität Magdeburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "board.h"
19#include "macros/units.h"
20#include "periph/gpio.h"
21#include "periph/pwm.h"
22#include "periph/timer.h"
23#include "saul_reg.h"
24#include "servo.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34#ifndef SERVO_PWM_PARAM_DEV
40#define SERVO_PWM_PARAM_DEV PWM_DEV(0)
41#endif
42
43#ifndef SERVO_PWM_PARAM_RES
49#define SERVO_PWM_PARAM_RES UINT16_MAX
50#endif
51
52#ifndef SERVO_PWM_PARAM_FREQ
58#define SERVO_PWM_PARAM_FREQ 50
59#endif
60
61#ifndef SERVO_PWM_PARAMS
65#define SERVO_PWM_PARAMS {\
66 .pwm = SERVO_PWM_PARAM_DEV, \
67 .freq = SERVO_PWM_PARAM_FREQ, \
68 .res = SERVO_PWM_PARAM_RES, \
69 }
70#endif
72
80
85#ifndef SERVO_TIMER_PARAM_DEV
91#define SERVO_TIMER_PARAM_DEV TIMER_DEV(1)
92#endif
93
94#ifndef SERVO_TIMER_PARAM_TIMER_FREQ
100#define SERVO_TIMER_PARAM_TIMER_FREQ MHZ(1)
101#endif
102
103#ifndef SERVO_TIMER_PARAM_SERVO_FREQ
109#define SERVO_TIMER_PARAM_SERVO_FREQ 50
110#endif
111
112#ifndef SERVO_TIMER_PARAM_TIMER_CTX
126#define SERVO_TIMER_PARAM_TIMER_CTX (&servo_timer_default_ctx)
127#endif
128
129#ifndef SERVO_TIMER_PARAMS
133#define SERVO_TIMER_PARAMS {\
134 .timer = SERVO_TIMER_PARAM_DEV, \
135 .timer_freq = SERVO_TIMER_PARAM_TIMER_FREQ, \
136 .servo_freq = SERVO_TIMER_PARAM_SERVO_FREQ, \
137 .ctx = SERVO_TIMER_PARAM_TIMER_CTX, \
138 }
139#endif
141
149
154#ifndef SERVO_PARAM_PWM_PARAMS
160#define SERVO_PARAM_PWM_PARAMS (&servo_pwm_params[0])
161#endif
162
163#ifndef SERVO_PARAM_TIMER_PARAMS
169#define SERVO_PARAM_TIMER_PARAMS (&servo_timer_params[0])
170#endif
171
172#ifndef SERVO_PARAM_PWM_CHAN
178#define SERVO_PARAM_PWM_CHAN 0
179#endif
180
181#ifndef SERVO_PARAM_TIMER_CHAN
187#define SERVO_PARAM_TIMER_CHAN 1
188#endif
189
190#ifndef SERVO_PARAM_PIN
196#define SERVO_PARAM_PIN GPIO_UNDEF
197#endif
198
199#ifndef SERVO_PARAM_MIN_US
205#define SERVO_PARAM_MIN_US 900UL
206#endif
207
208#ifndef SERVO_PARAM_MAX_US
214#define SERVO_PARAM_MAX_US 2100UL
215#endif
216
217#ifndef SERVO_PARAMS
221#ifdef MODULE_SERVO_PWM
222#define SERVO_PARAMS {\
223 .pwm = SERVO_PARAM_PWM_PARAMS, \
224 .min_us = SERVO_PARAM_MIN_US, \
225 .max_us = SERVO_PARAM_MAX_US, \
226 .pwm_chan = SERVO_PARAM_PWM_CHAN, \
227 }
228#endif
229#ifdef MODULE_SERVO_TIMER
230#define SERVO_PARAMS {\
231 .timer = SERVO_PARAM_TIMER_PARAMS, \
232 .servo_pin = SERVO_PARAM_PIN, \
233 .min_us = SERVO_PARAM_MIN_US, \
234 .max_us = SERVO_PARAM_MAX_US, \
235 .timer_chan = SERVO_PARAM_TIMER_CHAN, \
236 }
237#endif
238#endif
240
245{
246 SERVO_PARAMS
247};
248
249#ifndef SERVO_SAULINFO
253#define SERVO_SAULINFO { .name = "servo" }
254#endif
255
260{
262};
263
264#ifdef __cplusplus
265}
266#endif
267
Low-level timer peripheral driver interface definitions.
Low-level GPIO peripheral driver interface definitions.
servo_timer_ctx_t servo_timer_default_ctx
Default timer context.
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.
#define SERVO_SAULINFO
Servo SAUL info.
#define SERVO_TIMER_PARAMS
TIMER parameters for controlling a servo.
static const servo_pwm_params_t servo_pwm_params[]
Servo PWM parameters.
#define SERVO_PWM_PARAMS
PWM parameters for controlling a servo.
static const servo_timer_params_t servo_timer_params[]
Servo timer parameters.
static const saul_reg_info_t servo_saul_info[]
Allocate and configure entries to the SAUL registry.
Additional data to collect for each entry.
Definition saul_reg.h:48
Configuration parameters for a servo.
Definition servo.h:119
PWM configuration parameters for a servos.
Definition servo.h:82
Memory needed for book keeping when using periph_timer_periodic based servo driver.
Definition servo.h:96
Timer configuration parameters for a servos.
Definition servo.h:109
Unit helper macros.