Paparazzi UAS  v5.17_devel-145-ga57bdbf-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 }
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
unsigned short uint16_t
Definition: types.h:16
Specific RAM section for DMA usage on F7.
#define DSHOT_SERVO_7_PIN
#define DSHOT_SERVO_3
Definition: board.h:414
#define DSHOT_SERVO_1_GPIO
Definition: board.h:367
DSHOT driver based on ChibiOS.
#define DSHOT_SERVO_4_PIN
Definition: board.h:375
#define DSHOT_SERVO_8_PIN
#define DSHOT_SERVO_4_GPIO
Definition: board.h:374
#define DSHOT_SERVO_1_CHANNEL
Definition: board.h:371
#define DSHOT_SERVO_7_GPIO
#define DSHOT_SERVO_5_PIN
Definition: board.h:382
#define DSHOT_SERVO_9_GPIO
Some architecture independent helper functions for GPIOs.
#define DSHOT_SERVO_2_DRIVER
Definition: board.h:411
#define DSHOT_SERVO_9_DRIVER
#define DSHOT_SERVO_9_PIN
#define DSHOT_SERVO_8_DRIVER
DSHOT Driver configuration structure.
Definition: esc_dshot.h:155
#define DSHOT_SERVO_8_GPIO
void dshotStart(DSHOTDriver *driver, const DSHOTConfig *config)
Configures and activates the DSHOT peripheral.
Definition: esc_dshot.c:122
void dshotSetThrottle(DSHOTDriver *driver, const uint8_t index, const uint16_t throttle)
prepare throttle order for specified ESC
Definition: esc_dshot.c:210
#define DSHOT_SERVO_4
Definition: board.h:373
#define DSHOT_SERVO_0_CHANNEL
Definition: board.h:405
#define DSHOT_SERVO_0_PIN
Definition: board.h:402
void dshotSendFrame(DSHOTDriver *driver)
send throttle order
Definition: esc_dshot.c:302
DSHOT driver structure.
Definition: esc_dshot.h:228
#define DSHOT_CONF2_DEF
Definition: board.h:388
#define DSHOT_SERVO_9_CHANNEL
#define DSHOT_SERVO_10
#define DSHOT_SERVO_2_AF
Definition: board.h:410
#define DSHOT_SERVO_5_AF
Definition: board.h:383
#define DSHOT_SERVO_3_CHANNEL
Definition: board.h:419
#define DSHOT_SERVO_0_GPIO
Definition: board.h:401
#define DSHOT_SERVO_0
Definition: board.h:400
#define DSHOT_SERVO_1_AF
Definition: board.h:369
#define DSHOT_SERVO_1
Definition: board.h:366
#define DSHOT_SERVO_3_PIN
Definition: board.h:416
#define DSHOT_SERVO_8_AF
#define DSHOT_SERVO_5_CHANNEL
Definition: board.h:385
#define DSHOT_SERVO_7_DRIVER
uint16_t actuators_dshot_values[ACTUATORS_DSHOT_NB]
#define DSHOT_SERVO_8
#define DSHOT_SERVO_7_CHANNEL
#define DSHOT_SERVO_9_AF
#define DSHOT_SERVO_2_PIN
Definition: board.h:409
#define DSHOT_SERVO_5_GPIO
Definition: board.h:381
#define DSHOT_SERVO_8_CHANNEL
#define DSHOT_SERVO_3_DRIVER
Definition: board.h:418
#define DSHOT_SERVO_1_PIN
Definition: board.h:368
#define DSHOT_SERVO_4_DRIVER
Definition: board.h:377
#define DSHOT_SERVO_2_GPIO
Definition: board.h:408
#define DSHOT_SERVO_7_AF
#define DSHOT_SERVO_3_AF
Definition: board.h:417
#define ACTUATORS_DSHOT_NB
Maxnum number of DSHOT commands This should be large enough for max applications: 8 motors +1 in case...
#define DSHOT_SERVO_2
Definition: board.h:407
#define DSHOT_SERVO_5
Definition: board.h:380
#define DSHOT_SERVO_7
#define DSHOT_SERVO_10_PIN
#define DSHOT_SERVO_9
#define DSHOT_SERVO_4_AF
Definition: board.h:376
void actuators_dshot_arch_commit(void)
void actuators_dshot_arch_init(void)
Arch dependent init.
#define DSHOT_CONF3_DEF
Definition: board.h:432
#define DSHOT_CONF4_DEF
#define DSHOT_SERVO_3_GPIO
Definition: board.h:415
#define DSHOT_SERVO_0_AF
Definition: board.h:403
#define DSHOT_SERVO_5_DRIVER
Definition: board.h:384
#define DSHOT_SERVO_10_DRIVER
#define DSHOT_SERVO_2_CHANNEL
Definition: board.h:412
#define DSHOT_SERVO_10_CHANNEL
#define DSHOT_SERVO_10_AF
#define IN_DMA_SECTION_NOINIT(var)
Definition: ram_arch.h:74
#define DSHOT_SERVO_0_DRIVER
Definition: board.h:404
#define DSHOT_SERVO_10_GPIO
#define DSHOT_SERVO_1_DRIVER
Definition: board.h:370
#define DSHOT_SERVO_4_CHANNEL
Definition: board.h:378