inc_encoder_params.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2025 TU Dresden
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 #include "board.h"
19 #include "inc_encoder.h"
20 #include "saul_reg.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 #ifndef CONFIG_INC_ENCODER_GEAR_RED_RATIO
30 # define CONFIG_INC_ENCODER_GEAR_RED_RATIO 204
31 #endif
32 
36 #ifndef CONFIG_INC_ENCODER_PPR
37 # define CONFIG_INC_ENCODER_PPR 13
38 #endif
39 
43 #if IS_USED(MODULE_INC_ENCODER_HARDWARE)
44 # ifndef CONFIG_INC_ENCODER_HARDWARE_PERIOD_MS
45 # define CONFIG_INC_ENCODER_HARDWARE_PERIOD_MS 200
46 # endif
47 #endif
48 
53 #if IS_USED(MODULE_INC_ENCODER_SOFTWARE)
57 # ifndef INC_ENCODER_INTERRUPT
58 # define INC_ENCODER_INTERRUPT GPIO_PIN(1, 10)
59 # endif
60 
65 # ifndef INC_ENCODER_DIRECTION
66 # define INC_ENCODER_DIRECTION GPIO_PIN(1, 11)
67 # endif
68 #endif /* IS_USED(MODULE_INC_ENCODER_SOFTWARE) */
69 
70 #if IS_USED(MODULE_INC_ENCODER_HARDWARE)
74 #ifndef INC_ENCODER_QDEC_DEV
75 # define INC_ENCODER_QDEC_DEV QDEC_DEV(0)
76 #endif
77 #endif /* IS_USED(MODULE_INC_ENCODER_HARDWARE) */
78 
82 #if IS_USED(MODULE_INC_ENCODER_SOFTWARE)
83 # ifndef INC_ENCODER_PARAMS
84 # define INC_ENCODER_PARAMS { .interrupt = INC_ENCODER_INTERRUPT, \
85  .direction = INC_ENCODER_DIRECTION }
86 # endif
87 #elif IS_USED(MODULE_INC_ENCODER_HARDWARE)
88 
89 # ifndef INC_ENCODER_PARAMS
90 # define INC_ENCODER_PARAMS { .qdec_dev = INC_ENCODER_QDEC_DEV }
91 # endif
92 #endif
98 #ifndef INC_ENCODER_SAUL_INFO
99 # define INC_ENCODER_SAUL_INFO { { .name = "Incremental Rotary Encoder RPM Sensor" }, \
100  { .name = "Incremental Rotary Encoder Pulse Count Sensor" } }
101 #endif
102 
107 {
108  INC_ENCODER_PARAMS
109 };
110 
115 {
117 };
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
#define INC_ENCODER_SAUL_INFO
Default parameters.
static const saul_reg_info_t inc_encoder_saul_info[][2]
Additional meta information to keep in the SAUL registry.
static const inc_encoder_params_t inc_encoder_params[]
Incremental rotary encoder configuration.
SAUL registry interface definition.
Device initialization parameters.
Definition: inc_encoder.h:101
Additional data to collect for each entry.
Definition: saul_reg.h:48