Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
actuators_dshot_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
30 #include "mcu_periph/ram_arch.h"
31 #include "mcu_periph/gpio.h"
32 #include BOARD_CONFIG
33 
35 
36 #if DSHOT_CONF_TIM1
37 static DSHOTDriver DSHOTD1;
38 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot1DmaBuffer);
39 static DSHOTConfig dshotcfg1 = DSHOT_CONF1_DEF;
40 #endif
41 #if DSHOT_CONF_TIM2
42 static DSHOTDriver DSHOTD2;
43 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot2DmaBuffer);
44 static DSHOTConfig dshotcfg2 = DSHOT_CONF2_DEF;
45 #endif
46 #if DSHOT_CONF_TIM3
47 static DSHOTDriver DSHOTD3;
48 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot3DmaBuffer);
49 static DSHOTConfig dshotcfg3 = DSHOT_CONF3_DEF;
50 #endif
51 #if DSHOT_CONF_TIM4
52 static DSHOTDriver DSHOTD4;
53 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot4DmaBuffer);
54 static DSHOTConfig dshotcfg4 = DSHOT_CONF4_DEF;
55 #endif
56 #if DSHOT_CONF_TIM5
57 static DSHOTDriver DSHOTD5;
58 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot5DmaBuffer);
59 static DSHOTConfig dshotcfg5 = DSHOT_CONF5_DEF;
60 #endif
61 #if DSHOT_CONF_TIM8
62 static DSHOTDriver DSHOTD8;
63 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot8DmaBuffer);
64 static DSHOTConfig dshotcfg8 = DSHOT_CONF8_DEF;
65 #endif
66 #if DSHOT_CONF_TIM9
67 static DSHOTDriver DSHOTD9;
68 static IN_DMA_SECTION_NOINIT(DshotDmaBuffer dshot9DmaBuffer);
69 static DSHOTConfig dshotcfg9 = DSHOT_CONF9_DEF;
70 #endif
71 
72 
74 {
75  /*----------------
76  * Configure GPIO
77  *----------------*/
78 #ifdef DSHOT_SERVO_0
80 #endif
81 #ifdef DSHOT_SERVO_1
83 #endif
84 #ifdef DSHOT_SERVO_2
86 #endif
87 #ifdef DSHOT_SERVO_3
89 #endif
90 #ifdef DSHOT_SERVO_4
92 #endif
93 #ifdef DSHOT_SERVO_5
95 #endif
96 #ifdef DSHOT_SERVO_6
97  gpio_setup_pin_af(DSHOT_SERVO_6_GPIO, DSHOT_SERVO_6_PIN, DSHOT_SERVO_6_AF, true);
98 #endif
99 #ifdef DSHOT_SERVO_7
101 #endif
102 #ifdef DSHOT_SERVO_8
104 #endif
105 #ifdef DSHOT_SERVO_9
107 #endif
108 #ifdef DSHOT_SERVO_10
110 #endif
111 #ifdef DSHOT_SERVO_11
112  gpio_setup_pin_af(DSHOT_SERVO_11_GPIO, DSHOT_SERVO_11_PIN, DSHOT_SERVO_11_AF, true);
113 #endif
114 
115  /*---------------
116  * Configure DSHOT
117  *---------------*/
118 #if DSHOT_CONF_TIM1
119  dshotStart(&DSHOTD1, &dshotcfg1);
120 #endif
121 #if DSHOT_CONF_TIM2
122  dshotStart(&DSHOTD2, &dshotcfg2);
123 #endif
124 #if DSHOT_CONF_TIM3
125  dshotStart(&DSHOTD3, &dshotcfg3);
126 #endif
127 #if DSHOT_CONF_TIM4
128  dshotStart(&DSHOTD4, &dshotcfg4);
129 #endif
130 #if DSHOT_CONF_TIM5
131  dshotStart(&DSHOTD5, &dshotcfg5);
132 #endif
133 #if DSHOT_CONF_TIM8
134  dshotStart(&DSHOTD8, &dshotcfg8);
135 #endif
136 #if DSHOT_CONF_TIM9
137  dshotStart(&DSHOTD9, &dshotcfg9);
138 #endif
139 }
140 
141 
143 {
144 #ifdef DSHOT_SERVO_0
146 #endif
147 #ifdef DSHOT_SERVO_1
149 #endif
150 #ifdef DSHOT_SERVO_2
152 #endif
153 #ifdef DSHOT_SERVO_3
155 #endif
156 #ifdef DSHOT_SERVO_4
158 #endif
159 #ifdef DSHOT_SERVO_5
161 #endif
162 #ifdef DSHOT_SERVO_6
163  dshotSetThrottle(&DSHOT_SERVO_6_DRIVER, DSHOT_SERVO_6_CHANNEL, actuators_dshot_values[DSHOT_SERVO_6]);
164 #endif
165 #ifdef DSHOT_SERVO_7
167 #endif
168 #ifdef DSHOT_SERVO_8
170 #endif
171 #ifdef DSHOT_SERVO_9
173 #endif
174 #ifdef DSHOT_SERVO_10
176 #endif
177 #ifdef DSHOT_SERVO_11
178  dshotSetThrottle(&DSHOT_SERVO_11_DRIVER, DSHOT_SERVO_11_CHANNEL, actuators_dshot_values[DSHOT_SERVO_11]);
179 #endif
180 
181 #if DSHOT_CONF_TIM1
182  dshotSendFrame(&DSHOTD1);
183 #endif
184 #if DSHOT_CONF_TIM2
185  dshotSendFrame(&DSHOTD2);
186 #endif
187 #if DSHOT_CONF_TIM3
188  dshotSendFrame(&DSHOTD3);
189 #endif
190 #if DSHOT_CONF_TIM4
191  dshotSendFrame(&DSHOTD4);
192 #endif
193 #if DSHOT_CONF_TIM5
194  dshotSendFrame(&DSHOTD5);
195 #endif
196 #if DSHOT_CONF_TIM8
197  dshotSendFrame(&DSHOTD8);
198 #endif
199 #if DSHOT_CONF_TIM9
200  dshotSendFrame(&DSHOTD9);
201 #endif
202 }
DSHOT_SERVO_5_PIN
#define DSHOT_SERVO_5_PIN
Definition: board.h:382
uint16_t
unsigned short uint16_t
Definition: types.h:16
DSHOT_SERVO_2_CHANNEL
#define DSHOT_SERVO_2_CHANNEL
Definition: board.h:412
DSHOT_SERVO_10_AF
#define DSHOT_SERVO_10_AF
Definition: matekF765-WING.h:426
DSHOT_CONF4_DEF
#define DSHOT_CONF4_DEF
Definition: matekF765-WING.h:431
DSHOT_SERVO_0_DRIVER
#define DSHOT_SERVO_0_DRIVER
Definition: board.h:404
DSHOT_SERVO_9_AF
#define DSHOT_SERVO_9_AF
Definition: matekF765-WING.h:419
DSHOT_SERVO_7_DRIVER
#define DSHOT_SERVO_7_DRIVER
Definition: matekF765-WING.h:406
DSHOT_SERVO_0
#define DSHOT_SERVO_0
Definition: board.h:400
DSHOT_SERVO_3
#define DSHOT_SERVO_3
Definition: board.h:414
DSHOT_SERVO_1_AF
#define DSHOT_SERVO_1_AF
Definition: board.h:369
DSHOT_SERVO_0_CHANNEL
#define DSHOT_SERVO_0_CHANNEL
Definition: board.h:405
DSHOT_SERVO_7_PIN
#define DSHOT_SERVO_7_PIN
Definition: matekF765-WING.h:404
dshotSetThrottle
void dshotSetThrottle(DSHOTDriver *driver, const uint8_t index, const uint16_t throttle)
prepare throttle order for specified ESC
Definition: esc_dshot.c:210
DSHOT_SERVO_1_CHANNEL
#define DSHOT_SERVO_1_CHANNEL
Definition: board.h:371
DSHOT_SERVO_9_DRIVER
#define DSHOT_SERVO_9_DRIVER
Definition: matekF765-WING.h:420
DSHOT_SERVO_2_AF
#define DSHOT_SERVO_2_AF
Definition: board.h:410
DSHOT_SERVO_1_DRIVER
#define DSHOT_SERVO_1_DRIVER
Definition: board.h:370
DSHOT_SERVO_4_CHANNEL
#define DSHOT_SERVO_4_CHANNEL
Definition: board.h:378
DSHOT_SERVO_0_GPIO
#define DSHOT_SERVO_0_GPIO
Definition: board.h:401
actuators_dshot_values
uint16_t actuators_dshot_values[ACTUATORS_DSHOT_NB]
Definition: actuators_dshot_arch.c:34
actuators_dshot_arch_commit
void actuators_dshot_arch_commit(void)
Definition: actuators_dshot_arch.c:142
actuators_dshot_arch_init
void actuators_dshot_arch_init(void)
Arch dependent init.
Definition: actuators_dshot_arch.c:73
DSHOT_SERVO_5_CHANNEL
#define DSHOT_SERVO_5_CHANNEL
Definition: board.h:385
DSHOT_SERVO_2
#define DSHOT_SERVO_2
Definition: board.h:407
DSHOT_SERVO_5
#define DSHOT_SERVO_5
Definition: board.h:380
DSHOT_SERVO_10
#define DSHOT_SERVO_10
Definition: matekF765-WING.h:423
DSHOT_SERVO_8
#define DSHOT_SERVO_8
Definition: matekF765-WING.h:409
DSHOT_SERVO_8_CHANNEL
#define DSHOT_SERVO_8_CHANNEL
Definition: matekF765-WING.h:414
DSHOT_SERVO_9_GPIO
#define DSHOT_SERVO_9_GPIO
Definition: matekF765-WING.h:417
ACTUATORS_DSHOT_NB
#define ACTUATORS_DSHOT_NB
Maxnum number of DSHOT commands This should be large enough for max applications: 8 motors +1 in case...
Definition: actuators_dshot.h:46
DSHOT_CONF3_DEF
#define DSHOT_CONF3_DEF
Definition: board.h:432
DSHOT_SERVO_8_DRIVER
#define DSHOT_SERVO_8_DRIVER
Definition: matekF765-WING.h:413
DSHOT_SERVO_3_DRIVER
#define DSHOT_SERVO_3_DRIVER
Definition: board.h:418
DSHOT_SERVO_2_DRIVER
#define DSHOT_SERVO_2_DRIVER
Definition: board.h:411
DSHOT_SERVO_7_CHANNEL
#define DSHOT_SERVO_7_CHANNEL
Definition: matekF765-WING.h:407
esc_dshot.h
DSHOT driver based on ChibiOS.
DSHOT_SERVO_10_DRIVER
#define DSHOT_SERVO_10_DRIVER
Definition: matekF765-WING.h:427
DSHOT_SERVO_2_GPIO
#define DSHOT_SERVO_2_GPIO
Definition: board.h:408
DSHOT_SERVO_3_CHANNEL
#define DSHOT_SERVO_3_CHANNEL
Definition: board.h:419
DSHOT_SERVO_9_CHANNEL
#define DSHOT_SERVO_9_CHANNEL
Definition: matekF765-WING.h:421
DSHOT_SERVO_3_PIN
#define DSHOT_SERVO_3_PIN
Definition: board.h:416
DSHOT_SERVO_0_PIN
#define DSHOT_SERVO_0_PIN
Definition: board.h:402
DSHOT_SERVO_7_AF
#define DSHOT_SERVO_7_AF
Definition: matekF765-WING.h:405
DshotDmaBuffer
Definition: esc_dshot.h:139
DSHOT_SERVO_7_GPIO
#define DSHOT_SERVO_7_GPIO
Definition: matekF765-WING.h:403
DSHOT_SERVO_10_GPIO
#define DSHOT_SERVO_10_GPIO
Definition: matekF765-WING.h:424
gpio_setup_pin_af
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
Definition: gpio_arch.c:61
DSHOT_CONF2_DEF
#define DSHOT_CONF2_DEF
Definition: board.h:388
DSHOT_SERVO_3_GPIO
#define DSHOT_SERVO_3_GPIO
Definition: board.h:415
DSHOT_SERVO_5_AF
#define DSHOT_SERVO_5_AF
Definition: board.h:383
DSHOT_SERVO_5_GPIO
#define DSHOT_SERVO_5_GPIO
Definition: board.h:381
DSHOT_SERVO_1_GPIO
#define DSHOT_SERVO_1_GPIO
Definition: board.h:367
gpio.h
DSHOT_SERVO_9
#define DSHOT_SERVO_9
Definition: matekF765-WING.h:416
DSHOT_SERVO_0_AF
#define DSHOT_SERVO_0_AF
Definition: board.h:403
ram_arch.h
dshotSendFrame
void dshotSendFrame(DSHOTDriver *driver)
send throttle order
Definition: esc_dshot.c:302
DSHOT_SERVO_5_DRIVER
#define DSHOT_SERVO_5_DRIVER
Definition: board.h:384
DSHOT_SERVO_8_PIN
#define DSHOT_SERVO_8_PIN
Definition: matekF765-WING.h:411
DSHOT_SERVO_4_DRIVER
#define DSHOT_SERVO_4_DRIVER
Definition: board.h:377
DSHOT_SERVO_1
#define DSHOT_SERVO_1
Definition: board.h:366
DSHOT_SERVO_10_PIN
#define DSHOT_SERVO_10_PIN
Definition: matekF765-WING.h:425
DSHOT_SERVO_7
#define DSHOT_SERVO_7
Definition: matekF765-WING.h:402
dshotStart
void dshotStart(DSHOTDriver *driver, const DSHOTConfig *config)
Configures and activates the DSHOT peripheral.
Definition: esc_dshot.c:122
DSHOT_SERVO_4_AF
#define DSHOT_SERVO_4_AF
Definition: board.h:376
DSHOT_SERVO_9_PIN
#define DSHOT_SERVO_9_PIN
Definition: matekF765-WING.h:418
DSHOTDriver
DSHOT driver structure.
Definition: esc_dshot.h:228
DSHOT_SERVO_2_PIN
#define DSHOT_SERVO_2_PIN
Definition: board.h:409
IN_DMA_SECTION_NOINIT
#define IN_DMA_SECTION_NOINIT(var)
Definition: ram_arch.h:74
actuators_dshot.h
DSHOT_SERVO_4_PIN
#define DSHOT_SERVO_4_PIN
Definition: board.h:375
DSHOT_SERVO_1_PIN
#define DSHOT_SERVO_1_PIN
Definition: board.h:368
DSHOT_SERVO_8_GPIO
#define DSHOT_SERVO_8_GPIO
Definition: matekF765-WING.h:410
DSHOT_SERVO_4
#define DSHOT_SERVO_4
Definition: board.h:373
DSHOTConfig
DSHOT Driver configuration structure.
Definition: esc_dshot.h:155
DSHOT_SERVO_10_CHANNEL
#define DSHOT_SERVO_10_CHANNEL
Definition: matekF765-WING.h:428
DSHOT_SERVO_4_GPIO
#define DSHOT_SERVO_4_GPIO
Definition: board.h:374
DSHOT_SERVO_8_AF
#define DSHOT_SERVO_8_AF
Definition: matekF765-WING.h:412
DSHOT_SERVO_3_AF
#define DSHOT_SERVO_3_AF
Definition: board.h:417