X9D+ 2019 Bootloader: wait needed before detecting trims are pressed
[opentx.git] / radio / src / targets / taranis / hal.h
blob6b890b5e2c8bf031ad4a1b3e7146f76e5d8a055e
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _HAL_H_
22 #define _HAL_H_
24 // Keys
25 #if defined(PCBX9E)
26 #define KEYS_GPIO_REG_MENU GPIOD->IDR
27 #define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
28 #define KEYS_GPIO_REG_EXIT GPIOD->IDR
29 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
30 #define KEYS_GPIO_REG_PAGE GPIOD->IDR
31 #define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
32 #define KEYS_GPIO_REG_ENTER GPIOF->IDR
33 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_0 // PF.00
34 #elif defined(PCBXLITE)
35 #define KEYS_GPIO_REG_SHIFT GPIOE->IDR
36 #define KEYS_GPIO_PIN_SHIFT GPIO_Pin_8 // PE.08
37 #define KEYS_GPIO_REG_EXIT GPIOE->IDR
38 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_7 // PE.07
39 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
40 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_11 // PE.11
41 #define KEYS_GPIO_REG_UP GPIOE->IDR
42 #define KEYS_GPIO_PIN_UP GPIO_Pin_10 // PE.10
43 #define KEYS_GPIO_REG_DOWN GPIOE->IDR
44 #define KEYS_GPIO_PIN_DOWN GPIO_Pin_14 // PE.14
45 #define KEYS_GPIO_REG_LEFT GPIOE->IDR
46 #define KEYS_GPIO_PIN_LEFT GPIO_Pin_12 // PE.12
47 #define KEYS_GPIO_REG_RIGHT GPIOE->IDR
48 #define KEYS_GPIO_PIN_RIGHT GPIO_Pin_13 // PE.13
49 #elif defined(RADIO_T12)
50 #define KEYS_GPIO_REG_EXIT GPIOD->IDR
51 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
52 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
53 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_10 // PE.10
54 #define KEYS_GPIO_REG_UP GPIOE->IDR
55 #define KEYS_GPIO_PIN_UP GPIO_Pin_9 // PE.09
56 #define KEYS_GPIO_REG_DOWN GPIOE->IDR
57 #define KEYS_GPIO_PIN_DOWN GPIO_Pin_11 // PE.11
58 #define KEYS_GPIO_REG_LEFT GPIOD->IDR
59 #define KEYS_GPIO_PIN_LEFT GPIO_Pin_7 // PD.07
60 #define KEYS_GPIO_REG_RIGHT GPIOD->IDR
61 #define KEYS_GPIO_PIN_RIGHT GPIO_Pin_3 // PD.03
62 #elif defined(RADIO_X7)
63 #define KEYS_GPIO_REG_PAGE GPIOD->IDR
64 #define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
65 #define KEYS_GPIO_REG_MENU GPIOD->IDR
66 #define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
67 #define KEYS_GPIO_REG_EXIT GPIOD->IDR
68 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
69 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
70 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_10 // PE.10
71 #elif defined(PCBX9LITE)
72 #define KEYS_GPIO_REG_PAGE GPIOE->IDR
73 #define KEYS_GPIO_PIN_PAGE GPIO_Pin_8 // PE.08
74 #define KEYS_GPIO_REG_MENU GPIOE->IDR
75 #define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PE.07
76 #define KEYS_GPIO_REG_EXIT GPIOE->IDR
77 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_9 // PE.09
78 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
79 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_11 // PE.11
80 #elif defined(PCBX9DP) && PCBREV >= 2019
81 #define KEYS_GPIO_REG_MENU GPIOD->IDR
82 #define KEYS_GPIO_PIN_MENU GPIO_Pin_2 // PD.02
83 #define KEYS_GPIO_REG_EXIT GPIOD->IDR
84 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_7 // PD.07
85 #define KEYS_GPIO_REG_PAGE GPIOD->IDR
86 #define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
87 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
88 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_12 // PE.12
89 #else
90 #define KEYS_GPIO_REG_MENU GPIOD->IDR
91 #define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
92 #define KEYS_GPIO_REG_EXIT GPIOD->IDR
93 #define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.02
94 #define KEYS_GPIO_REG_PAGE GPIOD->IDR
95 #define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.03
96 #define KEYS_GPIO_REG_PLUS GPIOE->IDR
97 #define KEYS_GPIO_PIN_PLUS GPIO_Pin_10 // PE.10
98 #define KEYS_GPIO_REG_MINUS GPIOE->IDR
99 #define KEYS_GPIO_PIN_MINUS GPIO_Pin_11 // PE.11
100 #define KEYS_GPIO_REG_ENTER GPIOE->IDR
101 #define KEYS_GPIO_PIN_ENTER GPIO_Pin_12 // PE.12
102 #endif
104 // Rotary Encoder
105 #if defined(PCBX9E)
106 #define ROTARY_ENCODER_NAVIGATION
107 #define ROTARY_ENCODER_GPIO GPIOD
108 #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_12 // PD.12
109 #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_13 // PD.13
110 #define ROTARY_ENCODER_POSITION() (ROTARY_ENCODER_GPIO->IDR >> 12) & 0x03
111 #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line12
112 #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line13
113 #define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn
114 #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler
115 #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOD
116 #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource12
117 #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource13
118 #elif defined(PCBX9DP) && PCBREV >= 2019
119 #define ROTARY_ENCODER_NAVIGATION
120 #define ROTARY_ENCODER_GPIO GPIOE
121 #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_10 // PE.10
122 #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_11 // PE.11
123 #define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x02) + ((ROTARY_ENCODER_GPIO->IDR >> 11) & 0x01))
124 #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line10
125 #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line11
126 #define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn
127 #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler
128 #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOE
129 #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource10
130 #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource11
131 #elif defined(RADIO_X7)
132 #define ROTARY_ENCODER_NAVIGATION
133 #define ROTARY_ENCODER_GPIO GPIOE
134 #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_9 // PE.09
135 #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_11 // PE.11
136 #define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 10) & 0x02) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x01))
137 #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line9
138 #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line11
139 #define ROTARY_ENCODER_EXTI_IRQn1 EXTI9_5_IRQn
140 #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI9_5_IRQHandler
141 #define ROTARY_ENCODER_EXTI_IRQn2 EXTI15_10_IRQn
142 #define ROTARY_ENCODER_EXTI_IRQHandler2 EXTI15_10_IRQHandler
143 #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOE
144 #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource9
145 #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource11
146 #elif defined(PCBX9LITE)
147 #define ROTARY_ENCODER_NAVIGATION
148 #define ROTARY_ENCODER_GPIO GPIOE
149 #define ROTARY_ENCODER_GPIO_PIN_A GPIO_Pin_10 // PE.10
150 #define ROTARY_ENCODER_GPIO_PIN_B GPIO_Pin_12 // PE.12
151 #define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 12) & 0x01) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x02))
152 #define ROTARY_ENCODER_EXTI_LINE1 EXTI_Line10
153 #define ROTARY_ENCODER_EXTI_LINE2 EXTI_Line12
154 #define ROTARY_ENCODER_EXTI_IRQn1 EXTI15_10_IRQn
155 #define ROTARY_ENCODER_EXTI_IRQHandler1 EXTI15_10_IRQHandler
156 #define ROTARY_ENCODER_EXTI_PortSource EXTI_PortSourceGPIOE
157 #define ROTARY_ENCODER_EXTI_PinSource1 EXTI_PinSource10
158 #define ROTARY_ENCODER_EXTI_PinSource2 EXTI_PinSource12
159 #endif
160 #if defined(ROTARY_ENCODER_NAVIGATION)
161 #define ROTARY_ENCODER_RCC_APB1Periph RCC_APB1Periph_TIM5
162 #define ROTARY_ENCODER_TIMER TIM5
163 #define ROTARY_ENCODER_TIMER_IRQn TIM5_IRQn
164 #define ROTARY_ENCODER_TIMER_IRQHandler TIM5_IRQHandler
165 #else
166 #define ROTARY_ENCODER_RCC_APB1Periph 0
167 #endif
169 // Trims
170 #if defined(PCBX9E)
171 #define TRIMS_GPIO_REG_LHL GPIOG->IDR
172 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_1 // PG.01
173 #define TRIMS_GPIO_REG_LHR GPIOG->IDR
174 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_0 // PG.00
175 #define TRIMS_GPIO_REG_LVD GPIOE->IDR
176 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_4 // PE.04
177 #define TRIMS_GPIO_REG_LVU GPIOE->IDR
178 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_3 // PE.03
179 #define TRIMS_GPIO_REG_RVD GPIOC->IDR
180 #define TRIMS_GPIO_PIN_RVD GPIO_Pin_3 // PC.03
181 #define TRIMS_GPIO_REG_RHL GPIOC->IDR
182 #define TRIMS_GPIO_PIN_RHL GPIO_Pin_1 // PC.01
183 #define TRIMS_GPIO_REG_RVU GPIOC->IDR
184 #define TRIMS_GPIO_PIN_RVU GPIO_Pin_2 // PC.02
185 #define TRIMS_GPIO_REG_RHR GPIOC->IDR
186 #define TRIMS_GPIO_PIN_RHR GPIO_Pin_13 // PC.13
187 #elif defined(PCBXLITE)
188 #define TRIMS_GPIO_REG_LHL GPIOC->IDR
189 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_4 // PC.04
190 #define TRIMS_GPIO_REG_LHR GPIOC->IDR
191 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_5 // PC.05
192 #define TRIMS_GPIO_REG_LVU GPIOB->IDR
193 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_0 // PB.00
194 #define TRIMS_GPIO_REG_LVD GPIOB->IDR
195 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_1 // PB.01
196 #elif defined(PCBX7)
197 #define TRIMS_GPIO_REG_LHL GPIOD->IDR
198 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_15 // PD.15
199 #define TRIMS_GPIO_REG_LHR GPIOC->IDR
200 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_1 // PC.01
201 #define TRIMS_GPIO_REG_LVD GPIOE->IDR
202 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_6 // PE.06
203 #define TRIMS_GPIO_REG_LVU GPIOE->IDR
204 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_5 // PE.05
205 #define TRIMS_GPIO_REG_RVD GPIOC->IDR
206 #define TRIMS_GPIO_PIN_RVD GPIO_Pin_3 // PC.03
207 #define TRIMS_GPIO_REG_RHL GPIOE->IDR
208 #define TRIMS_GPIO_PIN_RHL GPIO_Pin_3 // PE.03
209 #define TRIMS_GPIO_REG_RVU GPIOC->IDR
210 #define TRIMS_GPIO_PIN_RVU GPIO_Pin_2 // PC.02
211 #define TRIMS_GPIO_REG_RHR GPIOE->IDR
212 #define TRIMS_GPIO_PIN_RHR GPIO_Pin_4 // PE.04
213 #elif defined(PCBX9LITE)
214 #define TRIMS_GPIO_REG_LHR GPIOC->IDR
215 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_4 // PC.04
216 #define TRIMS_GPIO_REG_LHL GPIOC->IDR
217 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_5 // PC.05
218 #define TRIMS_GPIO_REG_LVU GPIOB->IDR
219 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_0 // PB.00
220 #define TRIMS_GPIO_REG_LVD GPIOB->IDR
221 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_1 // PB.01
222 #define TRIMS_GPIO_REG_RVU GPIOE->IDR
223 #define TRIMS_GPIO_PIN_RVU GPIO_Pin_13 // PE.13
224 #define TRIMS_GPIO_REG_RHR GPIOD->IDR
225 #define TRIMS_GPIO_PIN_RHR GPIO_Pin_8 // PD.08
226 #define TRIMS_GPIO_REG_RVD GPIOE->IDR
227 #define TRIMS_GPIO_PIN_RVD GPIO_Pin_14 // PE.14
228 #define TRIMS_GPIO_REG_RHL GPIOD->IDR
229 #define TRIMS_GPIO_PIN_RHL GPIO_Pin_9 // PD.09
230 #elif defined(PCBX9DP) && PCBREV >= 2019
231 #define BOOTLOADER_WAIT_BEFORE_READ_TRIMS
232 #define TRIMS_GPIO_REG_LHL GPIOE->IDR
233 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PE.03
234 #define TRIMS_GPIO_REG_LHR GPIOE->IDR
235 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_4 // PE.04
236 #define TRIMS_GPIO_REG_LVD GPIOE->IDR
237 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_6 // PE.06
238 #define TRIMS_GPIO_REG_LVU GPIOE->IDR
239 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_5 // PE.05
240 #define TRIMS_GPIO_REG_RVD GPIOC->IDR
241 #define TRIMS_GPIO_PIN_RVD GPIO_Pin_3 // PC.03
242 #define TRIMS_GPIO_REG_RVU GPIOC->IDR
243 #define TRIMS_GPIO_PIN_RVU GPIO_Pin_2 // PC.02
244 #define TRIMS_GPIO_REG_RHL GPIOC->IDR
245 #define TRIMS_GPIO_PIN_RHL GPIO_Pin_13 // PC.13
246 #define TRIMS_GPIO_REG_RHR GPIOC->IDR
247 #define TRIMS_GPIO_PIN_RHR GPIO_Pin_1 // PC.01
248 #else
249 #define TRIMS_GPIO_REG_LHL GPIOE->IDR
250 #define TRIMS_GPIO_PIN_LHL GPIO_Pin_4 // PE.04
251 #define TRIMS_GPIO_REG_LHR GPIOE->IDR
252 #define TRIMS_GPIO_PIN_LHR GPIO_Pin_3 // PE.03
253 #define TRIMS_GPIO_REG_LVD GPIOE->IDR
254 #define TRIMS_GPIO_PIN_LVD GPIO_Pin_6 // PE.06
255 #define TRIMS_GPIO_REG_LVU GPIOE->IDR
256 #define TRIMS_GPIO_PIN_LVU GPIO_Pin_5 // PE.05
257 #define TRIMS_GPIO_REG_RVD GPIOC->IDR
258 #define TRIMS_GPIO_PIN_RVD GPIO_Pin_3 // PC.03
259 #define TRIMS_GPIO_REG_RHL GPIOC->IDR
260 #define TRIMS_GPIO_PIN_RHL GPIO_Pin_1 // PC.01
261 #define TRIMS_GPIO_REG_RVU GPIOC->IDR
262 #define TRIMS_GPIO_PIN_RVU GPIO_Pin_2 // PC.02
263 #define TRIMS_GPIO_REG_RHR GPIOC->IDR
264 #define TRIMS_GPIO_PIN_RHR GPIO_Pin_13 // PC.13
265 #endif
267 // Switches
268 #if defined(PCBX9E)
269 #define STORAGE_SWITCH_A
270 #define HARDWARE_SWITCH_A
271 #define HARDWARE_SWITCH_A
272 #define SWITCHES_GPIO_REG_A_H GPIOD->IDR
273 #define SWITCHES_GPIO_PIN_A_H GPIO_Pin_10 // PD.10
274 #define SWITCHES_GPIO_REG_A_L GPIOD->IDR
275 #define SWITCHES_GPIO_PIN_A_L GPIO_Pin_14 // PD.14
276 #elif defined(PCBXLITE) || defined(PCBX9LITE)
277 #define STORAGE_SWITCH_A
278 #define HARDWARE_SWITCH_A
279 #define SWITCHES_GPIO_REG_A_H GPIOE->IDR
280 #define SWITCHES_GPIO_PIN_A_H GPIO_Pin_1 // PE.01
281 #define SWITCHES_GPIO_REG_A_L GPIOE->IDR
282 #define SWITCHES_GPIO_PIN_A_L GPIO_Pin_0 // PE.00
283 #elif defined(PCBX7)
284 #define STORAGE_SWITCH_A
285 #define HARDWARE_SWITCH_A
286 #define SWITCHES_GPIO_REG_A_L GPIOE->IDR
287 #define SWITCHES_GPIO_PIN_A_L GPIO_Pin_7 // PE.07
288 #define SWITCHES_GPIO_REG_A_H GPIOE->IDR
289 #define SWITCHES_GPIO_PIN_A_H GPIO_Pin_13 // PE.13
290 #else
291 #define STORAGE_SWITCH_A
292 #define HARDWARE_SWITCH_A
293 #define SWITCHES_GPIO_REG_A_H GPIOB->IDR
294 #define SWITCHES_GPIO_PIN_A_H GPIO_Pin_5 // PB.05
295 #define SWITCHES_GPIO_REG_A_L GPIOE->IDR
296 #define SWITCHES_GPIO_PIN_A_L GPIO_Pin_0 // PE.00
297 #endif
299 #if defined(PCBX9E)
300 #define STORAGE_SWITCH_B
301 #define HARDWARE_SWITCH_B
302 #define SWITCHES_GPIO_REG_B_H GPIOG->IDR
303 #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_11 // PG.11
304 #define SWITCHES_GPIO_REG_B_L GPIOG->IDR
305 #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_10 // PG.10
306 #elif defined(PCBXLITE)
307 #define STORAGE_SWITCH_B
308 #define HARDWARE_SWITCH_B
309 #define SWITCHES_GPIO_REG_B_L GPIOA->IDR
310 #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_6 // PA.06
311 #define SWITCHES_GPIO_REG_B_H GPIOA->IDR
312 #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_5 // PA.05
313 #elif defined(PCBX7)
314 #define STORAGE_SWITCH_B
315 #define HARDWARE_SWITCH_B
316 #define SWITCHES_GPIO_REG_B_L GPIOE->IDR
317 #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_15 // PE.15
318 #define SWITCHES_GPIO_REG_B_H GPIOA->IDR
319 #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_5 // PA.05
320 #elif defined(PCBX9LITE)
321 #define STORAGE_SWITCH_B
322 #define HARDWARE_SWITCH_B
323 #define SWITCHES_GPIO_REG_B_L GPIOB->IDR
324 #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_4 // PB.04
325 #define SWITCHES_GPIO_REG_B_H GPIOB->IDR
326 #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_5 // PB.05
327 #else
328 #define STORAGE_SWITCH_B
329 #define HARDWARE_SWITCH_B
330 #define SWITCHES_GPIO_REG_B_H GPIOE->IDR
331 #define SWITCHES_GPIO_PIN_B_H GPIO_Pin_1 // PE.01
332 #define SWITCHES_GPIO_REG_B_L GPIOE->IDR
333 #define SWITCHES_GPIO_PIN_B_L GPIO_Pin_2 // PE.02
334 #endif
336 #if defined(PCBX9E)
337 #define STORAGE_SWITCH_C
338 #define HARDWARE_SWITCH_C
339 #define SWITCHES_GPIO_REG_C_H GPIOF->IDR
340 #define SWITCHES_GPIO_PIN_C_H GPIO_Pin_13 // PF.13
341 #define SWITCHES_GPIO_REG_C_L GPIOF->IDR
342 #define SWITCHES_GPIO_PIN_C_L GPIO_Pin_14 // PF.14
343 #elif defined(PCBXLITE) || defined(PCBX9LITE)
344 #define STORAGE_SWITCH_C
345 #define HARDWARE_SWITCH_C
346 #define SWITCHES_GPIO_REG_C_L GPIOE->IDR
347 #define SWITCHES_GPIO_PIN_C_L GPIO_Pin_2 // PE.02
348 #define SWITCHES_GPIO_REG_C_H GPIOE->IDR
349 #define SWITCHES_GPIO_PIN_C_H GPIO_Pin_3 // PE.03
350 #elif defined(PCBX7)
351 #define STORAGE_SWITCH_C
352 #define HARDWARE_SWITCH_C
353 #define SWITCHES_GPIO_REG_C_L GPIOD->IDR
354 #define SWITCHES_GPIO_PIN_C_L GPIO_Pin_11 // PD.11
355 #define SWITCHES_GPIO_REG_C_H GPIOE->IDR
356 #define SWITCHES_GPIO_PIN_C_H GPIO_Pin_0 // PE.00
357 #else
358 #define STORAGE_SWITCH_C
359 #define HARDWARE_SWITCH_C
360 #define SWITCHES_GPIO_REG_C_H GPIOE->IDR
361 #define SWITCHES_GPIO_PIN_C_H GPIO_Pin_15 // PE.15
362 #define SWITCHES_GPIO_REG_C_L GPIOA->IDR
363 #define SWITCHES_GPIO_PIN_C_L GPIO_Pin_5 // PA.05
364 #endif
366 #if defined(PCBX9E)
367 #define STORAGE_SWITCH_D
368 #define HARDWARE_SWITCH_D
369 #define SWITCHES_GPIO_REG_D_H GPIOE->IDR
370 #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_1 // PE.01
371 #define SWITCHES_GPIO_REG_D_L GPIOE->IDR
372 #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_2 // PE.02
373 #elif defined(PCBX9DP)
374 #define STORAGE_SWITCH_D
375 #define HARDWARE_SWITCH_D
376 #define SWITCHES_GPIO_REG_D_H GPIOE->IDR
377 #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07
378 #define SWITCHES_GPIO_REG_D_L GPIOE->IDR
379 #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_13 // PE.13
380 #elif defined(PCBXLITE)
381 #define STORAGE_SWITCH_D
382 #define HARDWARE_SWITCH_D
383 #define SWITCHES_GPIO_REG_D_L GPIOB->IDR
384 #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_4 // PB.04
385 #define SWITCHES_GPIO_REG_D_H GPIOB->IDR
386 #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_5 // PB.05
387 #elif defined(PCBX7)
388 #define STORAGE_SWITCH_D
389 #define HARDWARE_SWITCH_D
390 #define SWITCHES_GPIO_REG_D_L GPIOE->IDR
391 #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_1 // PE.01
392 #define SWITCHES_GPIO_REG_D_H GPIOE->IDR
393 #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_2 // PE.02
394 #elif defined(PCBX9LITE)
395 #define STORAGE_SWITCH_D
396 #define HARDWARE_SWITCH_D
397 #define SWITCHES_GPIO_REG_D GPIOC->IDR
398 #define SWITCHES_GPIO_PIN_D GPIO_Pin_13 // PC.13
399 #else
400 #define STORAGE_SWITCH_D
401 #define HARDWARE_SWITCH_D
402 #define SWITCHES_GPIO_REG_D_H GPIOE->IDR
403 #define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07
404 #define SWITCHES_GPIO_REG_D_L GPIOB->IDR
405 #define SWITCHES_GPIO_PIN_D_L GPIO_Pin_1 // PB.01
406 #endif
408 #if defined(PCBX9E)
409 #define STORAGE_SWITCH_E
410 #define HARDWARE_SWITCH_E
411 #define SWITCHES_GPIO_REG_E_H GPIOE->IDR
412 #define SWITCHES_GPIO_PIN_E_H GPIO_Pin_7 // PE.07
413 #define SWITCHES_GPIO_REG_E_L GPIOE->IDR
414 #define SWITCHES_GPIO_PIN_E_L GPIO_Pin_13 // PE.13
415 #elif defined(PCBXLITES)
416 #define STORAGE_SWITCH_E
417 #define HARDWARE_SWITCH_E
418 #define SWITCHES_GPIO_REG_E GPIOE->IDR
419 #define SWITCHES_GPIO_PIN_E GPIO_Pin_5 // PE.05
420 #elif defined(PCBXLITE)
421 // no SWE but we want to remain compatible with XLiteS
422 #define STORAGE_SWITCH_E
423 #elif defined(PCBX9LITE)
424 #define STORAGE_SWITCH_E
425 #define HARDWARE_SWITCH_E
426 #define SWITCHES_GPIO_REG_E GPIOA->IDR
427 #define SWITCHES_GPIO_PIN_E GPIO_Pin_5 // PA.05
428 #elif defined(PCBX7)
429 // no SWE
430 #else
431 #define STORAGE_SWITCH_E
432 #define HARDWARE_SWITCH_E
433 #define SWITCHES_GPIO_REG_E_H GPIOB->IDR
434 #define SWITCHES_GPIO_PIN_E_H GPIO_Pin_3 // PB.03
435 #define SWITCHES_GPIO_REG_E_L GPIOB->IDR
436 #define SWITCHES_GPIO_PIN_E_L GPIO_Pin_4 // PB.04
437 #endif
439 #if defined(PCBX9E)
440 #define STORAGE_SWITCH_F
441 #define HARDWARE_SWITCH_F
442 #define SWITCHES_GPIO_REG_F GPIOE->IDR
443 #define SWITCHES_GPIO_PIN_F GPIO_Pin_11 // PE.11
444 #elif defined(PCBXLITES)
445 #define STORAGE_SWITCH_F
446 #define HARDWARE_SWITCH_F
447 #define SWITCHES_GPIO_REG_F GPIOC->IDR
448 #define SWITCHES_GPIO_PIN_F GPIO_Pin_3 // PC.03
449 #elif defined(PCBXLITE)
450 // no SWF but we want to remain compatible with XLiteS
451 #define STORAGE_SWITCH_F
452 #elif defined(PCBX9LITES)
453 #define STORAGE_SWITCH_F
454 #define HARDWARE_SWITCH_F
455 #define SWITCHES_GPIO_REG_F GPIOC->IDR
456 #define SWITCHES_GPIO_PIN_F GPIO_Pin_3 // PC.03
457 #elif defined(PCBX9LITE)
458 // no SWF
459 #elif defined(PCBX7)
460 #define STORAGE_SWITCH_F
461 #define HARDWARE_SWITCH_F
462 #define SWITCHES_GPIO_REG_F GPIOE->IDR
463 #define SWITCHES_GPIO_PIN_F GPIO_Pin_14 // PE.14
464 #else
465 #define STORAGE_SWITCH_F
466 #define HARDWARE_SWITCH_F
467 #define SWITCHES_GPIO_REG_F GPIOE->IDR
468 #define SWITCHES_GPIO_PIN_F GPIO_Pin_14 // PE.14
469 #endif
471 #if defined(PCBX9E)
472 #define STORAGE_SWITCH_G
473 #define HARDWARE_SWITCH_G
474 #define SWITCHES_GPIO_REG_G_H GPIOF->IDR
475 #define SWITCHES_GPIO_PIN_G_H GPIO_Pin_3 // PF.03
476 #define SWITCHES_GPIO_REG_G_L GPIOF->IDR
477 #define SWITCHES_GPIO_PIN_G_L GPIO_Pin_4 // PF.04
478 #elif defined(PCBX9LITES)
479 #define STORAGE_SWITCH_G
480 #define HARDWARE_SWITCH_G
481 #define SWITCHES_GPIO_REG_G GPIOC->IDR
482 #define SWITCHES_GPIO_PIN_G GPIO_Pin_2 // PC.02
483 #elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE)
484 // no SWG
485 #else
486 #define STORAGE_SWITCH_G
487 #define HARDWARE_SWITCH_G
488 #define SWITCHES_GPIO_REG_G_H GPIOE->IDR
489 #define SWITCHES_GPIO_PIN_G_H GPIO_Pin_9 // PE.09
490 #define SWITCHES_GPIO_REG_G_L GPIOE->IDR
491 #define SWITCHES_GPIO_PIN_G_L GPIO_Pin_8 // PE.08
492 #endif
494 #if defined(PCBX9E)
495 #define STORAGE_SWITCH_H
496 #define HARDWARE_SWITCH_H
497 #define SWITCHES_GPIO_REG_H GPIOF->IDR
498 #define SWITCHES_GPIO_PIN_H GPIO_Pin_1 // PF.01
499 #elif defined(PCBX9DP)
500 #define STORAGE_SWITCH_H
501 #define HARDWARE_SWITCH_H
502 #define SWITCHES_GPIO_REG_H GPIOD->IDR
503 #define SWITCHES_GPIO_PIN_H GPIO_Pin_14 // PD.14
504 #elif defined(PCBXLITE) || defined(PCBX9LITE)
505 // no SWH
506 #elif defined(PCBX7)
507 #define STORAGE_SWITCH_H
508 #define HARDWARE_SWITCH_H
509 #define SWITCHES_GPIO_REG_H GPIOD->IDR
510 #define SWITCHES_GPIO_PIN_H GPIO_Pin_14 // PD.14
511 #else
512 #define STORAGE_SWITCH_H
513 #define HARDWARE_SWITCH_H
514 #define SWITCHES_GPIO_REG_H GPIOE->IDR
515 #define SWITCHES_GPIO_PIN_H GPIO_Pin_13 // PE.13
516 #endif
518 #if defined(PCBX9DP) && PCBREV >= 2019
519 #define STORAGE_SWITCH_I
520 #define HARDWARE_SWITCH_I
521 #define SWITCHES_GPIO_REG_I GPIOD->IDR
522 #define SWITCHES_GPIO_PIN_I GPIO_Pin_10 // PD.10
523 #elif defined(PCBX9D) || defined(PCBX9DP)
524 #define STORAGE_SWITCH_I
525 #endif
527 // X7 P400 P401 headers additionnal momentary switches
528 #if defined(PCBX7)
529 #define STORAGE_SWITCH_I
530 #define HARDWARE_SWITCH_I
531 #define STORAGE_SWITCH_J
532 #define HARDWARE_SWITCH_J
533 #define SWITCHES_GPIO_REG_I GPIOC->IDR
534 #define SWITCHES_GPIO_PIN_I GPIO_Pin_13 // PC.13
535 #define SWITCHES_GPIO_REG_J GPIOD->IDR
536 #define SWITCHES_GPIO_PIN_J GPIO_Pin_10 // PD.10
537 #endif
539 #if defined(PCBX9E)
540 #define STORAGE_SWITCH_I
541 #define HARDWARE_SWITCH_I
542 #define SWITCHES_GPIO_REG_I_H GPIOF->IDR
543 #define SWITCHES_GPIO_PIN_I_H GPIO_Pin_15 // PF.15
544 #define SWITCHES_GPIO_REG_I_L GPIOE->IDR
545 #define SWITCHES_GPIO_PIN_I_L GPIO_Pin_14 // PE.14
546 #define STORAGE_SWITCH_J
547 #define HARDWARE_SWITCH_J
548 #define SWITCHES_GPIO_REG_J_H GPIOG->IDR
549 #define SWITCHES_GPIO_PIN_J_H GPIO_Pin_7 // PG.07
550 #define SWITCHES_GPIO_REG_J_L GPIOG->IDR
551 #define SWITCHES_GPIO_PIN_J_L GPIO_Pin_8 // PG.08
552 #define STORAGE_SWITCH_K
553 #define HARDWARE_SWITCH_K
554 #define SWITCHES_GPIO_REG_K_H GPIOG->IDR
555 #define SWITCHES_GPIO_PIN_K_H GPIO_Pin_13 // PG.13
556 #define SWITCHES_GPIO_REG_K_L GPIOG->IDR
557 #define SWITCHES_GPIO_PIN_K_L GPIO_Pin_12 // PG.12
558 #define STORAGE_SWITCH_L
559 #define HARDWARE_SWITCH_L
560 #define SWITCHES_GPIO_REG_L_H GPIOE->IDR
561 #define SWITCHES_GPIO_PIN_L_H GPIO_Pin_9 // PE.09
562 #define SWITCHES_GPIO_REG_L_L GPIOE->IDR
563 #define SWITCHES_GPIO_PIN_L_L GPIO_Pin_8 // PE.08
564 #define STORAGE_SWITCH_M
565 #define HARDWARE_SWITCH_M
566 #define SWITCHES_GPIO_REG_M_H GPIOE->IDR
567 #define SWITCHES_GPIO_PIN_M_H GPIO_Pin_15 // PE.15
568 #define SWITCHES_GPIO_REG_M_L GPIOA->IDR
569 #define SWITCHES_GPIO_PIN_M_L GPIO_Pin_5 // PA.05
570 #define STORAGE_SWITCH_N
571 #define HARDWARE_SWITCH_N
572 #define SWITCHES_GPIO_REG_N_H GPIOB->IDR
573 #define SWITCHES_GPIO_PIN_N_H GPIO_Pin_3 // PB.03
574 #define SWITCHES_GPIO_REG_N_L GPIOB->IDR
575 #define SWITCHES_GPIO_PIN_N_L GPIO_Pin_4 // PB.04
576 #define STORAGE_SWITCH_O
577 #define HARDWARE_SWITCH_O
578 #define SWITCHES_GPIO_REG_O_H GPIOF->IDR
579 #define SWITCHES_GPIO_PIN_O_H GPIO_Pin_7 // PF.07
580 #define SWITCHES_GPIO_REG_O_L GPIOE->IDR
581 #define SWITCHES_GPIO_PIN_O_L GPIO_Pin_10 // PE.10
582 #define STORAGE_SWITCH_P
583 #define HARDWARE_SWITCH_P
584 #define SWITCHES_GPIO_REG_P_H GPIOF->IDR
585 #define SWITCHES_GPIO_PIN_P_H GPIO_Pin_11 // PF.11
586 #define SWITCHES_GPIO_REG_P_L GPIOF->IDR
587 #define SWITCHES_GPIO_PIN_P_L GPIO_Pin_12 // PF.12
588 #define STORAGE_SWITCH_Q
589 #define HARDWARE_SWITCH_Q
590 #define SWITCHES_GPIO_REG_Q_H GPIOF->IDR
591 #define SWITCHES_GPIO_PIN_Q_H GPIO_Pin_5 // PF.05
592 #define SWITCHES_GPIO_REG_Q_L GPIOF->IDR
593 #define SWITCHES_GPIO_PIN_Q_L GPIO_Pin_6 // PF.06
594 #define STORAGE_SWITCH_R
595 #define HARDWARE_SWITCH_R
596 #define SWITCHES_GPIO_REG_R_H GPIOB->IDR
597 #define SWITCHES_GPIO_PIN_R_H GPIO_Pin_5 // PB.05
598 #define SWITCHES_GPIO_REG_R_L GPIOE->IDR
599 #define SWITCHES_GPIO_PIN_R_L GPIO_Pin_0 // PE.00
600 #endif
602 #if defined(PCBX9E)
603 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG)
604 #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_M_L)
605 #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_N_H | SWITCHES_GPIO_PIN_N_L | SWITCHES_GPIO_PIN_R_H)
606 #define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR)
607 #define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_A_L | ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B)
608 #define KEYS_GPIOE_PINS (TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_LVD | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L| SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_I_L | SWITCHES_GPIO_PIN_L_H | SWITCHES_GPIO_PIN_L_L | SWITCHES_GPIO_PIN_M_H | SWITCHES_GPIO_PIN_O_L | SWITCHES_GPIO_PIN_R_L)
609 #define KEYS_GPIOF_PINS (KEYS_GPIO_PIN_ENTER | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | SWITCHES_GPIO_PIN_I_H | SWITCHES_GPIO_PIN_O_H | SWITCHES_GPIO_PIN_P_H | SWITCHES_GPIO_PIN_P_L | SWITCHES_GPIO_PIN_Q_H | SWITCHES_GPIO_PIN_Q_L)
610 #define KEYS_GPIOG_PINS (TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR| SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_J_H | SWITCHES_GPIO_PIN_J_L | SWITCHES_GPIO_PIN_K_H | SWITCHES_GPIO_PIN_K_L)
611 #elif defined(PCBX9DP) && PCBREV >= 2019
612 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
613 #define KEYS_GPIOA_PINS (GPIO_Pin_5)
614 #define KEYS_GPIOB_PINS (GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5)
615 #define KEYS_GPIOC_PINS (GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_13)
616 #define KEYS_GPIOD_PINS (GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_14)
617 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15)
618 #elif defined(PCBX9DP)
619 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
620 #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_C_L)
621 #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_A_H)
622 #define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR)
623 #define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_H)
624 #define KEYS_GPIOE_PINS (KEYS_GPIO_PIN_PLUS | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_MINUS | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L)
625 #elif defined(PCBXLITES)
626 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOE)
627 #define KEYS_GPIOA_PINS (GPIO_Pin_5 | GPIO_Pin_6)
628 #define KEYS_GPIOB_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5)
629 #define KEYS_GPIOC_PINS (GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5)
630 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14)
631 #elif defined(PCBXLITE)
632 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOE)
633 #define KEYS_GPIOA_PINS (GPIO_Pin_5 | GPIO_Pin_6)
634 #define KEYS_GPIOB_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5)
635 #define KEYS_GPIOC_PINS (GPIO_Pin_4 | GPIO_Pin_5)
636 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14)
637 #elif defined(RADIO_T12)
638 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
639 #define KEYS_GPIOA_PINS GPIO_Pin_5
640 #define KEYS_GPIOC_PINS (GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
641 #define KEYS_GPIOD_PINS (GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15)
642 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15)
643 #elif defined(RADIO_X7)
644 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
645 #define KEYS_GPIOA_PINS GPIO_Pin_5
646 #define KEYS_GPIOC_PINS (GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_13)
647 #define KEYS_GPIOD_PINS (GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15)
648 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15)
649 #elif defined(PCBX9LITES)
650 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
651 #define KEYS_GPIOA_PINS (GPIO_Pin_5)
652 #define KEYS_GPIOB_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5)
653 #define KEYS_GPIOC_PINS (GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_13)
654 #define KEYS_GPIOD_PINS (GPIO_Pin_8 | GPIO_Pin_9)
655 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14)
656 #elif defined(PCBX9LITE)
657 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
658 #define KEYS_GPIOA_PINS (GPIO_Pin_5)
659 #define KEYS_GPIOB_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5)
660 #define KEYS_GPIOC_PINS (GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_13)
661 #define KEYS_GPIOD_PINS (GPIO_Pin_8 | GPIO_Pin_9)
662 #define KEYS_GPIOE_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14)
663 #else
664 #define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
665 #define KEYS_GPIOA_PINS (SWITCHES_GPIO_PIN_C_L)
666 #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_D_L)
667 #define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR)
668 #define KEYS_GPIOD_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE)
669 #define KEYS_GPIOE_PINS (KEYS_GPIO_PIN_PLUS | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_MINUS | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H)
670 #endif
672 // ADC
673 #define ADC_MAIN ADC1
674 #define ADC_DMA DMA2
675 #define ADC_DMA_SxCR_CHSEL 0
676 #define ADC_DMA_Stream DMA2_Stream4
677 #define ADC_SET_DMA_FLAGS() ADC_DMA->HIFCR = (DMA_HIFCR_CTCIF4 | DMA_HIFCR_CHTIF4 | DMA_HIFCR_CTEIF4 | DMA_HIFCR_CDMEIF4 | DMA_HIFCR_CFEIF4)
678 #define ADC_TRANSFER_COMPLETE() (ADC_DMA->HISR & DMA_HISR_TCIF4)
679 #define ADC_SAMPTIME 2 // sample time = 28 cycles
680 #if defined(PCBX9E)
681 #define HARDWARE_POT1
682 #define HARDWARE_POT2
683 #define HARDWARE_POT3
684 #define HARDWARE_POT4
685 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2)
686 #define ADC_RCC_APB1Periph 0
687 #define ADC_RCC_APB2Periph (RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC3)
688 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
689 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
690 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_2 // PA.02
691 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_3 // PA.03
692 #define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
693 #define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
694 #define ADC_CHANNEL_STICK_LH ADC_Channel_2 // ADC1_IN2
695 #define ADC_CHANNEL_STICK_LV ADC_Channel_3 // ADC1_IN3
696 #define ADC_GPIO_PIN_POT1 GPIO_Pin_8 // PF.08
697 #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
698 #define ADC_GPIO_PIN_POT3 GPIO_Pin_5 // PC.05
699 #define ADC_GPIO_PIN_POT4 GPIO_Pin_4 // PC.04
700 #define ADC_GPIO_PIN_SLIDER1 GPIO_Pin_10 // PF.10
701 #define ADC_GPIO_PIN_SLIDER2 GPIO_Pin_9 // PF.09
702 #define ADC_GPIO_PIN_SLIDER3 GPIO_Pin_6 // PA.06
703 #define ADC_GPIO_PIN_SLIDER4 GPIO_Pin_1 // PB.01
704 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
705 #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_SLIDER3)
706 #define ADC_GPIOB_PINS (ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_SLIDER4)
707 #define ADC_GPIOC_PINS (ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_POT4 | ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT)
708 #define ADC_GPIOF_PINS (ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2)
709 #define ADC_CHANNEL_POT1 ADC_Channel_6 // ADC3_IN6
710 #define ADC_CHANNEL_POT2 ADC_Channel_8 // ADC1_IN8
711 #define ADC_CHANNEL_POT3 ADC_Channel_15 // ADC1_IN15
712 #define ADC_CHANNEL_POT4 ADC_Channel_14 // ADC1_IN14
713 #define ADC_CHANNEL_SLIDER1 ADC_Channel_8 // ADC3_IN8
714 #define ADC_CHANNEL_SLIDER2 ADC_Channel_7 // ADC3_IN7
715 #define ADC_CHANNEL_SLIDER3 ADC_Channel_6 // ADC1_IN6
716 #define ADC_CHANNEL_SLIDER4 ADC_Channel_9 // ADC1_IN9
717 #define ADC_CHANNEL_BATT ADC_Channel_10 // ADC1_IN10
718 #define ADC_EXT ADC3
719 #define ADC_EXT_DMA DMA2
720 #define ADC_EXT_DMA_Stream DMA2_Stream0
721 #define ADC_EXT_SET_DMA_FLAGS() ADC_DMA->LIFCR = (DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0)
722 #define ADC_EXT_TRANSFER_COMPLETE() (ADC_DMA->LISR & DMA_LISR_TCIF0)
723 #define ADC_EXT_SAMPTIME 3 // sample time = 56 cycles
724 #define ADC_VREF_PREC2 200
725 #elif defined(PCBX9DP)
726 #define HARDWARE_POT1
727 #define HARDWARE_POT2
728 #define HARDWARE_POT3
729 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
730 #define ADC_RCC_APB1Periph 0
731 #define ADC_RCC_APB2Periph RCC_APB2Periph_ADC1
732 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
733 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
734 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_2 // PA.02
735 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_3 // PA.03
736 #define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
737 #define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
738 #define ADC_CHANNEL_STICK_LH ADC_Channel_2 // ADC1_IN2
739 #define ADC_CHANNEL_STICK_LV ADC_Channel_3 // ADC1_IN3
740 #define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
741 #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
742 #if PCBREV < 2019
743 #define ADC_GPIO_PIN_POT3 GPIO_Pin_1 // PB.01
744 #define ADC_GPIOB_PINS (ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3)
745 #define ADC_CHANNEL_POT3 ADC_Channel_9
746 #define ADC_VREF_PREC2 330
747 #else
748 #define ADC_GPIOB_PINS (ADC_GPIO_PIN_POT2)
749 #define ADC_CHANNEL_POT3 0
750 #define ADC_VREF_PREC2 300
751 #endif
752 #define ADC_GPIO_PIN_SLIDER1 GPIO_Pin_4 // PC.04
753 #define ADC_GPIO_PIN_SLIDER2 GPIO_Pin_5 // PC.05
754 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
755 #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT1)
756 #define ADC_GPIOC_PINS (ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT)
757 #define ADC_CHANNEL_POT1 ADC_Channel_6
758 #define ADC_CHANNEL_POT2 ADC_Channel_8
759 #define ADC_CHANNEL_SLIDER1 ADC_Channel_14
760 #define ADC_CHANNEL_SLIDER2 ADC_Channel_15
761 #define ADC_CHANNEL_BATT ADC_Channel_10
762 #elif defined(PCBXLITE)
763 #define HARDWARE_POT1
764 #define HARDWARE_POT2
765 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
766 #define ADC_RCC_APB1Periph RCC_APB1Periph_TIM5
767 #define ADC_RCC_APB2Periph RCC_APB2Periph_ADC1
768 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
769 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
770 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_2 // PA.02
771 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_3 // PA.03
772 #define ADC_GPIO_PIN_POT1 GPIO_Pin_1 // PC.01
773 #define ADC_GPIO_PIN_POT2 GPIO_Pin_2 // PC.02
774 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
775 #define PWM_TIMER TIM5
776 #define PWM_GPIO GPIOA
777 #define PWM_GPIO_AF GPIO_AF_TIM5
778 #define PWM_IRQHandler TIM5_IRQHandler
779 #define PWM_IRQn TIM5_IRQn
780 #define PWM_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
781 #define ADC_GPIOA_PINS (STICKS_PWM_ENABLED() ? 0 : (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3))
782 #define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2)
783 #define ADC_CHANNEL_STICK_RV ADC_Channel_3 // ADC1_IN3
784 #define ADC_CHANNEL_STICK_RH ADC_Channel_2 // ADC1_IN2
785 #define ADC_CHANNEL_STICK_LV ADC_Channel_1 // ADC1_IN1
786 #define ADC_CHANNEL_STICK_LH ADC_Channel_0 // ADC1_IN0
787 #define ADC_CHANNEL_POT1 ADC_Channel_11 // ADC1_IN11
788 #define ADC_CHANNEL_POT2 ADC_Channel_12 // ADC1_IN12
789 #define ADC_CHANNEL_BATT ADC_Channel_10 // ADC1_IN10
790 #define ADC_VREF_PREC2 330
791 #elif defined(PCBX7)
792 #define HARDWARE_POT1
793 #define HARDWARE_POT2
794 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
795 #define ADC_RCC_APB1Periph 0
796 #define ADC_RCC_APB2Periph RCC_APB2Periph_ADC1
797 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
798 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
799 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_2 // PA.02
800 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_3 // PA.03
801 #define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
802 #define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
803 #define ADC_CHANNEL_STICK_LV ADC_Channel_2 // ADC1_IN2
804 #define ADC_CHANNEL_STICK_LH ADC_Channel_3 // ADC1_IN3
805 #define ADC_GPIO_PIN_POT1 GPIO_Pin_0 // PB.00
806 #define ADC_GPIO_PIN_POT2 GPIO_Pin_6 // PA.06
807 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
808 #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT2)
809 #define ADC_GPIOB_PINS ADC_GPIO_PIN_POT1
810 #define ADC_GPIOC_PINS ADC_GPIO_PIN_BATT
811 #define ADC_CHANNEL_POT1 ADC_Channel_8
812 #define ADC_CHANNEL_POT2 ADC_Channel_6
813 #define ADC_CHANNEL_BATT ADC_Channel_10
814 #define ADC_VREF_PREC2 330
815 #elif defined(PCBX9LITE)
816 #define HARDWARE_POT1
817 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
818 #define ADC_RCC_APB1Periph 0
819 #define ADC_RCC_APB2Periph RCC_APB2Periph_ADC1
820 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_0 // PA.00
821 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_1 // PA.01
822 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_2 // PA.02
823 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_3 // PA.03
824 #define ADC_CHANNEL_STICK_LH ADC_Channel_0 // ADC1_IN0
825 #define ADC_CHANNEL_STICK_LV ADC_Channel_1 // ADC1_IN1
826 #define ADC_CHANNEL_STICK_RV ADC_Channel_2 // ADC1_IN2
827 #define ADC_CHANNEL_STICK_RH ADC_Channel_3 // ADC1_IN3
828 #define ADC_GPIO_PIN_POT1 GPIO_Pin_1 // PC.01
829 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
830 #define ADC_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
831 #define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1)
832 #define ADC_CHANNEL_POT1 ADC_Channel_11 // ADC1_IN11
833 #define ADC_CHANNEL_BATT ADC_Channel_10 // ADC1_IN10
834 #define ADC_VREF_PREC2 300
835 #else
836 #define HARDWARE_POT1
837 #define HARDWARE_POT2
838 #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
839 #define ADC_RCC_APB1Periph 0
840 #define ADC_RCC_APB2Periph RCC_APB2Periph_ADC1
841 #define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
842 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
843 #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_2 // PA.02
844 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_3 // PA.03
845 #define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
846 #define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
847 #define ADC_CHANNEL_STICK_LH ADC_Channel_2 // ADC1_IN2
848 #define ADC_CHANNEL_STICK_LV ADC_Channel_3 // ADC1_IN3
849 #define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
850 #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
851 #define ADC_GPIO_PIN_SLIDER1 GPIO_Pin_4 // PC.04
852 #define ADC_GPIO_PIN_SLIDER2 GPIO_Pin_5 // PC.05
853 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
854 #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT1)
855 #define ADC_GPIOB_PINS (ADC_GPIO_PIN_POT2)
856 #define ADC_GPIOC_PINS (ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT)
857 #define ADC_CHANNEL_POT1 ADC_Channel_6
858 #define ADC_CHANNEL_POT2 ADC_Channel_8
859 #define ADC_CHANNEL_POT3 ADC_Channel_9
860 #define ADC_CHANNEL_SLIDER1 ADC_Channel_14
861 #define ADC_CHANNEL_SLIDER2 ADC_Channel_15
862 #define ADC_CHANNEL_BATT ADC_Channel_10
863 #define ADC_VREF_PREC2 330
864 #endif
866 // PWR and LED driver
867 #define PWR_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
869 #if defined(PCBX9LITE)
870 #define PWR_SWITCH_GPIO GPIOA
871 #define PWR_SWITCH_GPIO_PIN GPIO_Pin_7 // PA.07
872 #define PWR_ON_GPIO GPIOA
873 #define PWR_ON_GPIO_PIN GPIO_Pin_6 // PA.06
874 #elif defined(PCBXLITE)
875 #define PWR_SWITCH_GPIO GPIOA
876 #define PWR_SWITCH_GPIO_PIN GPIO_Pin_7 // PA.07
877 #define PWR_ON_GPIO GPIOE
878 #define PWR_ON_GPIO_PIN GPIO_Pin_9 // PE.09
879 #else
880 #define PWR_SWITCH_GPIO GPIOD
881 #define PWR_SWITCH_GPIO_PIN GPIO_Pin_1 // PD.01
882 #define PWR_ON_GPIO GPIOD
883 #define PWR_ON_GPIO_PIN GPIO_Pin_0 // PD.00
884 #endif
886 #if defined(PCBX9DP) && PCBREV >= 2019
887 #define STATUS_LEDS
888 #define GPIO_LED_GPIO_ON GPIO_ResetBits
889 #define GPIO_LED_GPIO_OFF GPIO_SetBits
890 #define LED_RED_GPIO GPIOA
891 #define LED_RED_GPIO_PIN GPIO_Pin_13 // PA.13
892 #elif defined(PCBXLITE)
893 #define STATUS_LEDS
894 #define GPIO_LED_GPIO_ON GPIO_ResetBits
895 #define GPIO_LED_GPIO_OFF GPIO_SetBits
896 #define LED_BLUE_GPIO GPIOE
897 #define LED_BLUE_GPIO_PIN GPIO_Pin_6 // PE.06
898 #define LED_RED_GPIO GPIOE
899 #define LED_RED_GPIO_PIN GPIO_Pin_4 // PE.04
900 #define LED_GREEN_GPIO GPIOE
901 #define LED_GREEN_GPIO_PIN GPIO_Pin_5 // PE.05
902 #elif defined(PCBX7)
903 #define STATUS_LEDS
904 #define GPIO_LED_GPIO_ON GPIO_SetBits
905 #define GPIO_LED_GPIO_OFF GPIO_ResetBits
906 #define LED_GREEN_GPIO GPIOC
907 #define LED_GREEN_GPIO_PIN GPIO_Pin_4 // PC.04
908 #define LED_RED_GPIO GPIOC
909 #define LED_RED_GPIO_PIN GPIO_Pin_5 // PC.05
910 #define LED_BLUE_GPIO GPIOB
911 #define LED_BLUE_GPIO_PIN GPIO_Pin_1 // PB.01
912 #elif defined(PCBX9LITES)
913 #define STATUS_LEDS
914 #define GPIO_LED_GPIO_ON GPIO_SetBits
915 #define GPIO_LED_GPIO_OFF GPIO_ResetBits
916 #define LED_RED_GPIO GPIOE
917 #define LED_RED_GPIO_PIN GPIO_Pin_5 // PE.05
918 #define LED_BLUE_GPIO GPIOE
919 #define LED_BLUE_GPIO_PIN GPIO_Pin_6 // PE.06
920 #elif defined(PCBX9LITE)
921 #define STATUS_LEDS
922 #define GPIO_LED_GPIO_ON GPIO_SetBits
923 #define GPIO_LED_GPIO_OFF GPIO_ResetBits
924 #define LED_RED_GPIO GPIOE
925 #define LED_RED_GPIO_PIN GPIO_Pin_5 // PE.05
926 #define LED_GREEN_GPIO GPIOE
927 #define LED_GREEN_GPIO_PIN GPIO_Pin_4 // PE.04
928 #define LED_BLUE_GPIO GPIOE
929 #define LED_BLUE_GPIO_PIN GPIO_Pin_6 // PE.06
930 #endif
932 // Internal Module
933 #if defined(PCBXLITE)
934 #define EXTERNAL_ANTENNA
935 #endif
936 #if defined(PCBXLITE) || defined(PCBX9LITE)
937 #define INTMODULE_RCC_APB1Periph 0
938 #define INTMODULE_RCC_APB2Periph RCC_APB2Periph_USART1
939 #if defined(PCBXLITES) || defined(PCBX9LITE)
940 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
941 #define INTMODULE_PWR_GPIO GPIOA
942 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_15 // PA.15
943 #else
944 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
945 #define INTMODULE_PWR_GPIO GPIOD
946 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_9 // PD.09
947 #endif
948 #define INTMODULE_GPIO GPIOB
949 #define INTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PB.06
950 #define INTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PB.07
951 #define INTMODULE_GPIO_PinSource_TX GPIO_PinSource6
952 #define INTMODULE_GPIO_PinSource_RX GPIO_PinSource7
953 #define INTMODULE_USART USART1
954 #define INTMODULE_GPIO_AF GPIO_AF_USART1
955 #define INTMODULE_USART_IRQHandler USART1_IRQHandler
956 #define INTMODULE_USART_IRQn USART1_IRQn
957 #define INTMODULE_DMA_STREAM DMA2_Stream7
958 #define INTMODULE_DMA_STREAM_IRQ DMA2_Stream7_IRQn
959 #define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream7_IRQHandler
960 #define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
961 #define INTMODULE_DMA_CHANNEL DMA_Channel_4
962 #if defined(PCBXLITES)
963 #define INTMODULE_BOOTCMD_GPIO GPIOC
964 #define INTMODULE_BOOTCMD_GPIO_PIN GPIO_Pin_8 // PC.08
965 #endif
966 #elif defined(PCBX9DP) && PCBREV >= 2019
967 #define INTMODULE_RCC_APB1Periph 0
968 #define INTMODULE_RCC_APB2Periph RCC_APB2Periph_USART1
969 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
970 #define INTMODULE_PWR_GPIO GPIOA
971 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_7 // PA.07
972 #define INTMODULE_GPIO GPIOB
973 #define INTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PB.06
974 #define INTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PB.07
975 #define INTMODULE_GPIO_PinSource_TX GPIO_PinSource6
976 #define INTMODULE_GPIO_PinSource_RX GPIO_PinSource7
977 #define INTMODULE_USART USART1
978 #define INTMODULE_GPIO_AF GPIO_AF_USART1
979 #define INTMODULE_USART_IRQHandler USART1_IRQHandler
980 #define INTMODULE_USART_IRQn USART1_IRQn
981 #define INTMODULE_DMA_STREAM DMA2_Stream7
982 #define INTMODULE_DMA_STREAM_IRQ DMA2_Stream7_IRQn
983 #define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream7_IRQHandler
984 #define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
985 #define INTMODULE_DMA_CHANNEL DMA_Channel_4
986 #elif defined(PCBX9E) || defined(PCBX9DP) || defined(RADIO_X7)
987 #define INTMODULE_PULSES
988 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
989 #define INTMODULE_RCC_APB1Periph 0
990 #define INTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
991 #define INTMODULE_PWR_GPIO GPIOC
992 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // PC.06
993 #define INTMODULE_TX_GPIO GPIOA
994 #define INTMODULE_TX_GPIO_PIN GPIO_Pin_10 // PA.10
995 #define INTMODULE_TX_GPIO_PinSource GPIO_PinSource10
996 #define INTMODULE_TIMER TIM1
997 #define INTMODULE_TIMER_CC_IRQn TIM1_CC_IRQn
998 #define INTMODULE_TIMER_CC_IRQHandler TIM1_CC_IRQHandler
999 #define INTMODULE_TX_GPIO_AF GPIO_AF_TIM1
1000 #define INTMODULE_DMA_CHANNEL DMA_Channel_6
1001 #define INTMODULE_DMA_STREAM DMA2_Stream5
1002 #define INTMODULE_DMA_STREAM_IRQn DMA2_Stream5_IRQn
1003 #define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream5_IRQHandler
1004 #define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
1005 #define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1006 #elif defined(RADIO_T12)
1007 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
1008 #define INTMODULE_PWR_GPIO GPIOC
1009 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_6 // PC.06
1010 #define INTMODULE_GPIO GPIOB
1011 #define INTMODULE_TX_GPIO_PIN GPIO_Pin_10 // PB.10
1012 #define INTMODULE_RX_GPIO_PIN GPIO_Pin_11 // PB.11
1013 #define INTMODULE_GPIO_PinSource_TX GPIO_PinSource10
1014 #define INTMODULE_GPIO_PinSource_RX GPIO_PinSource11
1015 #define INTMODULE_USART USART3
1016 #define INTMODULE_GPIO_AF GPIO_AF_USART3
1017 #define INTMODULE_USART_IRQn USART3_IRQn
1018 #define INTMODULE_USART_IRQHandler USART3_IRQHandler
1019 #define INTMODULE_DMA_STREAM DMA1_Stream3
1020 #define INTMODULE_DMA_STREAM_IRQ DMA1_Stream3_IRQn
1021 #define INTMODULE_DMA_STREAM_IRQHandler DMA1_Stream3_IRQHandler
1022 #define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF3
1023 #define INTMODULE_DMA_CHANNEL DMA_Channel_4
1024 #define INTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
1025 #define INTMODULE_RCC_APB2Periph RCC_APB1Periph_USART3
1026 #define INTMODULE_TIMER TIM2
1027 #define INTMODULE_TIMER_IRQn TIM2_IRQn
1028 #define INTMODULE_TIMER_IRQHandler TIM2_IRQHandler
1029 #define INTMODULE_TIMER_CC_IRQn TIM2_CC_IRQn
1030 #define INTMODULE_TIMER_CC_IRQHandler TIM2_CC_IRQHandler
1031 #define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1032 #else
1033 #define INTMODULE_PULSES
1034 #define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1035 #define INTMODULE_RCC_APB1Periph 0
1036 #define INTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM1
1037 #define INTMODULE_PWR_GPIO GPIOD
1038 #define INTMODULE_PWR_GPIO_PIN GPIO_Pin_15 // PD.15
1039 #define INTMODULE_TX_GPIO GPIOA
1040 #define INTMODULE_TX_GPIO_PIN GPIO_Pin_10 // PA.10
1041 #define INTMODULE_TX_GPIO_PinSource GPIO_PinSource10
1042 #define INTMODULE_TIMER TIM1
1043 #define INTMODULE_TIMER_CC_IRQn TIM1_CC_IRQn
1044 #define INTMODULE_TIMER_CC_IRQHandler TIM1_CC_IRQHandler
1045 #define INTMODULE_TX_GPIO_AF GPIO_AF_TIM1
1046 #define INTMODULE_DMA_CHANNEL DMA_Channel_6
1047 #define INTMODULE_DMA_STREAM DMA2_Stream5
1048 #define INTMODULE_DMA_STREAM_IRQn DMA2_Stream5_IRQn
1049 #define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream5_IRQHandler
1050 #define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF5
1051 #define INTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1052 #endif
1054 // External Module
1055 #if defined(PCBXLITE) || defined(PCBX9LITE) || (defined(PCBX9DP) && PCBREV >= 2019)
1056 #define EXTMODULE_RCC_APB2Periph (RCC_APB2Periph_TIM8 | RCC_APB2Periph_USART6)
1057 #if defined(PCBX9DP) && PCBREV >= 2019
1058 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1059 #define EXTMODULE_PWR_GPIO GPIOD
1060 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PD.08
1061 #elif defined(PCBX9LITE)
1062 #define HARDWARE_EXTERNAL_MODULE_SIZE_SML
1063 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2)
1064 #define EXTMODULE_PWR_GPIO GPIOA
1065 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PA.08
1066 #else
1067 #define HARDWARE_EXTERNAL_MODULE_SIZE_SML
1068 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1069 #define EXTMODULE_PWR_GPIO GPIOD
1070 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_11 // PD.11
1071 #endif
1072 #define EXTERNAL_MODULE_PWR_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1073 #define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1074 #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET)
1075 #define EXTMODULE_TX_GPIO GPIOC
1076 #define EXTMODULE_USART_GPIO EXTMODULE_TX_GPIO
1077 #define EXTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PC.06
1078 #define EXTMODULE_TX_GPIO_PinSource GPIO_PinSource6
1079 #define EXTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PC.07
1080 #define EXTMODULE_RX_GPIO_PinSource GPIO_PinSource7
1081 #define EXTMODULE_TIMER TIM8
1082 #define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1083 #define EXTMODULE_TIMER_CC_IRQn TIM8_CC_IRQn
1084 #define EXTMODULE_TIMER_CC_IRQHandler TIM8_CC_IRQHandler
1085 #define EXTMODULE_TIMER_TX_GPIO_AF GPIO_AF_TIM8 // TIM8_CH1
1086 #define EXTMODULE_TIMER_DMA_CHANNEL DMA_Channel_7
1087 #define EXTMODULE_TIMER_DMA_STREAM DMA2_Stream1
1088 #define EXTMODULE_TIMER_DMA_STREAM_IRQn DMA2_Stream1_IRQn
1089 #define EXTMODULE_TIMER_DMA_STREAM_IRQHandler DMA2_Stream1_IRQHandler
1090 #define EXTMODULE_TIMER_DMA_FLAG_TC DMA_IT_TCIF1
1091 #define EXTMODULE_TIMER_OUTPUT_ENABLE TIM_CCER_CC1E
1092 #define EXTMODULE_TIMER_OUTPUT_POLARITY TIM_CCER_CC1P
1093 #define EXTMODULE_USART_GPIO_AF GPIO_AF_USART6
1094 #define EXTMODULE_USART USART6
1095 #define EXTMODULE_USART_IRQn USART6_IRQn
1096 #define EXTMODULE_USART_IRQHandler USART6_IRQHandler
1097 #define EXTMODULE_USART_TX_DMA_CHANNEL DMA_Channel_5
1098 #define EXTMODULE_USART_TX_DMA_STREAM DMA2_Stream6
1099 #define EXTMODULE_USART_RX_DMA_CHANNEL DMA_Channel_5
1100 #define EXTMODULE_USART_RX_DMA_STREAM DMA2_Stream1
1101 #elif defined(RADIO_T12)
1102 //Jumper T12v2 external module configured
1103 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1104 #define EXTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM8
1105 #define EXTMODULE_PWR_GPIO GPIOD
1106 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // JUMPER EXT PD.08 // X7 EXT is PD.08
1107 #define EXTERNAL_MODULE_PWR_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1108 #define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1109 #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET)
1110 #define EXTMODULE_TX_GPIO GPIOA
1111 #define EXTMODULE_TX_GPIO_PIN GPIO_Pin_7 // JUMPER EXT PA.07 // X7 EXT is PA.07
1112 #define EXTMODULE_TX_GPIO_PinSource GPIO_PinSource7
1113 #define EXTMODULE_TIMER TIM8
1114 #define EXTMODULE_TIMER_TX_GPIO_AF GPIO_AF_TIM8 // TIM8_CH1N
1115 #define EXTMODULE_TIMER_CC_IRQn TIM8_CC_IRQn
1116 #define EXTMODULE_TIMER_CC_IRQHandler TIM8_CC_IRQHandler
1117 #define EXTMODULE_TIMER_DMA_CHANNEL DMA_Channel_7
1118 #define EXTMODULE_TIMER_DMA_STREAM DMA2_Stream1
1119 #define EXTMODULE_TIMER_DMA_STREAM_IRQn DMA2_Stream1_IRQn
1120 #define EXTMODULE_TIMER_DMA_STREAM_IRQHandler DMA2_Stream1_IRQHandler
1121 #define EXTMODULE_TIMER_DMA_FLAG_TC DMA_IT_TCIF1
1122 #define EXTMODULE_TIMER_OUTPUT_ENABLE TIM_CCER_CC1NE
1123 #define EXTMODULE_TIMER_OUTPUT_POLARITY TIM_CCER_CC1NP
1124 #define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1125 #elif defined(PCBX9DP) && PCBREV >= 2019
1126 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1127 #define EXTMODULE_RCC_APB2Periph (RCC_APB2Periph_TIM8 | RCC_APB2Periph_USART6)
1128 #define EXTMODULE_PWR_GPIO GPIOD
1129 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PD.08
1130 #define EXTERNAL_MODULE_PWR_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1131 #define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1132 #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET)
1133 #define EXTMODULE_TX_GPIO GPIOC
1134 #define EXTMODULE_TX_GPIO_PIN GPIO_Pin_7 // PC.07
1135 #define EXTMODULE_TX_GPIO_PinSource GPIO_PinSource7
1136 #define EXTMODULE_TIMER TIM8
1137 #define EXTMODULE_TIMER_TX_GPIO_AF GPIO_AF_TIM8 // TIM8_CH2
1138 #define EXTMODULE_TIMER_CC_IRQn TIM8_CC_IRQn
1139 #define EXTMODULE_TIMER_CC_IRQHandler TIM8_CC_IRQHandler
1140 #define EXTMODULE_TIMER_DMA_CHANNEL DMA_Channel_7 // TIM8_UP
1141 #define EXTMODULE_TIMER_DMA_STREAM DMA2_Stream1 // TIM8_UP
1142 #define EXTMODULE_TIMER_DMA_STREAM_IRQn DMA2_Stream1_IRQn
1143 #define EXTMODULE_TIMER_DMA_STREAM_IRQHandler DMA2_Stream1_IRQHandler
1144 #define EXTMODULE_TIMER_DMA_FLAG_TC DMA_IT_TCIF1
1145 #define EXTMODULE_TIMER_OUTPUT_ENABLE TIM_CCER_CC2E
1146 #define EXTMODULE_TIMER_OUTPUT_POLARITY TIM_CCER_CC2NP
1147 #define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1148 #else
1149 #define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
1150 #define EXTMODULE_RCC_APB2Periph RCC_APB2Periph_TIM8
1151 #define EXTMODULE_PWR_GPIO GPIOD
1152 #define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PD.08
1153 #define EXTERNAL_MODULE_PWR_ON() GPIO_SetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1154 #define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
1155 #define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET)
1156 #define EXTMODULE_TX_GPIO GPIOA
1157 #define EXTMODULE_TX_GPIO_PIN GPIO_Pin_7 // PA.07
1158 #define EXTMODULE_TX_GPIO_PinSource GPIO_PinSource7
1159 #define EXTMODULE_TIMER TIM8
1160 #define EXTMODULE_TIMER_TX_GPIO_AF GPIO_AF_TIM8 // TIM8_CH1N
1161 #define EXTMODULE_TIMER_CC_IRQn TIM8_CC_IRQn
1162 #define EXTMODULE_TIMER_CC_IRQHandler TIM8_CC_IRQHandler
1163 #define EXTMODULE_TIMER_DMA_CHANNEL DMA_Channel_7 // TIM8_UP
1164 #define EXTMODULE_TIMER_DMA_STREAM DMA2_Stream1 // TIM8_UP
1165 #define EXTMODULE_TIMER_DMA_STREAM_IRQn DMA2_Stream1_IRQn
1166 #define EXTMODULE_TIMER_DMA_STREAM_IRQHandler DMA2_Stream1_IRQHandler
1167 #define EXTMODULE_TIMER_DMA_FLAG_TC DMA_IT_TCIF1
1168 #define EXTMODULE_TIMER_OUTPUT_ENABLE TIM_CCER_CC1NE
1169 #define EXTMODULE_TIMER_OUTPUT_POLARITY TIM_CCER_CC1NP
1170 #define EXTMODULE_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1171 #endif
1173 // Trainer Port
1174 #if defined(PCBXLITES) || defined(PCBX9LITE)
1175 // on these 2 radios the trainer port already uses DMA1_Stream6, we won't use the DMA
1176 #define TRAINER_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1177 #define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM4
1178 #define TRAINER_GPIO GPIOD
1179 #define TRAINER_IN_GPIO_PIN GPIO_Pin_13 // PD.13
1180 #define TRAINER_IN_GPIO_PinSource GPIO_PinSource13
1181 #define TRAINER_OUT_GPIO_PIN GPIO_Pin_12 // PD.12
1182 #define TRAINER_OUT_GPIO_PinSource GPIO_PinSource12
1183 #if defined(PCBX9LITE)
1184 #define TRAINER_DETECT_GPIO GPIOD
1185 #define TRAINER_DETECT_GPIO_PIN GPIO_Pin_11 // PD.11
1186 #endif
1187 #define TRAINER_TIMER TIM4
1188 #define TRAINER_GPIO_AF GPIO_AF_TIM4 // TIM4_CH1 (Out) + TIM4_CH2 (In)
1189 #define TRAINER_TIMER_IRQn TIM4_IRQn
1190 #define TRAINER_TIMER_IRQHandler TIM4_IRQHandler
1191 #define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
1192 #define TRAINER_OUT_CCMR1 TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1PE;
1193 #define TRAINER_IN_CCMR1 TIM_CCMR1_IC2F_0 | TIM_CCMR1_IC2F_1 | TIM_CCMR1_CC2S_0;
1194 #define TRAINER_OUT_COUNTER_REGISTER TRAINER_TIMER->CCR1
1195 #define TRAINER_IN_COUNTER_REGISTER TRAINER_TIMER->CCR2
1196 #define TRAINER_SETUP_REGISTER TRAINER_TIMER->CCR3
1197 #define TRAINER_OUT_INTERRUPT_FLAG TIM_SR_CC3IF
1198 #define TRAINER_OUT_INTERRUPT_ENABLE TIM_DIER_CC3IE
1199 #define TRAINER_IN_INTERRUPT_ENABLE TIM_DIER_CC2IE
1200 #define TRAINER_IN_INTERRUPT_FLAG TIM_SR_CC2IF
1201 #define TRAINER_OUT_CCER TIM_CCER_CC1E
1202 #define TRAINER_CCER_POLARYTY TIM_CCER_CC1P
1203 #define TRAINER_IN_CCER TIM_CCER_CC2E
1204 #elif defined(PCBXLITE)
1205 #define TRAINER_TIMER TIM4
1206 #define TRAINER_RCC_AHB1Periph 0
1207 #define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM4
1208 #define TRAINER_TIMER_IRQn TIM4_IRQn
1209 #define TRAINER_TIMER_IRQHandler TIM4_IRQHandler
1210 #else
1211 #define TRAINER_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA1)
1212 #define TRAINER_RCC_APB1Periph RCC_APB1Periph_TIM3
1213 #define TRAINER_GPIO GPIOC
1214 #define TRAINER_IN_GPIO_PIN GPIO_Pin_8 // PC.08
1215 #define TRAINER_IN_GPIO_PinSource GPIO_PinSource8
1216 #define TRAINER_OUT_GPIO_PIN GPIO_Pin_9 // PC.09
1217 #define TRAINER_OUT_GPIO_PinSource GPIO_PinSource9
1218 #define TRAINER_DETECT_GPIO GPIOA
1219 #define TRAINER_DETECT_GPIO_PIN GPIO_Pin_8 // PA.08
1220 #define TRAINER_TIMER TIM3
1221 #define TRAINER_TIMER_IRQn TIM3_IRQn
1222 #define TRAINER_GPIO_AF GPIO_AF_TIM3
1223 #define TRAINER_DMA DMA1
1224 #define TRAINER_DMA_CHANNEL DMA_Channel_5
1225 #define TRAINER_DMA_STREAM DMA1_Stream2
1226 #define TRAINER_DMA_IRQn DMA1_Stream2_IRQn
1227 #define TRAINER_DMA_IRQHandler DMA1_Stream2_IRQHandler
1228 #define TRAINER_DMA_FLAG_TC DMA_IT_TCIF2
1229 #define TRAINER_TIMER_IRQn TIM3_IRQn
1230 #define TRAINER_TIMER_IRQHandler TIM3_IRQHandler
1231 #define TRAINER_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
1232 #define TRAINER_OUT_CCMR2 TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4PE;
1233 #define TRAINER_IN_CCMR2 TIM_CCMR2_IC3F_0 | TIM_CCMR2_IC3F_1 | TIM_CCMR2_CC3S_0;
1234 #define TRAINER_OUT_COUNTER_REGISTER TRAINER_TIMER->CCR4
1235 #define TRAINER_IN_COUNTER_REGISTER TRAINER_TIMER->CCR3
1236 #define TRAINER_SETUP_REGISTER TRAINER_TIMER->CCR1
1237 #define TRAINER_OUT_INTERRUPT_FLAG TIM_SR_CC1IF
1238 #define TRAINER_OUT_INTERRUPT_ENABLE TIM_DIER_CC1IE
1239 #define TRAINER_IN_INTERRUPT_ENABLE TIM_DIER_CC3IE
1240 #define TRAINER_IN_INTERRUPT_FLAG TIM_SR_CC3IF
1241 #define TRAINER_OUT_CCER TIM_CCER_CC4E
1242 #define TRAINER_IN_CCER TIM_CCER_CC3E
1243 #define TRAINER_CCER_POLARYTY TIM_CCER_CC4P
1244 #endif
1246 // Serial Port
1247 #if defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) || (defined(PCBX9DP) && PCBREV >= 2019)
1248 #define AUX_SERIAL_RCC_AHB1Periph 0
1249 #define AUX_SERIAL_RCC_APB1Periph 0
1250 #else
1251 #define TRAINER_BATTERY_COMPARTMENT
1252 #define AUX_SERIAL_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
1253 #define AUX_SERIAL_RCC_APB1Periph RCC_APB1Periph_USART3
1254 #define AUX_SERIAL_GPIO GPIOB
1255 #define AUX_SERIAL_GPIO_PIN_TX GPIO_Pin_10 // PB.10
1256 #define AUX_SERIAL_GPIO_PIN_RX GPIO_Pin_11 // PB.11
1257 #define AUX_SERIAL_GPIO_PinSource_TX GPIO_PinSource10
1258 #define AUX_SERIAL_GPIO_PinSource_RX GPIO_PinSource11
1259 #define AUX_SERIAL_GPIO_AF GPIO_AF_USART3
1260 #define AUX_SERIAL_USART USART3
1261 #define AUX_SERIAL_USART_IRQHandler USART3_IRQHandler
1262 #define AUX_SERIAL_USART_IRQn USART3_IRQn
1263 #define AUX_SERIAL_DMA_Stream_RX DMA1_Stream1
1264 #define AUX_SERIAL_DMA_Channel_RX DMA_Channel_4
1265 #endif
1267 // Telemetry
1268 #define TELEMETRY_RCC_AHB1Periph (RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
1269 #define TELEMETRY_RCC_APB1Periph RCC_APB1Periph_USART2
1270 #define TELEMETRY_DIR_GPIO GPIOD
1271 #define TELEMETRY_DIR_GPIO_PIN GPIO_Pin_4 // PD.04
1272 #if defined(PCBXLITE) || defined(PCBX9LITE) || (defined(PCBX9DP) && PCBREV >= 2019)
1273 #define TELEMETRY_DIR_OUTPUT() TELEMETRY_DIR_GPIO->BSRRH = TELEMETRY_DIR_GPIO_PIN
1274 #define TELEMETRY_DIR_INPUT() TELEMETRY_DIR_GPIO->BSRRL = TELEMETRY_DIR_GPIO_PIN
1275 #else
1276 #define TELEMETRY_DIR_OUTPUT() TELEMETRY_DIR_GPIO->BSRRL = TELEMETRY_DIR_GPIO_PIN
1277 #define TELEMETRY_DIR_INPUT() TELEMETRY_DIR_GPIO->BSRRH = TELEMETRY_DIR_GPIO_PIN
1278 #endif
1279 #define TELEMETRY_GPIO GPIOD
1280 #define TELEMETRY_TX_GPIO_PIN GPIO_Pin_5 // PD.05
1281 #define TELEMETRY_RX_GPIO_PIN GPIO_Pin_6 // PD.06
1282 #define TELEMETRY_GPIO_PinSource_TX GPIO_PinSource5
1283 #define TELEMETRY_GPIO_PinSource_RX GPIO_PinSource6
1284 #define TELEMETRY_GPIO_AF GPIO_AF_USART2
1285 #define TELEMETRY_USART USART2
1286 #define TELEMETRY_DMA_Stream_TX DMA1_Stream6
1287 #define TELEMETRY_DMA_Channel_TX DMA_Channel_4
1288 #define TELEMETRY_DMA_TX_Stream_IRQ DMA1_Stream6_IRQn
1289 #define TELEMETRY_DMA_TX_IRQHandler DMA1_Stream6_IRQHandler
1290 #define TELEMETRY_DMA_TX_FLAG_TC DMA_IT_TCIF6
1291 #define TELEMETRY_USART_IRQHandler USART2_IRQHandler
1292 #define TELEMETRY_USART_IRQn USART2_IRQn
1293 #define TELEMETRY_EXTI_PortSource EXTI_PortSourceGPIOD
1294 #define TELEMETRY_EXTI_PinSource EXTI_PinSource6
1295 #define TELEMETRY_EXTI_LINE EXTI_Line6
1296 #define TELEMETRY_EXTI_IRQn EXTI9_5_IRQn
1297 #define TELEMETRY_EXTI_TRIGGER EXTI_Trigger_Rising
1299 #if defined(RADIO_X7)
1300 #define TELEMETRY_EXTI_REUSE_INTERRUPT_ROTARY_ENCODER
1301 #elif defined(PCBXLITE) || defined(PCBX9LITE) || (defined(PCBX9DP) && PCBREV >= 2019)
1302 #define TELEMETRY_EXTI_IRQHandler EXTI9_5_IRQHandler
1303 #else
1304 #define TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT
1305 #endif
1307 #define TELEMETRY_TIMER TIM11
1308 #define TELEMETRY_TIMER_IRQn TIM1_TRG_COM_TIM11_IRQn
1309 #define TELEMETRY_TIMER_IRQHandler TIM1_TRG_COM_TIM11_IRQHandler
1311 // PCBREV
1312 #if defined(PCBX7)
1313 #define PCBREV_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
1314 #define PCBREV_GPIO GPIOA
1315 #define PCBREV_GPIO_PIN GPIO_Pin_14 // PA.14
1316 #else
1317 #define PCBREV_RCC_AHB1Periph 0
1318 #endif
1320 // S.Port update connector
1321 #if defined(PCBXLITE)
1322 #define SPORT_MAX_BAUDRATE 250000 // not tested
1323 #define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1324 #define SPORT_UPDATE_PWR_GPIO GPIOD
1325 #define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_8 // PD.08
1326 #define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
1327 #define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
1328 #elif defined(PCBX7)
1329 #define SPORT_MAX_BAUDRATE 250000 // < 400000
1330 #define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1331 #define SPORT_UPDATE_PWR_GPIO GPIOB
1332 #define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_2 // PB.02
1333 #define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
1334 #define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
1335 #elif defined(PCBX9LITE)
1336 #define SPORT_MAX_BAUDRATE 250000 // not tested
1337 #define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOE
1338 #define SPORT_UPDATE_PWR_GPIO GPIOE
1339 #define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_15 // PE.15
1340 #define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
1341 #define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
1342 #elif defined(PCBX9DP) && PCBREV >= 2019
1343 #define SPORT_MAX_BAUDRATE 400000
1344 #define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
1345 #define SPORT_UPDATE_PWR_GPIO GPIOA
1346 #define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_14 // PA.14
1347 #define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
1348 #define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
1349 #else
1350 #define SPORT_MAX_BAUDRATE 400000
1351 #define SPORT_UPDATE_RCC_AHB1Periph 0
1352 #endif
1354 // Heartbeat for iXJT / ISRM synchro
1355 #define INTMODULE_HEARTBEAT_TRIGGER EXTI_Trigger_Falling
1356 #if defined(PCBXLITE)
1357 #define INTMODULE_HEARTBEAT
1358 #define INTMODULE_HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1359 #define INTMODULE_HEARTBEAT_GPIO GPIOD
1360 #define INTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_15
1361 #define INTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOD
1362 #define INTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource15
1363 #define INTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line15
1364 #define INTMODULE_HEARTBEAT_EXTI_IRQn EXTI15_10_IRQn
1365 #define INTMODULE_HEARTBEAT_EXTI_IRQHandler EXTI15_10_IRQHandler
1366 #elif defined(PCBX9LITE)
1367 // #define INTMODULE_HEARTBEAT
1368 #define INTMODULE_HEARTBEAT_RCC_AHB1Periph 0 // RCC_AHB1Periph_GPIOC
1369 // #define INTMODULE_HEARTBEAT_GPIO GPIOC
1370 // #define INTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_9
1371 // #define INTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOC
1372 // #define INTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource9
1373 // #define INTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line9
1374 // #define INTMODULE_HEARTBEAT_EXTI_IRQn EXTI9_5_IRQn
1375 // #define INTMODULE_HEARTBEAT_EXTI_IRQHandler EXTI9_5_IRQHandler
1376 #elif defined(RADIO_X7)
1377 #define INTMODULE_HEARTBEAT
1378 #define INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER
1379 #define INTMODULE_HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOC
1380 #define INTMODULE_HEARTBEAT_GPIO GPIOC
1381 #define INTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_7
1382 #define INTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOC
1383 #define INTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource7
1384 #define INTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line7
1385 #define INTMODULE_HEARTBEAT_EXTI_IRQn EXTI9_5_IRQn
1386 #elif defined(PCBX9DP) && PCBREV >= 2019
1387 #define INTMODULE_HEARTBEAT
1388 #define INTMODULE_HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1389 #define INTMODULE_HEARTBEAT_GPIO GPIOB
1390 #define INTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_1 // PB.01
1391 #define INTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOB
1392 #define INTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource1
1393 #define INTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line1
1394 #define INTMODULE_HEARTBEAT_EXTI_IRQn EXTI1_IRQn
1395 #define INTMODULE_HEARTBEAT_EXTI_IRQHandler EXTI1_IRQHandler
1396 #else
1397 #define INTMODULE_HEARTBEAT
1398 #define INTMODULE_HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOC
1399 #define INTMODULE_HEARTBEAT_GPIO GPIOC
1400 #define INTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_7
1401 #define INTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOC
1402 #define INTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource7
1403 #define INTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line7
1404 #define INTMODULE_HEARTBEAT_EXTI_IRQn EXTI9_5_IRQn
1405 #define INTMODULE_HEARTBEAT_EXTI_IRQHandler EXTI9_5_IRQHandler
1406 #endif
1408 #if defined(PCBX9LITE)
1409 #define EXTMODULE_HEARTBEAT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1410 #define EXTMODULE_HEARTBEAT_GPIO GPIOD
1411 #define EXTMODULE_HEARTBEAT_GPIO_PIN GPIO_Pin_15
1412 #define EXTMODULE_HEARTBEAT_EXTI_PortSource EXTI_PortSourceGPIOD
1413 #define EXTMODULE_HEARTBEAT_EXTI_PinSource GPIO_PinSource15
1414 #define EXTMODULE_HEARTBEAT_EXTI_LINE EXTI_Line15
1415 #define EXTMODULE_HEARTBEAT_EXTI_IRQn EXTI15_10_IRQn
1416 #define EXTMODULE_HEARTBEAT_EXTI_IRQHandler EXTI15_10_IRQHandler
1417 #endif
1419 // Trainer / Trainee from the module bay
1420 #if defined(PCBX9LITE) || defined(PCBXLITE)
1421 #define TRAINER_MODULE_CPPM
1422 #define TRAINER_MODULE_SBUS
1423 #define TRAINER_MODULE_RCC_AHB1Periph 0
1424 #define TRAINER_MODULE_RCC_APB1Periph RCC_APB1Periph_TIM3
1425 #define TRAINER_MODULE_RCC_APB2Periph 0
1426 #define TRAINER_MODULE_CPPM_GPIO EXTMODULE_USART_GPIO
1427 #define TRAINER_MODULE_CPPM_GPIO_PIN EXTMODULE_RX_GPIO_PIN
1428 #define TRAINER_MODULE_CPPM_GPIO_PinSource EXTMODULE_RX_GPIO_PinSource
1429 #define TRAINER_MODULE_CPPM_GPIO_AF GPIO_AF_TIM3
1430 #define TRAINER_MODULE_CPPM_TIMER TIM3
1431 #define TRAINER_MODULE_CPPM_COUNTER_REGISTER TRAINER_MODULE_CPPM_TIMER->CCR2
1432 #define TRAINER_MODULE_CPPM_INTERRUPT_ENABLE TIM_DIER_CC2IE
1433 #define TRAINER_MODULE_CPPM_INTERRUPT_FLAG TIM_SR_CC2IF
1434 #define TRAINER_MODULE_CPPM_CCMR1 (TIM_CCMR1_IC2F_0 | TIM_CCMR1_IC2F_1 | TIM_CCMR1_CC2S_0)
1435 #define TRAINER_MODULE_CPPM_CCER TIM_CCER_CC2E
1436 #define TRAINER_MODULE_CPPM_TIMER_IRQn TIM3_IRQn
1437 #define TRAINER_MODULE_CPPM_TIMER_IRQHandler TIM3_IRQHandler
1438 #define TRAINER_MODULE_SBUS_GPIO EXTMODULE_USART_GPIO
1439 #define TRAINER_MODULE_SBUS_GPIO_PIN EXTMODULE_RX_GPIO_PIN
1440 #define TRAINER_MODULE_SBUS_GPIO_AF EXTMODULE_USART_GPIO_AF
1441 #define TRAINER_MODULE_SBUS_USART EXTMODULE_USART
1442 #define TRAINER_MODULE_SBUS_GPIO_PinSource EXTMODULE_RX_GPIO_PinSource
1443 #define TRAINER_MODULE_SBUS_DMA_STREAM EXTMODULE_USART_RX_DMA_STREAM
1444 #define TRAINER_MODULE_SBUS_DMA_CHANNEL EXTMODULE_USART_RX_DMA_CHANNEL
1445 #else
1446 #define TRAINER_MODULE_CPPM
1447 #define TRAINER_MODULE_SBUS
1448 #define TRAINER_MODULE_RCC_AHB1Periph RCC_AHB1Periph_GPIOC
1449 #define TRAINER_MODULE_RCC_APB2Periph RCC_APB2Periph_USART6
1450 #define TRAINER_MODULE_RCC_APB1Periph RCC_APB1Periph_TIM3
1451 #define TRAINER_MODULE_CPPM_TIMER TRAINER_TIMER
1452 #define TRAINER_MODULE_CPPM_GPIO INTMODULE_HEARTBEAT_GPIO
1453 #define TRAINER_MODULE_CPPM_GPIO_PIN INTMODULE_HEARTBEAT_GPIO_PIN
1454 #define TRAINER_MODULE_CPPM_GPIO_PinSource INTMODULE_HEARTBEAT_EXTI_PinSource
1455 #define TRAINER_MODULE_CPPM_INTERRUPT_ENABLE TIM_DIER_CC2IE
1456 #define TRAINER_MODULE_CPPM_INTERRUPT_FLAG TIM_SR_CC2IF
1457 #define TRAINER_MODULE_CPPM_CCMR1 (TIM_CCMR1_IC2F_0 | TIM_CCMR1_IC2F_1 | TIM_CCMR1_CC2S_0)
1458 #define TRAINER_MODULE_CPPM_CCER TIM_CCER_CC2E
1459 #define TRAINER_MODULE_CPPM_COUNTER_REGISTER TRAINER_TIMER->CCR2
1460 #define TRAINER_MODULE_CPPM_TIMER_IRQn TRAINER_TIMER_IRQn
1461 #define TRAINER_MODULE_CPPM_GPIO_AF GPIO_AF_TIM3
1462 #define TRAINER_MODULE_SBUS_GPIO_AF GPIO_AF_USART6
1463 #define TRAINER_MODULE_SBUS_USART USART6
1464 #define TRAINER_MODULE_SBUS_GPIO INTMODULE_HEARTBEAT_GPIO
1465 #define TRAINER_MODULE_SBUS_GPIO_PIN INTMODULE_HEARTBEAT_GPIO_PIN
1466 #define TRAINER_MODULE_SBUS_GPIO_PinSource INTMODULE_HEARTBEAT_EXTI_PinSource
1467 #define TRAINER_MODULE_SBUS_DMA_STREAM DMA2_Stream1
1468 #define TRAINER_MODULE_SBUS_DMA_CHANNEL DMA_Channel_5
1469 #endif
1471 // USB
1472 #define USB_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOA
1473 #define USB_GPIO GPIOA
1474 #define USB_GPIO_PIN_VBUS GPIO_Pin_9 // PA.09
1475 #define USB_GPIO_PIN_DM GPIO_Pin_11 // PA.11
1476 #define USB_GPIO_PIN_DP GPIO_Pin_12 // PA.12
1477 #define USB_GPIO_PinSource_DM GPIO_PinSource11
1478 #define USB_GPIO_PinSource_DP GPIO_PinSource12
1479 #define USB_GPIO_AF GPIO_AF_OTG1_FS
1481 // BackLight
1482 #if defined(PCBX9E)
1483 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOE
1484 #define BACKLIGHT_RCC_APB1Periph 0
1485 #define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM9
1486 #define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1487 #define BACKLIGHT_TIMER TIM9
1488 #define BACKLIGHT_GPIO GPIOE
1489 #define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_6 // PE.06
1490 #define BACKLIGHT_GPIO_PIN_2 GPIO_Pin_5 // PE.05
1491 #define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource6
1492 #define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource5
1493 #define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM9
1494 #define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM9
1495 #elif defined(PCBX9DP)
1496 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1497 #define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM4
1498 #define BACKLIGHT_RCC_APB2Periph 0
1499 #define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
1500 #define BACKLIGHT_TIMER TIM4
1501 #define BACKLIGHT_GPIO GPIOD
1502 #define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_15 // PD.15
1503 #define BACKLIGHT_GPIO_PIN_2 GPIO_Pin_13 // PD.13
1504 #define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource15
1505 #define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource13
1506 #define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM4
1507 #define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM4
1508 #elif defined(PCBXLITES) || defined(PCBX9LITE)
1509 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
1510 #define BACKLIGHT_RCC_APB1Periph 0
1511 #define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM1
1512 #define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1513 #define BACKLIGHT_TIMER TIM1
1514 #define BACKLIGHT_GPIO GPIOA
1515 #define BACKLIGHT_GPIO_PIN GPIO_Pin_10 // PA.10
1516 #define BACKLIGHT_GPIO_PinSource GPIO_PinSource10
1517 #define BACKLIGHT_GPIO_AF GPIO_AF_TIM1
1518 #define BACKLIGHT_CCMR2 TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2 // Channel 3, PWM
1519 #define BACKLIGHT_CCER TIM_CCER_CC3E
1520 #define BACKLIGHT_COUNTER_REGISTER BACKLIGHT_TIMER->CCR3
1521 #elif defined(PCBXLITE)
1522 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
1523 #define BACKLIGHT_RCC_APB1Periph 0
1524 #define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM1
1525 #define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1526 #define BACKLIGHT_TIMER TIM1
1527 #define BACKLIGHT_GPIO GPIOA
1528 #define BACKLIGHT_GPIO_PIN GPIO_Pin_8 // PA.08
1529 #define BACKLIGHT_GPIO_PinSource GPIO_PinSource8
1530 #define BACKLIGHT_GPIO_AF GPIO_AF_TIM1
1531 #define BACKLIGHT_CCMR1 TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 // Channel 1, PWM
1532 #define BACKLIGHT_CCER TIM_CCER_CC1E
1533 #define BACKLIGHT_COUNTER_REGISTER BACKLIGHT_TIMER->CCR1
1534 #elif defined(PCBX7)
1535 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1536 #define BACKLIGHT_RCC_APB1Periph RCC_APB1Periph_TIM4
1537 #define BACKLIGHT_RCC_APB2Periph 0
1538 #define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
1539 #define BACKLIGHT_TIMER TIM4
1540 #define BACKLIGHT_GPIO GPIOD
1541 #define BACKLIGHT_GPIO_PIN GPIO_Pin_13 // PD.13
1542 #define BACKLIGHT_GPIO_PinSource GPIO_PinSource13
1543 #define BACKLIGHT_GPIO_AF GPIO_AF_TIM4
1544 #define BACKLIGHT_CCMR1 TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 // Channel2, PWM
1545 #define BACKLIGHT_CCER TIM_CCER_CC2E
1546 #define BACKLIGHT_COUNTER_REGISTER BACKLIGHT_TIMER->CCR2
1547 #else
1548 #define BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1549 #define BACKLIGHT_RCC_APB1Periph 0
1550 #define BACKLIGHT_RCC_APB2Periph RCC_APB2Periph_TIM10
1551 #define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1552 #define BACKLIGHT_TIMER TIM10
1553 #define BACKLIGHT_GPIO GPIOB
1554 #define BACKLIGHT_GPIO_PIN GPIO_Pin_8 // PB.08
1555 #define BACKLIGHT_GPIO_PinSource GPIO_PinSource8
1556 #define BACKLIGHT_GPIO_AF GPIO_AF_TIM10
1557 #endif
1559 // LCD driver
1560 #if defined(PCBX9E)
1561 #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
1562 #define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3
1563 #define LCD_SPI_GPIO GPIOC
1564 #define LCD_MOSI_GPIO_PIN GPIO_Pin_12 // PC.12
1565 #define LCD_MOSI_GPIO_PinSource GPIO_PinSource12
1566 #define LCD_CLK_GPIO_PIN GPIO_Pin_10 // PC.10
1567 #define LCD_CLK_GPIO_PinSource GPIO_PinSource10
1568 #define LCD_A0_GPIO_PIN GPIO_Pin_11 // PC.11
1569 #define LCD_NCS_GPIO GPIOA
1570 #define LCD_NCS_GPIO_PIN GPIO_Pin_15 // PA.15
1571 #define LCD_RST_GPIO GPIOD
1572 #define LCD_RST_GPIO_PIN GPIO_Pin_15 // PD.15
1573 #define LCD_DMA DMA1
1574 #define LCD_DMA_Stream DMA1_Stream7
1575 #define LCD_DMA_Stream_IRQn DMA1_Stream7_IRQn
1576 #define LCD_DMA_Stream_IRQHandler DMA1_Stream7_IRQHandler
1577 #define LCD_DMA_FLAGS (DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7)
1578 #define LCD_DMA_FLAG_INT DMA_HIFCR_CTCIF7
1579 #define LCD_SPI SPI3
1580 #define LCD_GPIO_AF GPIO_AF_SPI3
1581 #elif defined(PCBXLITE) || defined(PCBX9LITE)
1582 #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
1583 #define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3
1584 #define LCD_SPI_GPIO GPIOC
1585 #define LCD_MOSI_GPIO_PIN GPIO_Pin_12 // PC.12
1586 #define LCD_MOSI_GPIO_PinSource GPIO_PinSource12
1587 #define LCD_CLK_GPIO_PIN GPIO_Pin_10 // PC.10
1588 #define LCD_CLK_GPIO_PinSource GPIO_PinSource10
1589 #define LCD_A0_GPIO_PIN GPIO_Pin_11 // PC.11
1590 #define LCD_NCS_GPIO GPIOD
1591 #define LCD_NCS_GPIO_PIN GPIO_Pin_3 // PD.03
1592 #define LCD_RST_GPIO GPIOD
1593 #define LCD_RST_GPIO_PIN GPIO_Pin_2 // PD.02
1594 #define LCD_DMA DMA1
1595 #define LCD_DMA_Stream DMA1_Stream7
1596 #define LCD_DMA_Stream_IRQn DMA1_Stream7_IRQn
1597 #define LCD_DMA_Stream_IRQHandler DMA1_Stream7_IRQHandler
1598 #define LCD_DMA_FLAGS (DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7)
1599 #define LCD_DMA_FLAG_INT DMA_HIFCR_CTCIF7
1600 #define LCD_SPI SPI3
1601 #define LCD_GPIO_AF GPIO_AF_SPI3
1602 #elif defined(PCBX9DP) || defined(PCBX7)
1603 #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
1604 #define LCD_RCC_APB1Periph RCC_APB1Periph_SPI3
1605 #define LCD_SPI_GPIO GPIOC
1606 #define LCD_MOSI_GPIO_PIN GPIO_Pin_12 // PC.12
1607 #define LCD_MOSI_GPIO_PinSource GPIO_PinSource12
1608 #define LCD_CLK_GPIO_PIN GPIO_Pin_10 // PC.10
1609 #define LCD_CLK_GPIO_PinSource GPIO_PinSource10
1610 #define LCD_A0_GPIO_PIN GPIO_Pin_11 // PC.11
1611 #define LCD_NCS_GPIO GPIOA
1612 #define LCD_NCS_GPIO_PIN GPIO_Pin_15 // PA.15
1613 #define LCD_RST_GPIO GPIOD
1614 #define LCD_RST_GPIO_PIN GPIO_Pin_12 // PD.12
1615 #define LCD_DMA DMA1
1616 #define LCD_DMA_Stream DMA1_Stream7
1617 #define LCD_DMA_Stream_IRQn DMA1_Stream7_IRQn
1618 #define LCD_DMA_Stream_IRQHandler DMA1_Stream7_IRQHandler
1619 #define LCD_DMA_FLAGS (DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7)
1620 #define LCD_DMA_FLAG_INT DMA_HIFCR_CTCIF7
1621 #define LCD_SPI SPI3
1622 #define LCD_GPIO_AF GPIO_AF_SPI3
1623 #else
1624 #define LCD_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
1625 #define LCD_RCC_APB1Periph 0
1626 #define LCD_SPI_GPIO GPIOD
1627 #define LCD_MOSI_GPIO_PIN GPIO_Pin_10 // PD.10
1628 #define LCD_CLK_GPIO_PIN GPIO_Pin_11 // PD.11
1629 #define LCD_A0_GPIO_PIN GPIO_Pin_13 // PD.13
1630 #define LCD_NCS_GPIO GPIOD
1631 #define LCD_NCS_GPIO_PIN GPIO_Pin_14 // PD.14
1632 #define LCD_RST_GPIO GPIOD
1633 #define LCD_RST_GPIO_PIN GPIO_Pin_12 // PD.12
1634 #endif
1635 #define LCD_RCC_APB2Periph 0
1637 // I2C Bus: EEPROM and CAT5137 digital pot for volume control
1638 #define I2C_RCC_APB1Periph RCC_APB1Periph_I2C1
1639 #define I2C I2C1
1640 #define I2C_GPIO_AF GPIO_AF_I2C1
1641 #if defined(PCBXLITE) || defined(PCBX9LITE)
1642 #define I2C_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOD)
1643 #define I2C_SPI_GPIO GPIOB
1644 #define I2C_SDA_GPIO_PIN GPIO_Pin_9 // PB.09
1645 #define I2C_SCL_GPIO_PIN GPIO_Pin_8 // PB.08
1646 #define I2C_WP_GPIO GPIOD
1647 #define I2C_WP_GPIO_PIN GPIO_Pin_7 // PD.07
1648 #define I2C_SCL_GPIO_PinSource GPIO_PinSource8
1649 #define I2C_SDA_GPIO_PinSource GPIO_PinSource9
1650 #elif defined(PCBX9DP) && PCBREV >= 2019
1651 #define I2C_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOF)
1652 #define I2C_SPI_GPIO GPIOB
1653 #define I2C_SDA_GPIO_PIN GPIO_Pin_9 // PB.09
1654 #define I2C_SCL_GPIO_PIN GPIO_Pin_8 // PB.08
1655 #define I2C_WP_GPIO GPIOF
1656 #define I2C_WP_GPIO_PIN GPIO_Pin_0 // PF.00
1657 #define I2C_SCL_GPIO_PinSource GPIO_PinSource8
1658 #define I2C_SDA_GPIO_PinSource GPIO_PinSource9
1659 #else
1660 #define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1661 #define I2C_SPI_GPIO GPIOB
1662 #define I2C_SCL_GPIO_PIN GPIO_Pin_6 // PB.06
1663 #define I2C_SDA_GPIO_PIN GPIO_Pin_7 // PB.07
1664 #define I2C_WP_GPIO GPIOB
1665 #define I2C_WP_GPIO_PIN GPIO_Pin_9 // PB.09
1666 #define I2C_SCL_GPIO_PinSource GPIO_PinSource6
1667 #define I2C_SDA_GPIO_PinSource GPIO_PinSource7
1668 #define I2C_ADDRESS_VOLUME 0x5C
1669 #endif
1670 #define I2C_SPEED 400000
1671 #define I2C_ADDRESS_EEPROM 0xA2
1672 #define I2C_FLASH_PAGESIZE 64
1674 // Second I2C Bus: IMU
1675 #if defined(PCBXLITES)
1676 #define GYRO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC)
1677 #define GYRO_RCC_APB1Periph RCC_APB1Periph_I2C3
1678 #define I2CX I2C3
1679 #define I2CX_SCL_GPIO GPIOA
1680 #define I2CX_SCL_GPIO_PIN GPIO_Pin_8 // PA.08
1681 #define I2CX_SDA_GPIO GPIOC
1682 #define I2CX_SDA_GPIO_PIN GPIO_Pin_9 // PC.09
1683 #define I2CX_GPIO_AF GPIO_AF_I2C3
1684 #define I2CX_SCL_GPIO_PinSource GPIO_PinSource8
1685 #define I2CX_SDA_GPIO_PinSource GPIO_PinSource9
1686 #define I2CX_SPEED 400000
1687 #else
1688 #define GYRO_RCC_AHB1Periph 0
1689 #define GYRO_RCC_APB1Periph 0
1690 #endif
1692 // SD - SPI2
1693 #define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
1694 #define SD_RCC_APB1Periph RCC_APB1Periph_SPI2
1695 #define SD_GPIO_PRESENT_GPIO GPIOD
1696 #if defined(PCBXLITE) || defined(PCBX9LITE)
1697 #define SD_GPIO_PRESENT_GPIO_PIN GPIO_Pin_10 // PD.10
1698 #else
1699 #define SD_GPIO_PRESENT_GPIO_PIN GPIO_Pin_9 // PD.09
1700 #endif
1701 #define SD_GPIO GPIOB
1702 #define SD_GPIO_PIN_CS GPIO_Pin_12 // PB.12
1703 #define SD_GPIO_PIN_SCK GPIO_Pin_13 // PB.13
1704 #define SD_GPIO_PIN_MISO GPIO_Pin_14 // PB.14
1705 #define SD_GPIO_PIN_MOSI GPIO_Pin_15 // PB.15
1706 #define SD_GPIO_AF GPIO_AF_SPI2
1707 #define SD_GPIO_PinSource_CS GPIO_PinSource12
1708 #define SD_GPIO_PinSource_SCK GPIO_PinSource13
1709 #define SD_GPIO_PinSource_MISO GPIO_PinSource14
1710 #define SD_GPIO_PinSource_MOSI GPIO_PinSource15
1711 #define SD_SPI SPI2
1712 #define SD_SPI_BaudRatePrescaler SPI_BaudRatePrescaler_4 // 10.5<20MHZ, make sure < 20MHZ
1714 #if !defined(BOOT)
1715 #define SD_USE_DMA // Enable the DMA for SD
1716 #define SD_DMA_Stream_SPI_RX DMA1_Stream3
1717 #define SD_DMA_Stream_SPI_TX DMA1_Stream4
1718 #define SD_DMA_FLAG_SPI_TC_RX DMA_FLAG_TCIF3
1719 #define SD_DMA_FLAG_SPI_TC_TX DMA_FLAG_TCIF4
1720 #define SD_DMA_Channel_SPI DMA_Channel_0
1721 #endif
1723 // Audio
1724 #define AUDIO_RCC_APB1Periph (RCC_APB1Periph_TIM6 | RCC_APB1Periph_DAC)
1725 #define AUDIO_OUTPUT_GPIO GPIOA
1726 #define AUDIO_OUTPUT_GPIO_PIN GPIO_Pin_4 // PA.04
1727 #define AUDIO_DMA_Stream DMA1_Stream5
1728 #define AUDIO_DMA_Stream_IRQn DMA1_Stream5_IRQn
1729 #define AUDIO_TIM_IRQn TIM6_DAC_IRQn
1730 #define AUDIO_TIM_IRQHandler TIM6_DAC_IRQHandler
1731 #define AUDIO_DMA_Stream_IRQHandler DMA1_Stream5_IRQHandler
1732 #define AUDIO_TIMER TIM6
1733 #define AUDIO_DMA DMA1
1735 #if defined(PCBXLITES)
1736 #define AUDIO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA1)
1737 #define JACK_DETECT_GPIO GPIOC
1738 #define JACK_DETECT_GPIO_PIN GPIO_Pin_13 // PC.13
1739 #define AUDIO_SPEAKER_ENABLE_GPIO GPIOD
1740 #define AUDIO_SPEAKER_ENABLE_GPIO_PIN GPIO_Pin_14 // PD.14
1741 #define HEADPHONE_TRAINER_SWITCH_GPIO GPIOD
1742 #define HEADPHONE_TRAINER_SWITCH_GPIO_PIN GPIO_Pin_9 // PD.09
1743 #else
1744 #define AUDIO_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_DMA1)
1745 #endif
1747 // Haptic
1748 #if defined(PCBXLITE) || defined(PCBX9LITE)
1749 #define HAPTIC_PWM
1750 #define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1751 #define HAPTIC_RCC_APB1Periph RCC_APB1Periph_TIM2
1752 #define HAPTIC_RCC_APB2Periph 0
1753 #define HAPTIC_GPIO_PinSource GPIO_PinSource3
1754 #define HAPTIC_GPIO GPIOB
1755 #define HAPTIC_GPIO_PIN GPIO_Pin_3 // PB.03
1756 #define HAPTIC_GPIO_AF GPIO_AF_TIM2
1757 #define HAPTIC_TIMER TIM2
1758 #define HAPTIC_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1)
1759 #define HAPTIC_COUNTER_REGISTER HAPTIC_TIMER->CCR2
1760 #define HAPTIC_CCMR1 TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2
1761 #define HAPTIC_CCER TIM_CCER_CC2E
1762 #define BACKLIGHT_BDTR TIM_BDTR_MOE
1763 #elif defined(PCBX9DP) && PCBREV >= 2019
1764 #define HAPTIC_PWM
1765 #define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
1766 #define HAPTIC_RCC_APB2Periph RCC_APB2Periph_TIM1
1767 #define HAPTIC_RCC_APB1Periph 0
1768 #define HAPTIC_GPIO_PinSource GPIO_PinSource10
1769 #define HAPTIC_GPIO GPIOA
1770 #define HAPTIC_GPIO_PIN GPIO_Pin_10 // PA.10
1771 #define HAPTIC_GPIO_AF GPIO_AF_TIM1
1772 #define HAPTIC_TIMER TIM1 // Timer1 Channel3
1773 #define HAPTIC_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1774 #define HAPTIC_COUNTER_REGISTER HAPTIC_TIMER->CCR3
1775 #define HAPTIC_CCMR2 TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2
1776 #define HAPTIC_CCER TIM_CCER_CC3E
1777 #elif defined(PCBX9E) || defined(PCBX9DP) || defined(PCBX7)
1778 #define HAPTIC_PWM
1779 #define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
1780 #define HAPTIC_RCC_APB2Periph RCC_APB2Periph_TIM10
1781 #define HAPTIC_RCC_APB1Periph 0
1782 #define HAPTIC_GPIO_PinSource GPIO_PinSource8
1783 #define HAPTIC_GPIO GPIOB
1784 #define HAPTIC_GPIO_PIN GPIO_Pin_8 // PB.08
1785 #define HAPTIC_GPIO_AF GPIO_AF_TIM10
1786 #define HAPTIC_TIMER TIM10
1787 #define HAPTIC_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
1788 #define HAPTIC_COUNTER_REGISTER HAPTIC_TIMER->CCR1
1789 #define HAPTIC_CCMR1 TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2
1790 #define HAPTIC_CCER TIM_CCER_CC1E
1791 #else
1792 #define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOC
1793 #define HAPTIC_RCC_APB2Periph 0
1794 #define HAPTIC_RCC_APB1Periph 0
1795 #define HAPTIC_GPIO GPIOC
1796 #define HAPTIC_GPIO_PIN GPIO_Pin_12
1797 #endif
1799 // Top LCD on X9E
1800 #if defined(PCBX9E)
1801 #define TOPLCD_RCC_AHB1Periph RCC_AHB1Periph_GPIOG
1802 #define TOPLCD_GPIO GPIOG
1803 #define TOPLCD_GPIO_PIN_DATA GPIO_Pin_5
1804 #define TOPLCD_GPIO_PIN_WR GPIO_Pin_4
1805 #define TOPLCD_GPIO_PIN_CS1 GPIO_Pin_3
1806 #define TOPLCD_GPIO_PIN_CS2 GPIO_Pin_15
1807 #define TOPLCD_GPIO_PIN_BL GPIO_Pin_2
1808 #endif
1810 // Bluetooth
1811 #if defined(PCBX9E)
1812 #define STORAGE_BLUETOOTH
1813 #define BT_USART USART6
1814 #define BT_GPIO_AF GPIO_AF_USART6
1815 #define BT_USART_IRQn USART6_IRQn
1816 #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG)
1817 #define BT_RCC_APB1Periph 0
1818 #define BT_RCC_APB2Periph RCC_APB2Periph_USART6
1819 #define BT_USART_GPIO GPIOG
1820 #define BT_TX_GPIO_PIN GPIO_Pin_14 // PG.14
1821 #define BT_RX_GPIO_PIN GPIO_Pin_9 // PG.09
1822 #define BT_EN_GPIO GPIOD
1823 #define BT_EN_GPIO_PIN GPIO_Pin_11 // PD.11
1824 #define BT_BRTS_GPIO GPIOE
1825 #define BT_BRTS_GPIO_PIN GPIO_Pin_12 // PE.12
1826 #define BT_BCTS_GPIO GPIOG
1827 #define BT_BCTS_GPIO_PIN GPIO_Pin_6 // PG.06
1828 #define BT_TX_GPIO_PinSource GPIO_PinSource14
1829 #define BT_RX_GPIO_PinSource GPIO_PinSource9
1830 #define BT_USART_IRQHandler USART6_IRQHandler
1831 #elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITES) || (defined(PCBX9DP) && PCBREV >= 2019)
1832 #define STORAGE_BLUETOOTH
1833 #define BT_RCC_APB1Periph RCC_APB1Periph_USART3
1834 #define BT_RCC_APB2Periph 0
1835 #if defined(PCBX9DP)
1836 #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB) // RCC_AHB1Periph_DMA1
1837 #define BT_EN_GPIO GPIOB
1838 #define BT_EN_GPIO_PIN GPIO_Pin_2 // PB.02
1839 #elif defined(PCBXLITE)
1840 #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE) // RCC_AHB1Periph_DMA1
1841 #define BT_EN_GPIO GPIOE
1842 #define BT_EN_GPIO_PIN GPIO_Pin_15 // PE.15
1843 #elif defined(PCBX9LITES)
1844 #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOD) // RCC_AHB1Periph_DMA1
1845 #define BT_EN_GPIO GPIOD
1846 #define BT_EN_GPIO_PIN GPIO_Pin_14 // PD.14
1847 #else
1848 #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE) // RCC_AHB1Periph_DMA1
1849 #define BT_EN_GPIO GPIOE
1850 #define BT_EN_GPIO_PIN GPIO_Pin_12 // PE.12
1851 #endif
1852 #define BT_USART_GPIO GPIOB
1853 #define BT_TX_GPIO_PIN GPIO_Pin_10 // PB.10
1854 #define BT_RX_GPIO_PIN GPIO_Pin_11 // PB.11
1855 #define BT_TX_GPIO_PinSource GPIO_PinSource10
1856 #define BT_RX_GPIO_PinSource GPIO_PinSource11
1857 #define BT_GPIO_AF GPIO_AF_USART3
1858 #define BT_USART USART3
1859 #define BT_USART_IRQHandler USART3_IRQHandler
1860 #define BT_USART_IRQn USART3_IRQn
1861 // #define BT_DMA_Stream_RX DMA1_Stream1
1862 // #define BT_DMA_Channel_RX DMA_Channel_4
1863 #elif defined(PCBX9D) || defined(PCBX9DP)
1864 #define STORAGE_BLUETOOTH
1865 #define BT_RCC_AHB1Periph 0
1866 #define BT_RCC_APB1Periph 0
1867 #define BT_RCC_APB2Periph 0
1868 #else
1869 #define BT_RCC_AHB1Periph 0
1870 #define BT_RCC_APB1Periph 0
1871 #define BT_RCC_APB2Periph 0
1872 #endif
1874 // Xms Interrupt
1875 #define INTERRUPT_xMS_RCC_APB1Periph RCC_APB1Periph_TIM14
1876 #define INTERRUPT_xMS_TIMER TIM14
1877 #define INTERRUPT_xMS_IRQn TIM8_TRG_COM_TIM14_IRQn
1878 #define INTERRUPT_xMS_IRQHandler TIM8_TRG_COM_TIM14_IRQHandler
1880 // 2MHz Timer
1881 #define TIMER_2MHz_RCC_APB1Periph RCC_APB1Periph_TIM7
1882 #define TIMER_2MHz_TIMER TIM7
1884 #endif // _HAL_H_