Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
board.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #pragma once
18 
19 /*
20  ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
21 
22  Licensed under the Apache License, Version 2.0 (the "License");
23  you may not use this file except in compliance with the License.
24  You may obtain a copy of the License at
25  http://www.apache.org/licenses/LICENSE-2.0
26  Unless required by applicable law or agreed to in writing, software
27  distributed under the License is distributed on an "AS IS" BASIS,
28  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  See the License for the specific language governing permissions and
30  limitations under the License.
31 */
32 
33 /*
34  * Board identifier.
35  */
36 #define BOARD_ST_APOGEE
37 #define BOARD_NAME "AB/GRZ STM32F4 Apogee 1.0"
38 
39 /*
40  * Board oscillators-related settings.
41  * NOTE: LSE fitted.
42  */
43 #if !defined(STM32_LSECLK)
44 #define STM32_LSECLK 32768
45 #endif
46 
47 #if !defined(STM32_HSECLK)
48 #define STM32_HSECLK 16000000
49 #endif
50 
51 
52 /*
53  * Board voltages.
54  * Required for performance limits calculation.
55  */
56 #define STM32_VDD 300
57 
58 /*
59  * MCU type as defined in the ST header file stm32f4xx.h.
60  */
61 #define STM32F407xx
62 
63 /*
64  * PAPARAZZI CONFIGURATION
65  */
66 
67 
68 /*
69  * Concat macro
70  */
71 #define _CONCAT_BOARD_PARAM(_s1, _s2) _s1 ## _s2
72 #define CONCAT_BOARD_PARAM(_s1, _s2) _CONCAT_BOARD_PARAM(_s1, _s2)
73 
74 
75 /*
76  * LEDs
77  */
78 /* red, on PC0 */
79 #ifndef USE_LED_1
80 #define USE_LED_1 1
81 #endif
82 #define LED_1_GPIO GPIOC
83 #define LED_1_GPIO_PIN GPIO0
84 #define LED_1_GPIO_ON gpio_clear
85 #define LED_1_GPIO_OFF gpio_set
86 
87 /* orange, on PC13 */
88 #ifndef USE_LED_2
89 #define USE_LED_2 1
90 #endif
91 #define LED_2_GPIO GPIOC
92 #define LED_2_GPIO_PIN GPIO13
93 #define LED_2_GPIO_ON gpio_clear
94 #define LED_2_GPIO_OFF gpio_set
95 
96 /* green, on PC1 */
97 #ifndef USE_LED_3
98 #define USE_LED_3 1
99 #endif
100 #define LED_3_GPIO GPIOC
101 #define LED_3_GPIO_PIN GPIO1
102 #define LED_3_GPIO_ON gpio_clear
103 #define LED_3_GPIO_OFF gpio_set
104 
105 /* yellow, on PC3 */
106 #ifndef USE_LED_4
107 #define USE_LED_4 1
108 #endif
109 #define LED_4_GPIO GPIOC
110 #define LED_4_GPIO_PIN GPIO3
111 #define LED_4_GPIO_ON gpio_clear
112 #define LED_4_GPIO_OFF gpio_set
113 
114 /* AUX1, on PB1, 1 on LED_ON, 0 on LED_OFF */
115 #ifndef USE_LED_5
116 #define USE_LED_5 0
117 #endif
118 #define LED_5_GPIO GPIOB
119 #define LED_5_GPIO_PIN GPIO1
120 #define LED_5_GPIO_ON gpio_set
121 #define LED_5_GPIO_OFF gpio_clear
122 
123 /* AUX2, on PC5, 1 on LED_ON, 0 on LED_OFF */
124 #ifndef USE_LED_6
125 #define USE_LED_6 0
126 #endif
127 #define LED_6_GPIO GPIOC
128 #define LED_6_GPIO_PIN GPIO5
129 #define LED_6_GPIO_ON gpio_set
130 #define LED_6_GPIO_OFF gpio_clear
131 
132 /* AUX3, on PC4, 1 on LED_ON, 0 on LED_OFF */
133 #ifndef USE_LED_7
134 #define USE_LED_7 0
135 #endif
136 #define LED_7_GPIO GPIOC
137 #define LED_7_GPIO_PIN GPIO4
138 #define LED_7_GPIO_ON gpio_set
139 #define LED_7_GPIO_OFF gpio_clear
140 
141 /* AUX4, on PB15, 1 on LED_ON, 0 on LED_OFF */
142 #ifndef USE_LED_8
143 #define USE_LED_8 0
144 #endif
145 #define LED_8_GPIO GPIOB
146 #define LED_8_GPIO_PIN GPIO15
147 #define LED_8_GPIO_ON gpio_set
148 #define LED_8_GPIO_OFF gpio_clear
149 
150 /* Power Switch, on PB12 */
151 #define POWER_SWITCH_GPIO GPIOB,GPIO12
152 
153 /* Pint to set Uart2 RX polarity, on PB13, output high inverts, low doesn't */
154 #define RC_POLARITY_GPIO_PORT GPIOB
155 #define RC_POLARITY_GPIO_PIN GPIO13
156 
157 /*
158  * ADCs
159  */
160 // AUX 1
161 #if USE_ADC_1
162 #define AD1_1_CHANNEL ADC_CHANNEL_IN9
163 #define ADC_1 AD1_1
164 #define ADC_1_GPIO_PORT GPIOB
165 #define ADC_1_GPIO_PIN GPIO1
166 #endif
167 
168 // AUX 2
169 #if USE_ADC_2
170 #define AD1_2_CHANNEL ADC_CHANNEL_IN15
171 #define ADC_2 AD1_2
172 #define ADC_2_GPIO_PORT GPIOC
173 #define ADC_2_GPIO_PIN GPIO5
174 #endif
175 
176 // AUX 3
177 #if USE_ADC_3
178 #define AD1_3_CHANNEL ADC_CHANNEL_IN14
179 #define ADC_3 AD1_3
180 #define ADC_3_GPIO_PORT GPIOC
181 #define ADC_3_GPIO_PIN GPIO4
182 #endif
183 
184 // Internal ADC for battery enabled by default
185 #ifndef USE_ADC_4
186 #define USE_ADC_4 1
187 #endif
188 #if USE_ADC_4
189 #define AD1_4_CHANNEL ADC_CHANNEL_IN4
190 #define ADC_4 AD1_4
191 #define ADC_4_GPIO_PORT GPIOA
192 #define ADC_4_GPIO_PIN GPIO4
193 #endif
194 
195 /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/
196 #ifndef ADC_CHANNEL_VSUPPLY
197 #define ADC_CHANNEL_VSUPPLY ADC_4
198 #endif
199 
200 #define DefaultVoltageOfAdc(adc) (0.006185*adc)
201 
202 /*
203  * PWM defines
204  */
205 #ifndef USE_PWM0
206 #define USE_PWM0 1
207 #endif
208 #if USE_PWM0
209 #define PWM_SERVO_0 0
210 #define PWM_SERVO_0_GPIO PAL_PORT(LINE_SERVO0)
211 #define PWM_SERVO_0_PIN PAL_PAD(LINE_SERVO0)
212 #define PWM_SERVO_0_AF AF_LINE_SERVO0
213 #define PWM_SERVO_0_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO0_TIM)
214 #define PWM_SERVO_0_CHANNEL (SERVO0_TIM_CH-1)
215 #define PWM_SERVO_0_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO0_TIM)
216 #endif
217 
218 #ifndef USE_PWM1
219 #define USE_PWM1 1
220 #endif
221 #if USE_PWM1
222 #define PWM_SERVO_1 1
223 #define PWM_SERVO_1_GPIO PAL_PORT(LINE_SERVO1)
224 #define PWM_SERVO_1_PIN PAL_PAD(LINE_SERVO1)
225 #define PWM_SERVO_1_AF AF_LINE_SERVO1
226 #define PWM_SERVO_1_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO1_TIM)
227 #define PWM_SERVO_1_CHANNEL (SERVO1_TIM_CH-1)
228 #define PWM_SERVO_1_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO1_TIM)
229 #endif
230 
231 #ifndef USE_PWM2
232 #define USE_PWM2 1
233 #endif
234 #if USE_PWM2
235 #define PWM_SERVO_2 2
236 #define PWM_SERVO_2_GPIO PAL_PORT(LINE_SERVO2)
237 #define PWM_SERVO_2_PIN PAL_PAD(LINE_SERVO2)
238 #define PWM_SERVO_2_AF AF_LINE_SERVO2
239 #define PWM_SERVO_2_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO2_TIM)
240 #define PWM_SERVO_2_CHANNEL (SERVO2_TIM_CH-1)
241 #define PWM_SERVO_2_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO2_TIM)
242 #endif
243 
244 #ifndef USE_PWM3
245 #define USE_PWM3 1
246 #endif
247 #if USE_PWM3
248 #define PWM_SERVO_3 3
249 #define PWM_SERVO_3_GPIO PAL_PORT(LINE_SERVO3)
250 #define PWM_SERVO_3_PIN PAL_PAD(LINE_SERVO3)
251 #define PWM_SERVO_3_AF AF_LINE_SERVO3
252 #define PWM_SERVO_3_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO3_TIM)
253 #define PWM_SERVO_3_CHANNEL (SERVO3_TIM_CH-1)
254 #define PWM_SERVO_3_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO3_TIM)
255 #endif
256 
257 #ifndef USE_PWM4
258 #define USE_PWM4 1
259 #endif
260 #if USE_PWM4
261 #define PWM_SERVO_4 4
262 #define PWM_SERVO_4_GPIO PAL_PORT(LINE_SERVO4)
263 #define PWM_SERVO_4_PIN PAL_PAD(LINE_SERVO4)
264 #define PWM_SERVO_4_AF AF_LINE_SERVO4
265 #define PWM_SERVO_4_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO4_TIM)
266 #define PWM_SERVO_4_CHANNEL (SERVO4_TIM_CH-1)
267 #define PWM_SERVO_4_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO4_TIM)
268 #endif
269 
270 #ifndef USE_PWM5
271 #define USE_PWM5 1
272 #endif
273 #if USE_PWM5
274 #define PWM_SERVO_5 5
275 #define PWM_SERVO_5_GPIO PAL_PORT(LINE_SERVO5)
276 #define PWM_SERVO_5_PIN PAL_PAD(LINE_SERVO5)
277 #define PWM_SERVO_5_AF AF_LINE_SERVO5
278 #define PWM_SERVO_5_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO5_TIM)
279 #define PWM_SERVO_5_CHANNEL (SERVO5_TIM_CH-1)
280 #define PWM_SERVO_5_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO5_TIM)
281 #endif
282 
283 #if USE_PWM6
284 #define PWM_SERVO_6 6
285 #define PWM_SERVO_6_GPIO PAL_PORT(LINE_SERVO6)
286 #define PWM_SERVO_6_PIN PAL_PAD(LINE_SERVO6)
287 #define PWM_SERVO_6_AF AF_LINE_SERVO6
288 #define PWM_SERVO_6_DRIVER CONCAT_BOARD_PARAM(PWMD, SERVO6_TIM)
289 #define PWM_SERVO_6_CHANNEL (SERVO6_TIM_CH-1)
290 #define PWM_SERVO_6_CONF CONCAT_BOARD_PARAM(pwmcfg, SERVO6_TIM)
291 #endif
292 
296 #ifndef DSHOT_TELEMETRY_DEV
297 #define DSHOT_TELEMETRY_DEV NULL
298 #endif
299 #ifndef USE_DSHOT_TIM2
300 #define USE_DSHOT_TIM2 1
301 #endif
302 #ifndef USE_DSHOT_TIM3
303 #define USE_DSHOT_TIM3 1
304 #endif
305 #if USE_DSHOT_TIM2 // Servo 1, 4, 5
306 #define DSHOT_SERVO_1 1
307 #define DSHOT_SERVO_1_GPIO GPIOA
308 #define DSHOT_SERVO_1_PIN GPIO2
309 #define DSHOT_SERVO_1_AF GPIO_AF1
310 #define DSHOT_SERVO_1_DRIVER DSHOTD2
311 #define DSHOT_SERVO_1_CHANNEL 2
312 #define DSHOT_SERVO_4 4
313 #define DSHOT_SERVO_4_GPIO GPIOB
314 #define DSHOT_SERVO_4_PIN GPIO3
315 #define DSHOT_SERVO_4_AF GPIO_AF1
316 #define DSHOT_SERVO_4_DRIVER DSHOTD2
317 #define DSHOT_SERVO_4_CHANNEL 1
318 #define DSHOT_SERVO_5 5
319 #define DSHOT_SERVO_5_GPIO GPIOA
320 #define DSHOT_SERVO_5_PIN GPIO15
321 #define DSHOT_SERVO_5_AF GPIO_AF1
322 #define DSHOT_SERVO_5_DRIVER DSHOTD2
323 #define DSHOT_SERVO_5_CHANNEL 0
324 #define DSHOT_CONF_TIM2 1
325 #define DSHOT_CONF2_DEF { \
326  .dma_stream = STM32_PWM2_UP_DMA_STREAM, \
327  .dma_channel = STM32_PWM2_UP_DMA_CHANNEL, \
328  .pwmp = &PWMD2, \
329  .tlm_sd = DSHOT_TELEMETRY_DEV, \
330  .dma_buf = &dshot2DmaBuffer, \
331 }
332 #endif
333 #if USE_DSHOT_TIM3 // Servo 0,2,3,6
334 #define DSHOT_SERVO_0 0
335 #define DSHOT_SERVO_0_GPIO GPIOB
336 #define DSHOT_SERVO_0_PIN GPIO0
337 #define DSHOT_SERVO_0_AF GPIO_AF2
338 #define DSHOT_SERVO_0_DRIVER DSHOTD3
339 #define DSHOT_SERVO_0_CHANNEL 2
340 #define DSHOT_SERVO_2 2
341 #define DSHOT_SERVO_2_GPIO GPIOB
342 #define DSHOT_SERVO_2_PIN GPIO5
343 #define DSHOT_SERVO_2_AF GPIO_AF2
344 #define DSHOT_SERVO_2_DRIVER DSHOTD3
345 #define DSHOT_SERVO_2_CHANNEL 1
346 #define DSHOT_SERVO_3 3
347 #define DSHOT_SERVO_3_GPIO GPIOB
348 #define DSHOT_SERVO_3_PIN GPIO4
349 #define DSHOT_SERVO_3_AF GPIO_AF2
350 #define DSHOT_SERVO_3_DRIVER DSHOTD3
351 #define DSHOT_SERVO_3_CHANNEL 0
352 #if USE_DSHOT6
353 // DSHOT6 on AUX1 pin, not activated by default
354 #define DSHOT_SERVO_6 6
355 #define DSHOT_SERVO_6_GPIO GPIOB
356 #define DSHOT_SERVO_6_PIN GPIO1
357 #define DSHOT_SERVO_6_AF GPIO_AF2
358 #define DSHOT_SERVO_6_DRIVER DSHOTD3
359 #define DSHOT_SERVO_6_CHANNEL 3
360 #endif
361 #define DSHOT_CONF_TIM3 1
362 #define DSHOT_CONF3_DEF { \
363  .dma_stream = STM32_PWM3_UP_DMA_STREAM, \
364  .dma_channel = STM32_PWM3_UP_DMA_CHANNEL, \
365  .pwmp = &PWMD3, \
366  .tlm_sd = DSHOT_TELEMETRY_DEV, \
367  .dma_buf = &dshot3DmaBuffer, \
368 }
369 #endif
370 
374 #define RC_PPM_TICKS_PER_USEC 2
375 #define PPM_TIMER_FREQUENCY 2000000
376 #define PPM_CHANNEL ICU_CHANNEL_1
377 #define PPM_TIMER ICUD1
378 
379 /*
380  * Spektrum
381  */
382 
383 // shorter wait with chibios as the RTC oscillator takes longer to stabilize
384 #define SPEKTRUM_BIND_WAIT 30000
385 
386 /* The line that is pulled low at power up to initiate the bind process
387  * PB15: AUX4
388  */
389 #define SPEKTRUM_BIND_PIN GPIO15
390 #define SPEKTRUM_BIND_PIN_PORT GPIOB
391 
392 /* The line used to send the pulse train for the bind process
393  * When using UART2 on Apogee, this as to be a different pin than the uart2 rx
394  * Default pin for this is PA8: PPM_IN
395  */
396 #ifndef SPEKTRUM_PRIMARY_BIND_CONF_PORT
397 #define SPEKTRUM_PRIMARY_BIND_CONF_PORT GPIOA
398 #define SPEKTRUM_PRIMARY_BIND_CONF_PIN GPIO8
399 #endif
400 
401 /*
402  * PWM input
403  */
404 // PWM_INPUT 1 on PA8 (also PPM IN)
405 #define PWM_INPUT1_ICU ICUD1
406 #define PWM_INPUT1_CHANNEL ICU_CHANNEL_1
407 // PPM in (aka PA8) is used: not compatible with PPM RC receiver
408 #define PWM_INPUT1_GPIO_PORT GPIOA
409 #define PWM_INPUT1_GPIO_PIN GPIO8
410 #define PWM_INPUT1_GPIO_AF GPIO_AF1
411 
412 // PWM_INPUT 2 on PA2 (also SERVO 1)
413 #if (USE_PWM1 && USE_PWM_INPUT2)
414 #error "PW1 and PWM_INPUT2 are not compatible"
415 #endif
416 #define PWM_INPUT2_ICU ICUD5
417 #define PWM_INPUT2_CHANNEL ICU_CHANNEL_4
418 #define PWM_INPUT2_GPIO_PORT GPIOA
419 #define PWM_INPUT2_GPIO_PIN GPIO2
420 #define PWM_INPUT2_GPIO_AF GPIO_AF2
421 
425 #ifndef I2C1_CLOCK_SPEED
426 #define I2C1_CLOCK_SPEED 400000
427 #endif
428 #if I2C1_CLOCK_SPEED == 400000
429 #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
430 #elif I2C1_CLOCK_SPEED == 100000
431 #define I2C1_DUTY_CYCLE STD_DUTY_CYCLE
432 #else
433 #error Invalid I2C1 clock speed
434 #endif
435 #define I2C1_CFG_DEF { \
436  OPMODE_I2C, \
437  I2C1_CLOCK_SPEED, \
438  I2C1_DUTY_CYCLE, \
439  }
440 
441 #ifndef I2C2_CLOCK_SPEED
442 #define I2C2_CLOCK_SPEED 400000
443 #endif
444 #if I2C2_CLOCK_SPEED == 400000
445 #define I2C2_DUTY_CYCLE FAST_DUTY_CYCLE_2
446 #elif I2C2_CLOCK_SPEED == 100000
447 #define I2C2_DUTY_CYCLE STD_DUTY_CYCLE
448 #else
449 #error Invalid I2C2 clock speed
450 #endif
451 #define I2C2_CFG_DEF { \
452  OPMODE_I2C, \
453  I2C2_CLOCK_SPEED, \
454  I2C2_DUTY_CYCLE, \
455  }
456 
460 #define SPI1_GPIO_AF GPIO_AF5
461 #define SPI1_GPIO_PORT_MISO GPIOA
462 #define SPI1_GPIO_MISO GPIO6
463 #define SPI1_GPIO_PORT_MOSI GPIOA
464 #define SPI1_GPIO_MOSI GPIO7
465 #define SPI1_GPIO_PORT_SCK GPIOA
466 #define SPI1_GPIO_SCK GPIO5
467 
468 // SLAVE0 on SPI connector
469 #define SPI_SELECT_SLAVE0_PORT GPIOB
470 #define SPI_SELECT_SLAVE0_PIN GPIO9
471 // SLAVE1 on AUX1
472 #define SPI_SELECT_SLAVE1_PORT GPIOB
473 #define SPI_SELECT_SLAVE1_PIN GPIO1
474 // SLAVE2 on AUX2
475 #define SPI_SELECT_SLAVE2_PORT GPIOC
476 #define SPI_SELECT_SLAVE2_PIN GPIO5
477 // SLAVE3 on AUX3
478 #define SPI_SELECT_SLAVE3_PORT GPIOC
479 #define SPI_SELECT_SLAVE3_PIN GPIO4
480 // SLAVE4 on AUX4
481 #define SPI_SELECT_SLAVE4_PORT GPIOB
482 #define SPI_SELECT_SLAVE4_PIN GPIO15
483 
490 #ifndef USE_BARO_BOARD
491 #define USE_BARO_BOARD 1
492 #endif
493 
494 /*
495  * Actuators for fixedwing
496  */
497  /* Default actuators driver */
498 #define DEFAULT_ACTUATORS "modules/actuators/actuators_pwm.h"
499 #define ActuatorDefaultSet(_x,_y) ActuatorPwmSet(_x,_y)
500 #define ActuatorsDefaultInit() ActuatorsPwmInit()
501 #define ActuatorsDefaultCommit() ActuatorsPwmCommit()
502 
503 
507 #define SDIO_D0_PORT GPIOC
508 #define SDIO_D0_PIN SDIO_D0
509 #define SDIO_D1_PORT GPIOC
510 #define SDIO_D1_PIN SDIO_D1
511 #define SDIO_D2_PORT GPIOC
512 #define SDIO_D2_PIN SDIO_D2
513 #define SDIO_D3_PORT GPIOC
514 #define SDIO_D3_PIN SDIO_D3
515 #define SDIO_CK_PORT GPIOC
516 #define SDIO_CK_PIN SDIO_CK
517 #define SDIO_CMD_PORT GPIOD
518 #define SDIO_CMD_PIN SDIO_CMD
519 #define SDIO_AF 12
520 // bat monitoring for file closing
521 #define SDLOG_BAT_ADC ADCD1
522 #define SDLOG_BAT_CHAN AD1_4_CHANNEL
523 // usb led status
524 #define SDLOG_USB_LED 4
525 #define SDLOG_USB_VBUS_PORT GPIOA
526 #define SDLOG_USB_VBUS_PIN GPIO9
527 
528 
532 #define WS2812D1_GPIO GPIOA
533 #define WS2812D1_PIN GPIO8
534 #define WS2812D1_AF 1
535 #define WS2812D1_CFG_DEF { \
536  .dma_stream = STM32_PWM1_UP_DMA_STREAM, \
537  .dma_channel = STM32_PWM1_UP_DMA_CHANNEL, \
538  .dma_priority = STM32_PWM1_UP_DMA_PRIORITY, \
539  .pwm_channel = 0, \
540  .pwmp = &PWMD1 \
541 }
542 
543 
544 /*
545  * IO pins assignments.
546  */
547 #define UART4_TX 0U
548 #define UART4_RX 1U
549 #define SERVO1 2U
550 #define UART2_RX 3U
551 #define ADC1_IN4 4U
552 #define SPI1_SCK 5U
553 #define SPI1_MISO 6U
554 #define SPI1_MOSI 7U
555 #define CU1_CH1 8U
556 #define OTG_FS_VBUS 9U
557 #define USART1_RX 10U
558 #define OTG_FS_DM 11U
559 #define OTG_FS_DP 12U
560 #define SWDIO 13U
561 #define SWCLK 14U
562 #define SERVO5 15U
563 
564 #define SERVO0 0U
565 #define SERVO6 1U
566 #define BOOT1 2U
567 #define SERVO4 3U
568 #define SERVO3 4U
569 #define SERVO2 5U
570 #define USART1_TX 6U
571 #define I2C1_SDA 7U
572 #define I2C1_SCL 8U
573 #define SPI1_CS 9U
574 #define I2C2_SCL 10U
575 #define I2C2_SDA 11U
576 #define POWER_SWITCH 12U
577 #define RX2_POL 13U
578 #define SDIO_DETECT 14U
579 #define AUX4 15U
580 
581 #define LED1 0U
582 #define LED3 1U
583 #define PC02 2U
584 #define LED4 3U
585 #define AUX3 4U
586 #define AUX2 5U
587 #define USART6_TX 6U
588 #define USART6_RX 7U
589 #define SDIO_D0 8U
590 #define SDIO_D1 9U
591 #define SDIO_D2 10U
592 #define SDIO_D3 11U
593 #define SDIO_CK 12U
594 #define LED2 13U
595 #define OSC32_IN 14U
596 #define OSC32_OUT 15U
597 
598 #define PD00 0U
599 #define PD01 1U
600 #define SDIO_CMD 2U
601 #define PD03 3U
602 #define PD04 4U
603 #define PD05 5U
604 #define PD06 6U
605 #define PD07 7U
606 #define PD08 8U
607 #define PD09 9U
608 #define PD10 10U
609 #define PD11 11U
610 #define PD12 12U
611 #define PD13 13U
612 #define PD14 14U
613 #define PD15 15U
614 
615 #define PE00 0U
616 #define PE01 1U
617 #define PE02 2U
618 #define PE03 3U
619 #define PE04 4U
620 #define PE05 5U
621 #define PE06 6U
622 #define PE07 7U
623 #define PE08 8U
624 #define PE09 9U
625 #define PE10 10U
626 #define PE11 11U
627 #define PE12 12U
628 #define PE13 13U
629 #define PE14 14U
630 #define PE15 15U
631 
632 #define PF00 0U
633 #define PF01 1U
634 #define PF02 2U
635 #define PF03 3U
636 #define PF04 4U
637 #define PF05 5U
638 #define PF06 6U
639 #define PF07 7U
640 #define PF08 8U
641 #define PF09 9U
642 #define PF10 10U
643 #define PF11 11U
644 #define PF12 12U
645 #define PF13 13U
646 #define PF14 14U
647 #define PF15 15U
648 
649 #define PG00 0U
650 #define PG01 1U
651 #define PG02 2U
652 #define PG03 3U
653 #define PG04 4U
654 #define PG05 5U
655 #define PG06 6U
656 #define PG07 7U
657 #define PG08 8U
658 #define PG09 9U
659 #define PG10 10U
660 #define PG11 11U
661 #define PG12 12U
662 #define PG13 13U
663 #define PG14 14U
664 #define PG15 15U
665 
666 #define OSC_IN 0U
667 #define OSC_OUT 1U
668 #define PH02 2U
669 #define PH03 3U
670 #define PH04 4U
671 #define PH05 5U
672 #define PH06 6U
673 #define PH07 7U
674 #define PH08 8U
675 #define PH09 9U
676 #define PH10 10U
677 #define PH11 11U
678 #define PH12 12U
679 #define PH13 13U
680 #define PH14 14U
681 #define PH15 15U
682 
683 #define PI00 0U
684 #define PI01 1U
685 #define PI02 2U
686 #define PI03 3U
687 #define PI04 4U
688 #define PI05 5U
689 #define PI06 6U
690 #define PI07 7U
691 #define PI08 8U
692 #define PI09 9U
693 #define PI10 10U
694 #define PI11 11U
695 #define PI12 12U
696 #define PI13 13U
697 #define PI14 14U
698 #define PI15 15U
699 
700 #define PJ00 0U
701 #define PJ01 1U
702 #define PJ02 2U
703 #define PJ03 3U
704 #define PJ04 4U
705 #define PJ05 5U
706 #define PJ06 6U
707 #define PJ07 7U
708 #define PJ08 8U
709 #define PJ09 9U
710 #define PJ10 10U
711 #define PJ11 11U
712 #define PJ12 12U
713 #define PJ13 13U
714 #define PJ14 14U
715 #define PJ15 15U
716 
717 #define PK00 0U
718 #define PK01 1U
719 #define PK02 2U
720 #define PK03 3U
721 #define PK04 4U
722 #define PK05 5U
723 #define PK06 6U
724 #define PK07 7U
725 #define PK08 8U
726 #define PK09 9U
727 #define PK10 10U
728 #define PK11 11U
729 #define PK12 12U
730 #define PK13 13U
731 #define PK14 14U
732 #define PK15 15U
733 
734 /*
735  * IO lines assignments.
736  */
737 #define LINE_UART4_TX PAL_LINE(GPIOA, 0U)
738 #define LINE_UART4_RX PAL_LINE(GPIOA, 1U)
739 #define LINE_SERVO1 PAL_LINE(GPIOA, 2U)
740 #define LINE_UART2_RX PAL_LINE(GPIOA, 3U)
741 #define LINE_ADC1_IN4 PAL_LINE(GPIOA, 4U)
742 #define LINE_SPI1_SCK PAL_LINE(GPIOA, 5U)
743 #define LINE_SPI1_MISO PAL_LINE(GPIOA, 6U)
744 #define LINE_SPI1_MOSI PAL_LINE(GPIOA, 7U)
745 #define LINE_CU1_CH1 PAL_LINE(GPIOA, 8U)
746 #define LINE_OTG_FS_VBUS PAL_LINE(GPIOA, 9U)
747 #define LINE_USART1_RX PAL_LINE(GPIOA, 10U)
748 #define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U)
749 #define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U)
750 #define LINE_SWDIO PAL_LINE(GPIOA, 13U)
751 #define LINE_SWCLK PAL_LINE(GPIOA, 14U)
752 #define LINE_SERVO5 PAL_LINE(GPIOA, 15U)
753 
754 #define LINE_SERVO0 PAL_LINE(GPIOB, 0U)
755 #define LINE_SERVO6 PAL_LINE(GPIOB, 1U)
756 #define LINE_BOOT1 PAL_LINE(GPIOB, 2U)
757 #define LINE_SERVO4 PAL_LINE(GPIOB, 3U)
758 #define LINE_SERVO3 PAL_LINE(GPIOB, 4U)
759 #define LINE_SERVO2 PAL_LINE(GPIOB, 5U)
760 #define LINE_USART1_TX PAL_LINE(GPIOB, 6U)
761 #define LINE_I2C1_SDA PAL_LINE(GPIOB, 7U)
762 #define LINE_I2C1_SCL PAL_LINE(GPIOB, 8U)
763 #define LINE_SPI1_CS PAL_LINE(GPIOB, 9U)
764 #define LINE_I2C2_SCL PAL_LINE(GPIOB, 10U)
765 #define LINE_I2C2_SDA PAL_LINE(GPIOB, 11U)
766 #define LINE_POWER_SWITCH PAL_LINE(GPIOB, 12U)
767 #define LINE_RX2_POL PAL_LINE(GPIOB, 13U)
768 #define LINE_SDIO_DETECT PAL_LINE(GPIOB, 14U)
769 #define LINE_AUX4 PAL_LINE(GPIOB, 15U)
770 
771 #define LINE_LED1 PAL_LINE(GPIOC, 0U)
772 #define LINE_LED3 PAL_LINE(GPIOC, 1U)
773 #define LINE_LED4 PAL_LINE(GPIOC, 3U)
774 #define LINE_AUX3 PAL_LINE(GPIOC, 4U)
775 #define LINE_AUX2 PAL_LINE(GPIOC, 5U)
776 #define LINE_USART6_TX PAL_LINE(GPIOC, 6U)
777 #define LINE_USART6_RX PAL_LINE(GPIOC, 7U)
778 #define LINE_SDIO_D0 PAL_LINE(GPIOC, 8U)
779 #define LINE_SDIO_D1 PAL_LINE(GPIOC, 9U)
780 #define LINE_SDIO_D2 PAL_LINE(GPIOC, 10U)
781 #define LINE_SDIO_D3 PAL_LINE(GPIOC, 11U)
782 #define LINE_SDIO_CK PAL_LINE(GPIOC, 12U)
783 #define LINE_LED2 PAL_LINE(GPIOC, 13U)
784 #define LINE_OSC32_IN PAL_LINE(GPIOC, 14U)
785 #define LINE_OSC32_OUT PAL_LINE(GPIOC, 15U)
786 
787 #define LINE_SDIO_CMD PAL_LINE(GPIOD, 2U)
788 
789 #define LINE_OSC_IN PAL_LINE(GPIOH, 0U)
790 #define LINE_OSC_OUT PAL_LINE(GPIOH, 1U)
791 
792 
793 /*
794  * I/O ports initial setup, this configuration is established soon after reset
795  * in the initialization code.
796  * Please refer to the STM32 Reference Manual for details.
797  */
798 #define PIN_MODE_INPUT(n) (0U << ((n) * 2U))
799 #define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U))
800 #define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U))
801 #define PIN_MODE_ANALOG(n) (3U << ((n) * 2U))
802 #define PIN_ODR_LEVEL_LOW(n) (0U << (n))
803 #define PIN_ODR_LEVEL_HIGH(n) (1U << (n))
804 #define PIN_OTYPE_PUSHPULL(n) (0U << (n))
805 #define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
806 #define PIN_OSPEED_SPEED_VERYLOW(n) (0U << ((n) * 2U))
807 #define PIN_OSPEED_SPEED_LOW(n) (1U << ((n) * 2U))
808 #define PIN_OSPEED_SPEED_MEDIUM(n) (2U << ((n) * 2U))
809 #define PIN_OSPEED_SPEED_HIGH(n) (3U << ((n) * 2U))
810 #define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U))
811 #define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U))
812 #define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U))
813 #define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U))
814 
815 #define VAL_GPIOA_MODER (PIN_MODE_ALTERNATE(UART4_TX) | \
816  PIN_MODE_ALTERNATE(UART4_RX) | \
817  PIN_MODE_ALTERNATE(SERVO1) | \
818  PIN_MODE_ALTERNATE(UART2_RX) | \
819  PIN_MODE_ANALOG(ADC1_IN4) | \
820  PIN_MODE_ALTERNATE(SPI1_SCK) | \
821  PIN_MODE_ALTERNATE(SPI1_MISO) | \
822  PIN_MODE_ALTERNATE(SPI1_MOSI) | \
823  PIN_MODE_ALTERNATE(CU1_CH1) | \
824  PIN_MODE_INPUT(OTG_FS_VBUS) | \
825  PIN_MODE_ALTERNATE(USART1_RX) | \
826  PIN_MODE_ALTERNATE(OTG_FS_DM) | \
827  PIN_MODE_ALTERNATE(OTG_FS_DP) | \
828  PIN_MODE_ALTERNATE(SWDIO) | \
829  PIN_MODE_ALTERNATE(SWCLK) | \
830  PIN_MODE_ALTERNATE(SERVO5))
831 
832 #define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(UART4_TX) | \
833  PIN_OTYPE_PUSHPULL(UART4_RX) | \
834  PIN_OTYPE_PUSHPULL(SERVO1) | \
835  PIN_OTYPE_PUSHPULL(UART2_RX) | \
836  PIN_OTYPE_PUSHPULL(ADC1_IN4) | \
837  PIN_OTYPE_PUSHPULL(SPI1_SCK) | \
838  PIN_OTYPE_PUSHPULL(SPI1_MISO) | \
839  PIN_OTYPE_PUSHPULL(SPI1_MOSI) | \
840  PIN_OTYPE_PUSHPULL(CU1_CH1) | \
841  PIN_OTYPE_OPENDRAIN(OTG_FS_VBUS) | \
842  PIN_OTYPE_PUSHPULL(USART1_RX) | \
843  PIN_OTYPE_PUSHPULL(OTG_FS_DM) | \
844  PIN_OTYPE_PUSHPULL(OTG_FS_DP) | \
845  PIN_OTYPE_PUSHPULL(SWDIO) | \
846  PIN_OTYPE_PUSHPULL(SWCLK) | \
847  PIN_OTYPE_PUSHPULL(SERVO5))
848 
849 #define VAL_GPIOA_OSPEEDR (PIN_OSPEED_SPEED_HIGH(UART4_TX) | \
850  PIN_OSPEED_SPEED_HIGH(UART4_RX) | \
851  PIN_OSPEED_SPEED_HIGH(SERVO1) | \
852  PIN_OSPEED_SPEED_HIGH(UART2_RX) | \
853  PIN_OSPEED_SPEED_VERYLOW(ADC1_IN4) | \
854  PIN_OSPEED_SPEED_HIGH(SPI1_SCK) | \
855  PIN_OSPEED_SPEED_HIGH(SPI1_MISO) | \
856  PIN_OSPEED_SPEED_HIGH(SPI1_MOSI) | \
857  PIN_OSPEED_SPEED_HIGH(CU1_CH1) | \
858  PIN_OSPEED_SPEED_VERYLOW(OTG_FS_VBUS) | \
859  PIN_OSPEED_SPEED_HIGH(USART1_RX) | \
860  PIN_OSPEED_SPEED_HIGH(OTG_FS_DM) | \
861  PIN_OSPEED_SPEED_HIGH(OTG_FS_DP) | \
862  PIN_OSPEED_SPEED_HIGH(SWDIO) | \
863  PIN_OSPEED_SPEED_HIGH(SWCLK) | \
864  PIN_OSPEED_SPEED_HIGH(SERVO5))
865 
866 #define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(UART4_TX) | \
867  PIN_PUPDR_FLOATING(UART4_RX) | \
868  PIN_PUPDR_FLOATING(SERVO1) | \
869  PIN_PUPDR_FLOATING(UART2_RX) | \
870  PIN_PUPDR_FLOATING(ADC1_IN4) | \
871  PIN_PUPDR_FLOATING(SPI1_SCK) | \
872  PIN_PUPDR_FLOATING(SPI1_MISO) | \
873  PIN_PUPDR_FLOATING(SPI1_MOSI) | \
874  PIN_PUPDR_FLOATING(CU1_CH1) | \
875  PIN_PUPDR_PULLDOWN(OTG_FS_VBUS) | \
876  PIN_PUPDR_FLOATING(USART1_RX) | \
877  PIN_PUPDR_FLOATING(OTG_FS_DM) | \
878  PIN_PUPDR_FLOATING(OTG_FS_DP) | \
879  PIN_PUPDR_FLOATING(SWDIO) | \
880  PIN_PUPDR_FLOATING(SWCLK) | \
881  PIN_PUPDR_FLOATING(SERVO5))
882 
883 #define VAL_GPIOA_ODR (PIN_ODR_LEVEL_HIGH(UART4_TX) | \
884  PIN_ODR_LEVEL_HIGH(UART4_RX) | \
885  PIN_ODR_LEVEL_LOW(SERVO1) | \
886  PIN_ODR_LEVEL_HIGH(UART2_RX) | \
887  PIN_ODR_LEVEL_LOW(ADC1_IN4) | \
888  PIN_ODR_LEVEL_HIGH(SPI1_SCK) | \
889  PIN_ODR_LEVEL_HIGH(SPI1_MISO) | \
890  PIN_ODR_LEVEL_HIGH(SPI1_MOSI) | \
891  PIN_ODR_LEVEL_HIGH(CU1_CH1) | \
892  PIN_ODR_LEVEL_LOW(OTG_FS_VBUS) | \
893  PIN_ODR_LEVEL_HIGH(USART1_RX) | \
894  PIN_ODR_LEVEL_HIGH(OTG_FS_DM) | \
895  PIN_ODR_LEVEL_HIGH(OTG_FS_DP) | \
896  PIN_ODR_LEVEL_HIGH(SWDIO) | \
897  PIN_ODR_LEVEL_HIGH(SWCLK) | \
898  PIN_ODR_LEVEL_LOW(SERVO5))
899 
900 #define VAL_GPIOA_AFRL (PIN_AFIO_AF(UART4_TX, 8) | \
901  PIN_AFIO_AF(UART4_RX, 8) | \
902  PIN_AFIO_AF(SERVO1, 1) | \
903  PIN_AFIO_AF(UART2_RX, 7) | \
904  PIN_AFIO_AF(ADC1_IN4, 0) | \
905  PIN_AFIO_AF(SPI1_SCK, 5) | \
906  PIN_AFIO_AF(SPI1_MISO, 5) | \
907  PIN_AFIO_AF(SPI1_MOSI, 5))
908 
909 #define VAL_GPIOA_AFRH (PIN_AFIO_AF(CU1_CH1, 1) | \
910  PIN_AFIO_AF(OTG_FS_VBUS, 0) | \
911  PIN_AFIO_AF(USART1_RX, 7) | \
912  PIN_AFIO_AF(OTG_FS_DM, 10) | \
913  PIN_AFIO_AF(OTG_FS_DP, 10) | \
914  PIN_AFIO_AF(SWDIO, 0) | \
915  PIN_AFIO_AF(SWCLK, 0) | \
916  PIN_AFIO_AF(SERVO5, 1))
917 
918 #define VAL_GPIOB_MODER (PIN_MODE_ALTERNATE(SERVO0) | \
919  PIN_MODE_ALTERNATE(SERVO6) | \
920  PIN_MODE_INPUT(BOOT1) | \
921  PIN_MODE_ALTERNATE(SERVO4) | \
922  PIN_MODE_ALTERNATE(SERVO3) | \
923  PIN_MODE_ALTERNATE(SERVO2) | \
924  PIN_MODE_ALTERNATE(USART1_TX) | \
925  PIN_MODE_ALTERNATE(I2C1_SDA) | \
926  PIN_MODE_ALTERNATE(I2C1_SCL) | \
927  PIN_MODE_OUTPUT(SPI1_CS) | \
928  PIN_MODE_ALTERNATE(I2C2_SCL) | \
929  PIN_MODE_ALTERNATE(I2C2_SDA) | \
930  PIN_MODE_OUTPUT(POWER_SWITCH) | \
931  PIN_MODE_OUTPUT(RX2_POL) | \
932  PIN_MODE_INPUT(SDIO_DETECT) | \
933  PIN_MODE_INPUT(AUX4))
934 
935 #define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(SERVO0) | \
936  PIN_OTYPE_PUSHPULL(SERVO6) | \
937  PIN_OTYPE_OPENDRAIN(BOOT1) | \
938  PIN_OTYPE_PUSHPULL(SERVO4) | \
939  PIN_OTYPE_PUSHPULL(SERVO3) | \
940  PIN_OTYPE_PUSHPULL(SERVO2) | \
941  PIN_OTYPE_PUSHPULL(USART1_TX) | \
942  PIN_OTYPE_OPENDRAIN(I2C1_SDA) | \
943  PIN_OTYPE_OPENDRAIN(I2C1_SCL) | \
944  PIN_OTYPE_PUSHPULL(SPI1_CS) | \
945  PIN_OTYPE_OPENDRAIN(I2C2_SCL) | \
946  PIN_OTYPE_OPENDRAIN(I2C2_SDA) | \
947  PIN_OTYPE_PUSHPULL(POWER_SWITCH) | \
948  PIN_OTYPE_PUSHPULL(RX2_POL) | \
949  PIN_OTYPE_OPENDRAIN(SDIO_DETECT) | \
950  PIN_OTYPE_OPENDRAIN(AUX4))
951 
952 #define VAL_GPIOB_OSPEEDR (PIN_OSPEED_SPEED_HIGH(SERVO0) | \
953  PIN_OSPEED_SPEED_HIGH(SERVO6) | \
954  PIN_OSPEED_SPEED_VERYLOW(BOOT1) | \
955  PIN_OSPEED_SPEED_HIGH(SERVO4) | \
956  PIN_OSPEED_SPEED_HIGH(SERVO3) | \
957  PIN_OSPEED_SPEED_HIGH(SERVO2) | \
958  PIN_OSPEED_SPEED_HIGH(USART1_TX) | \
959  PIN_OSPEED_SPEED_HIGH(I2C1_SDA) | \
960  PIN_OSPEED_SPEED_HIGH(I2C1_SCL) | \
961  PIN_OSPEED_SPEED_HIGH(SPI1_CS) | \
962  PIN_OSPEED_SPEED_HIGH(I2C2_SCL) | \
963  PIN_OSPEED_SPEED_HIGH(I2C2_SDA) | \
964  PIN_OSPEED_SPEED_HIGH(POWER_SWITCH) | \
965  PIN_OSPEED_SPEED_HIGH(RX2_POL) | \
966  PIN_OSPEED_SPEED_VERYLOW(SDIO_DETECT) | \
967  PIN_OSPEED_SPEED_VERYLOW(AUX4))
968 
969 #define VAL_GPIOB_PUPDR (PIN_PUPDR_FLOATING(SERVO0) | \
970  PIN_PUPDR_FLOATING(SERVO6) | \
971  PIN_PUPDR_FLOATING(BOOT1) | \
972  PIN_PUPDR_FLOATING(SERVO4) | \
973  PIN_PUPDR_FLOATING(SERVO3) | \
974  PIN_PUPDR_FLOATING(SERVO2) | \
975  PIN_PUPDR_FLOATING(USART1_TX) | \
976  PIN_PUPDR_PULLUP(I2C1_SDA) | \
977  PIN_PUPDR_PULLUP(I2C1_SCL) | \
978  PIN_PUPDR_FLOATING(SPI1_CS) | \
979  PIN_PUPDR_PULLUP(I2C2_SCL) | \
980  PIN_PUPDR_PULLUP(I2C2_SDA) | \
981  PIN_PUPDR_FLOATING(POWER_SWITCH) | \
982  PIN_PUPDR_FLOATING(RX2_POL) | \
983  PIN_PUPDR_PULLUP(SDIO_DETECT) | \
984  PIN_PUPDR_FLOATING(AUX4))
985 
986 #define VAL_GPIOB_ODR (PIN_ODR_LEVEL_LOW(SERVO0) | \
987  PIN_ODR_LEVEL_LOW(SERVO6) | \
988  PIN_ODR_LEVEL_LOW(BOOT1) | \
989  PIN_ODR_LEVEL_LOW(SERVO4) | \
990  PIN_ODR_LEVEL_LOW(SERVO3) | \
991  PIN_ODR_LEVEL_LOW(SERVO2) | \
992  PIN_ODR_LEVEL_HIGH(USART1_TX) | \
993  PIN_ODR_LEVEL_HIGH(I2C1_SDA) | \
994  PIN_ODR_LEVEL_HIGH(I2C1_SCL) | \
995  PIN_ODR_LEVEL_HIGH(SPI1_CS) | \
996  PIN_ODR_LEVEL_HIGH(I2C2_SCL) | \
997  PIN_ODR_LEVEL_HIGH(I2C2_SDA) | \
998  PIN_ODR_LEVEL_HIGH(POWER_SWITCH) | \
999  PIN_ODR_LEVEL_HIGH(RX2_POL) | \
1000  PIN_ODR_LEVEL_LOW(SDIO_DETECT) | \
1001  PIN_ODR_LEVEL_LOW(AUX4))
1002 
1003 #define VAL_GPIOB_AFRL (PIN_AFIO_AF(SERVO0, 2) | \
1004  PIN_AFIO_AF(SERVO6, 2) | \
1005  PIN_AFIO_AF(BOOT1, 0) | \
1006  PIN_AFIO_AF(SERVO4, 1) | \
1007  PIN_AFIO_AF(SERVO3, 2) | \
1008  PIN_AFIO_AF(SERVO2, 2) | \
1009  PIN_AFIO_AF(USART1_TX, 7) | \
1010  PIN_AFIO_AF(I2C1_SDA, 4))
1011 
1012 #define VAL_GPIOB_AFRH (PIN_AFIO_AF(I2C1_SCL, 4) | \
1013  PIN_AFIO_AF(SPI1_CS, 0) | \
1014  PIN_AFIO_AF(I2C2_SCL, 4) | \
1015  PIN_AFIO_AF(I2C2_SDA, 4) | \
1016  PIN_AFIO_AF(POWER_SWITCH, 0) | \
1017  PIN_AFIO_AF(RX2_POL, 0) | \
1018  PIN_AFIO_AF(SDIO_DETECT, 0) | \
1019  PIN_AFIO_AF(AUX4, 0))
1020 
1021 #define VAL_GPIOC_MODER (PIN_MODE_OUTPUT(LED1) | \
1022  PIN_MODE_OUTPUT(LED3) | \
1023  PIN_MODE_INPUT(PC02) | \
1024  PIN_MODE_OUTPUT(LED4) | \
1025  PIN_MODE_INPUT(AUX3) | \
1026  PIN_MODE_INPUT(AUX2) | \
1027  PIN_MODE_ALTERNATE(USART6_TX) | \
1028  PIN_MODE_ALTERNATE(USART6_RX) | \
1029  PIN_MODE_ALTERNATE(SDIO_D0) | \
1030  PIN_MODE_ALTERNATE(SDIO_D1) | \
1031  PIN_MODE_ALTERNATE(SDIO_D2) | \
1032  PIN_MODE_ALTERNATE(SDIO_D3) | \
1033  PIN_MODE_ALTERNATE(SDIO_CK) | \
1034  PIN_MODE_OUTPUT(LED2) | \
1035  PIN_MODE_ALTERNATE(OSC32_IN) | \
1036  PIN_MODE_ALTERNATE(OSC32_OUT))
1037 
1038 #define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(LED1) | \
1039  PIN_OTYPE_PUSHPULL(LED3) | \
1040  PIN_OTYPE_PUSHPULL(PC02) | \
1041  PIN_OTYPE_PUSHPULL(LED4) | \
1042  PIN_OTYPE_OPENDRAIN(AUX3) | \
1043  PIN_OTYPE_OPENDRAIN(AUX2) | \
1044  PIN_OTYPE_PUSHPULL(USART6_TX) | \
1045  PIN_OTYPE_PUSHPULL(USART6_RX) | \
1046  PIN_OTYPE_PUSHPULL(SDIO_D0) | \
1047  PIN_OTYPE_PUSHPULL(SDIO_D1) | \
1048  PIN_OTYPE_PUSHPULL(SDIO_D2) | \
1049  PIN_OTYPE_PUSHPULL(SDIO_D3) | \
1050  PIN_OTYPE_PUSHPULL(SDIO_CK) | \
1051  PIN_OTYPE_PUSHPULL(LED2) | \
1052  PIN_OTYPE_PUSHPULL(OSC32_IN) | \
1053  PIN_OTYPE_PUSHPULL(OSC32_OUT))
1054 
1055 #define VAL_GPIOC_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(LED1) | \
1056  PIN_OSPEED_SPEED_VERYLOW(LED3) | \
1057  PIN_OSPEED_SPEED_VERYLOW(PC02) | \
1058  PIN_OSPEED_SPEED_VERYLOW(LED4) | \
1059  PIN_OSPEED_SPEED_VERYLOW(AUX3) | \
1060  PIN_OSPEED_SPEED_VERYLOW(AUX2) | \
1061  PIN_OSPEED_SPEED_HIGH(USART6_TX) | \
1062  PIN_OSPEED_SPEED_HIGH(USART6_RX) | \
1063  PIN_OSPEED_SPEED_HIGH(SDIO_D0) | \
1064  PIN_OSPEED_SPEED_HIGH(SDIO_D1) | \
1065  PIN_OSPEED_SPEED_HIGH(SDIO_D2) | \
1066  PIN_OSPEED_SPEED_HIGH(SDIO_D3) | \
1067  PIN_OSPEED_SPEED_HIGH(SDIO_CK) | \
1068  PIN_OSPEED_SPEED_VERYLOW(LED2) | \
1069  PIN_OSPEED_SPEED_HIGH(OSC32_IN) | \
1070  PIN_OSPEED_SPEED_HIGH(OSC32_OUT))
1071 
1072 #define VAL_GPIOC_PUPDR (PIN_PUPDR_FLOATING(LED1) | \
1073  PIN_PUPDR_FLOATING(LED3) | \
1074  PIN_PUPDR_PULLDOWN(PC02) | \
1075  PIN_PUPDR_FLOATING(LED4) | \
1076  PIN_PUPDR_FLOATING(AUX3) | \
1077  PIN_PUPDR_FLOATING(AUX2) | \
1078  PIN_PUPDR_FLOATING(USART6_TX) | \
1079  PIN_PUPDR_FLOATING(USART6_RX) | \
1080  PIN_PUPDR_PULLUP(SDIO_D0) | \
1081  PIN_PUPDR_PULLUP(SDIO_D1) | \
1082  PIN_PUPDR_PULLUP(SDIO_D2) | \
1083  PIN_PUPDR_PULLUP(SDIO_D3) | \
1084  PIN_PUPDR_FLOATING(SDIO_CK) | \
1085  PIN_PUPDR_FLOATING(LED2) | \
1086  PIN_PUPDR_FLOATING(OSC32_IN) | \
1087  PIN_PUPDR_FLOATING(OSC32_OUT))
1088 
1089 #define VAL_GPIOC_ODR (PIN_ODR_LEVEL_LOW(LED1) | \
1090  PIN_ODR_LEVEL_LOW(LED3) | \
1091  PIN_ODR_LEVEL_LOW(PC02) | \
1092  PIN_ODR_LEVEL_LOW(LED4) | \
1093  PIN_ODR_LEVEL_LOW(AUX3) | \
1094  PIN_ODR_LEVEL_LOW(AUX2) | \
1095  PIN_ODR_LEVEL_HIGH(USART6_TX) | \
1096  PIN_ODR_LEVEL_HIGH(USART6_RX) | \
1097  PIN_ODR_LEVEL_HIGH(SDIO_D0) | \
1098  PIN_ODR_LEVEL_HIGH(SDIO_D1) | \
1099  PIN_ODR_LEVEL_HIGH(SDIO_D2) | \
1100  PIN_ODR_LEVEL_HIGH(SDIO_D3) | \
1101  PIN_ODR_LEVEL_HIGH(SDIO_CK) | \
1102  PIN_ODR_LEVEL_LOW(LED2) | \
1103  PIN_ODR_LEVEL_HIGH(OSC32_IN) | \
1104  PIN_ODR_LEVEL_HIGH(OSC32_OUT))
1105 
1106 #define VAL_GPIOC_AFRL (PIN_AFIO_AF(LED1, 0) | \
1107  PIN_AFIO_AF(LED3, 0) | \
1108  PIN_AFIO_AF(PC02, 0) | \
1109  PIN_AFIO_AF(LED4, 0) | \
1110  PIN_AFIO_AF(AUX3, 0) | \
1111  PIN_AFIO_AF(AUX2, 0) | \
1112  PIN_AFIO_AF(USART6_TX, 8) | \
1113  PIN_AFIO_AF(USART6_RX, 8))
1114 
1115 #define VAL_GPIOC_AFRH (PIN_AFIO_AF(SDIO_D0, 12) | \
1116  PIN_AFIO_AF(SDIO_D1, 12) | \
1117  PIN_AFIO_AF(SDIO_D2, 12) | \
1118  PIN_AFIO_AF(SDIO_D3, 12) | \
1119  PIN_AFIO_AF(SDIO_CK, 12) | \
1120  PIN_AFIO_AF(LED2, 0) | \
1121  PIN_AFIO_AF(OSC32_IN, 0) | \
1122  PIN_AFIO_AF(OSC32_OUT, 0))
1123 
1124 #define VAL_GPIOD_MODER (PIN_MODE_INPUT(PD00) | \
1125  PIN_MODE_INPUT(PD01) | \
1126  PIN_MODE_ALTERNATE(SDIO_CMD) | \
1127  PIN_MODE_INPUT(PD03) | \
1128  PIN_MODE_INPUT(PD04) | \
1129  PIN_MODE_INPUT(PD05) | \
1130  PIN_MODE_INPUT(PD06) | \
1131  PIN_MODE_INPUT(PD07) | \
1132  PIN_MODE_INPUT(PD08) | \
1133  PIN_MODE_INPUT(PD09) | \
1134  PIN_MODE_INPUT(PD10) | \
1135  PIN_MODE_INPUT(PD11) | \
1136  PIN_MODE_INPUT(PD12) | \
1137  PIN_MODE_INPUT(PD13) | \
1138  PIN_MODE_INPUT(PD14) | \
1139  PIN_MODE_INPUT(PD15))
1140 
1141 #define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(PD00) | \
1142  PIN_OTYPE_PUSHPULL(PD01) | \
1143  PIN_OTYPE_PUSHPULL(SDIO_CMD) | \
1144  PIN_OTYPE_PUSHPULL(PD03) | \
1145  PIN_OTYPE_PUSHPULL(PD04) | \
1146  PIN_OTYPE_PUSHPULL(PD05) | \
1147  PIN_OTYPE_PUSHPULL(PD06) | \
1148  PIN_OTYPE_PUSHPULL(PD07) | \
1149  PIN_OTYPE_PUSHPULL(PD08) | \
1150  PIN_OTYPE_PUSHPULL(PD09) | \
1151  PIN_OTYPE_PUSHPULL(PD10) | \
1152  PIN_OTYPE_PUSHPULL(PD11) | \
1153  PIN_OTYPE_PUSHPULL(PD12) | \
1154  PIN_OTYPE_PUSHPULL(PD13) | \
1155  PIN_OTYPE_PUSHPULL(PD14) | \
1156  PIN_OTYPE_PUSHPULL(PD15))
1157 
1158 #define VAL_GPIOD_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PD00) | \
1159  PIN_OSPEED_SPEED_VERYLOW(PD01) | \
1160  PIN_OSPEED_SPEED_HIGH(SDIO_CMD) | \
1161  PIN_OSPEED_SPEED_VERYLOW(PD03) | \
1162  PIN_OSPEED_SPEED_VERYLOW(PD04) | \
1163  PIN_OSPEED_SPEED_VERYLOW(PD05) | \
1164  PIN_OSPEED_SPEED_VERYLOW(PD06) | \
1165  PIN_OSPEED_SPEED_VERYLOW(PD07) | \
1166  PIN_OSPEED_SPEED_VERYLOW(PD08) | \
1167  PIN_OSPEED_SPEED_VERYLOW(PD09) | \
1168  PIN_OSPEED_SPEED_VERYLOW(PD10) | \
1169  PIN_OSPEED_SPEED_VERYLOW(PD11) | \
1170  PIN_OSPEED_SPEED_VERYLOW(PD12) | \
1171  PIN_OSPEED_SPEED_VERYLOW(PD13) | \
1172  PIN_OSPEED_SPEED_VERYLOW(PD14) | \
1173  PIN_OSPEED_SPEED_VERYLOW(PD15))
1174 
1175 #define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLDOWN(PD00) | \
1176  PIN_PUPDR_PULLDOWN(PD01) | \
1177  PIN_PUPDR_PULLUP(SDIO_CMD) | \
1178  PIN_PUPDR_PULLDOWN(PD03) | \
1179  PIN_PUPDR_PULLDOWN(PD04) | \
1180  PIN_PUPDR_PULLDOWN(PD05) | \
1181  PIN_PUPDR_PULLDOWN(PD06) | \
1182  PIN_PUPDR_PULLDOWN(PD07) | \
1183  PIN_PUPDR_PULLDOWN(PD08) | \
1184  PIN_PUPDR_PULLDOWN(PD09) | \
1185  PIN_PUPDR_PULLDOWN(PD10) | \
1186  PIN_PUPDR_PULLDOWN(PD11) | \
1187  PIN_PUPDR_PULLDOWN(PD12) | \
1188  PIN_PUPDR_PULLDOWN(PD13) | \
1189  PIN_PUPDR_PULLDOWN(PD14) | \
1190  PIN_PUPDR_PULLDOWN(PD15))
1191 
1192 #define VAL_GPIOD_ODR (PIN_ODR_LEVEL_LOW(PD00) | \
1193  PIN_ODR_LEVEL_LOW(PD01) | \
1194  PIN_ODR_LEVEL_HIGH(SDIO_CMD) | \
1195  PIN_ODR_LEVEL_LOW(PD03) | \
1196  PIN_ODR_LEVEL_LOW(PD04) | \
1197  PIN_ODR_LEVEL_LOW(PD05) | \
1198  PIN_ODR_LEVEL_LOW(PD06) | \
1199  PIN_ODR_LEVEL_LOW(PD07) | \
1200  PIN_ODR_LEVEL_LOW(PD08) | \
1201  PIN_ODR_LEVEL_LOW(PD09) | \
1202  PIN_ODR_LEVEL_LOW(PD10) | \
1203  PIN_ODR_LEVEL_LOW(PD11) | \
1204  PIN_ODR_LEVEL_LOW(PD12) | \
1205  PIN_ODR_LEVEL_LOW(PD13) | \
1206  PIN_ODR_LEVEL_LOW(PD14) | \
1207  PIN_ODR_LEVEL_LOW(PD15))
1208 
1209 #define VAL_GPIOD_AFRL (PIN_AFIO_AF(PD00, 0) | \
1210  PIN_AFIO_AF(PD01, 0) | \
1211  PIN_AFIO_AF(SDIO_CMD, 12) | \
1212  PIN_AFIO_AF(PD03, 0) | \
1213  PIN_AFIO_AF(PD04, 0) | \
1214  PIN_AFIO_AF(PD05, 0) | \
1215  PIN_AFIO_AF(PD06, 0) | \
1216  PIN_AFIO_AF(PD07, 0))
1217 
1218 #define VAL_GPIOD_AFRH (PIN_AFIO_AF(PD08, 0) | \
1219  PIN_AFIO_AF(PD09, 0) | \
1220  PIN_AFIO_AF(PD10, 0) | \
1221  PIN_AFIO_AF(PD11, 0) | \
1222  PIN_AFIO_AF(PD12, 0) | \
1223  PIN_AFIO_AF(PD13, 0) | \
1224  PIN_AFIO_AF(PD14, 0) | \
1225  PIN_AFIO_AF(PD15, 0))
1226 
1227 #define VAL_GPIOE_MODER (PIN_MODE_INPUT(PE00) | \
1228  PIN_MODE_INPUT(PE01) | \
1229  PIN_MODE_INPUT(PE02) | \
1230  PIN_MODE_INPUT(PE03) | \
1231  PIN_MODE_INPUT(PE04) | \
1232  PIN_MODE_INPUT(PE05) | \
1233  PIN_MODE_INPUT(PE06) | \
1234  PIN_MODE_INPUT(PE07) | \
1235  PIN_MODE_INPUT(PE08) | \
1236  PIN_MODE_INPUT(PE09) | \
1237  PIN_MODE_INPUT(PE10) | \
1238  PIN_MODE_INPUT(PE11) | \
1239  PIN_MODE_INPUT(PE12) | \
1240  PIN_MODE_INPUT(PE13) | \
1241  PIN_MODE_INPUT(PE14) | \
1242  PIN_MODE_INPUT(PE15))
1243 
1244 #define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(PE00) | \
1245  PIN_OTYPE_PUSHPULL(PE01) | \
1246  PIN_OTYPE_PUSHPULL(PE02) | \
1247  PIN_OTYPE_PUSHPULL(PE03) | \
1248  PIN_OTYPE_PUSHPULL(PE04) | \
1249  PIN_OTYPE_PUSHPULL(PE05) | \
1250  PIN_OTYPE_PUSHPULL(PE06) | \
1251  PIN_OTYPE_PUSHPULL(PE07) | \
1252  PIN_OTYPE_PUSHPULL(PE08) | \
1253  PIN_OTYPE_PUSHPULL(PE09) | \
1254  PIN_OTYPE_PUSHPULL(PE10) | \
1255  PIN_OTYPE_PUSHPULL(PE11) | \
1256  PIN_OTYPE_PUSHPULL(PE12) | \
1257  PIN_OTYPE_PUSHPULL(PE13) | \
1258  PIN_OTYPE_PUSHPULL(PE14) | \
1259  PIN_OTYPE_PUSHPULL(PE15))
1260 
1261 #define VAL_GPIOE_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PE00) | \
1262  PIN_OSPEED_SPEED_VERYLOW(PE01) | \
1263  PIN_OSPEED_SPEED_VERYLOW(PE02) | \
1264  PIN_OSPEED_SPEED_VERYLOW(PE03) | \
1265  PIN_OSPEED_SPEED_VERYLOW(PE04) | \
1266  PIN_OSPEED_SPEED_VERYLOW(PE05) | \
1267  PIN_OSPEED_SPEED_VERYLOW(PE06) | \
1268  PIN_OSPEED_SPEED_VERYLOW(PE07) | \
1269  PIN_OSPEED_SPEED_VERYLOW(PE08) | \
1270  PIN_OSPEED_SPEED_VERYLOW(PE09) | \
1271  PIN_OSPEED_SPEED_VERYLOW(PE10) | \
1272  PIN_OSPEED_SPEED_VERYLOW(PE11) | \
1273  PIN_OSPEED_SPEED_VERYLOW(PE12) | \
1274  PIN_OSPEED_SPEED_VERYLOW(PE13) | \
1275  PIN_OSPEED_SPEED_VERYLOW(PE14) | \
1276  PIN_OSPEED_SPEED_VERYLOW(PE15))
1277 
1278 #define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLDOWN(PE00) | \
1279  PIN_PUPDR_PULLDOWN(PE01) | \
1280  PIN_PUPDR_PULLDOWN(PE02) | \
1281  PIN_PUPDR_PULLDOWN(PE03) | \
1282  PIN_PUPDR_PULLDOWN(PE04) | \
1283  PIN_PUPDR_PULLDOWN(PE05) | \
1284  PIN_PUPDR_PULLDOWN(PE06) | \
1285  PIN_PUPDR_PULLDOWN(PE07) | \
1286  PIN_PUPDR_PULLDOWN(PE08) | \
1287  PIN_PUPDR_PULLDOWN(PE09) | \
1288  PIN_PUPDR_PULLDOWN(PE10) | \
1289  PIN_PUPDR_PULLDOWN(PE11) | \
1290  PIN_PUPDR_PULLDOWN(PE12) | \
1291  PIN_PUPDR_PULLDOWN(PE13) | \
1292  PIN_PUPDR_PULLDOWN(PE14) | \
1293  PIN_PUPDR_PULLDOWN(PE15))
1294 
1295 #define VAL_GPIOE_ODR (PIN_ODR_LEVEL_LOW(PE00) | \
1296  PIN_ODR_LEVEL_LOW(PE01) | \
1297  PIN_ODR_LEVEL_LOW(PE02) | \
1298  PIN_ODR_LEVEL_LOW(PE03) | \
1299  PIN_ODR_LEVEL_LOW(PE04) | \
1300  PIN_ODR_LEVEL_LOW(PE05) | \
1301  PIN_ODR_LEVEL_LOW(PE06) | \
1302  PIN_ODR_LEVEL_LOW(PE07) | \
1303  PIN_ODR_LEVEL_LOW(PE08) | \
1304  PIN_ODR_LEVEL_LOW(PE09) | \
1305  PIN_ODR_LEVEL_LOW(PE10) | \
1306  PIN_ODR_LEVEL_LOW(PE11) | \
1307  PIN_ODR_LEVEL_LOW(PE12) | \
1308  PIN_ODR_LEVEL_LOW(PE13) | \
1309  PIN_ODR_LEVEL_LOW(PE14) | \
1310  PIN_ODR_LEVEL_LOW(PE15))
1311 
1312 #define VAL_GPIOE_AFRL (PIN_AFIO_AF(PE00, 0) | \
1313  PIN_AFIO_AF(PE01, 0) | \
1314  PIN_AFIO_AF(PE02, 0) | \
1315  PIN_AFIO_AF(PE03, 0) | \
1316  PIN_AFIO_AF(PE04, 0) | \
1317  PIN_AFIO_AF(PE05, 0) | \
1318  PIN_AFIO_AF(PE06, 0) | \
1319  PIN_AFIO_AF(PE07, 0))
1320 
1321 #define VAL_GPIOE_AFRH (PIN_AFIO_AF(PE08, 0) | \
1322  PIN_AFIO_AF(PE09, 0) | \
1323  PIN_AFIO_AF(PE10, 0) | \
1324  PIN_AFIO_AF(PE11, 0) | \
1325  PIN_AFIO_AF(PE12, 0) | \
1326  PIN_AFIO_AF(PE13, 0) | \
1327  PIN_AFIO_AF(PE14, 0) | \
1328  PIN_AFIO_AF(PE15, 0))
1329 
1330 #define VAL_GPIOF_MODER (PIN_MODE_INPUT(PF00) | \
1331  PIN_MODE_INPUT(PF01) | \
1332  PIN_MODE_INPUT(PF02) | \
1333  PIN_MODE_INPUT(PF03) | \
1334  PIN_MODE_INPUT(PF04) | \
1335  PIN_MODE_INPUT(PF05) | \
1336  PIN_MODE_INPUT(PF06) | \
1337  PIN_MODE_INPUT(PF07) | \
1338  PIN_MODE_INPUT(PF08) | \
1339  PIN_MODE_INPUT(PF09) | \
1340  PIN_MODE_INPUT(PF10) | \
1341  PIN_MODE_INPUT(PF11) | \
1342  PIN_MODE_INPUT(PF12) | \
1343  PIN_MODE_INPUT(PF13) | \
1344  PIN_MODE_INPUT(PF14) | \
1345  PIN_MODE_INPUT(PF15))
1346 
1347 #define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(PF00) | \
1348  PIN_OTYPE_PUSHPULL(PF01) | \
1349  PIN_OTYPE_PUSHPULL(PF02) | \
1350  PIN_OTYPE_PUSHPULL(PF03) | \
1351  PIN_OTYPE_PUSHPULL(PF04) | \
1352  PIN_OTYPE_PUSHPULL(PF05) | \
1353  PIN_OTYPE_PUSHPULL(PF06) | \
1354  PIN_OTYPE_PUSHPULL(PF07) | \
1355  PIN_OTYPE_PUSHPULL(PF08) | \
1356  PIN_OTYPE_PUSHPULL(PF09) | \
1357  PIN_OTYPE_PUSHPULL(PF10) | \
1358  PIN_OTYPE_PUSHPULL(PF11) | \
1359  PIN_OTYPE_PUSHPULL(PF12) | \
1360  PIN_OTYPE_PUSHPULL(PF13) | \
1361  PIN_OTYPE_PUSHPULL(PF14) | \
1362  PIN_OTYPE_PUSHPULL(PF15))
1363 
1364 #define VAL_GPIOF_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PF00) | \
1365  PIN_OSPEED_SPEED_VERYLOW(PF01) | \
1366  PIN_OSPEED_SPEED_VERYLOW(PF02) | \
1367  PIN_OSPEED_SPEED_VERYLOW(PF03) | \
1368  PIN_OSPEED_SPEED_VERYLOW(PF04) | \
1369  PIN_OSPEED_SPEED_VERYLOW(PF05) | \
1370  PIN_OSPEED_SPEED_VERYLOW(PF06) | \
1371  PIN_OSPEED_SPEED_VERYLOW(PF07) | \
1372  PIN_OSPEED_SPEED_VERYLOW(PF08) | \
1373  PIN_OSPEED_SPEED_VERYLOW(PF09) | \
1374  PIN_OSPEED_SPEED_VERYLOW(PF10) | \
1375  PIN_OSPEED_SPEED_VERYLOW(PF11) | \
1376  PIN_OSPEED_SPEED_VERYLOW(PF12) | \
1377  PIN_OSPEED_SPEED_VERYLOW(PF13) | \
1378  PIN_OSPEED_SPEED_VERYLOW(PF14) | \
1379  PIN_OSPEED_SPEED_VERYLOW(PF15))
1380 
1381 #define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLDOWN(PF00) | \
1382  PIN_PUPDR_PULLDOWN(PF01) | \
1383  PIN_PUPDR_PULLDOWN(PF02) | \
1384  PIN_PUPDR_PULLDOWN(PF03) | \
1385  PIN_PUPDR_PULLDOWN(PF04) | \
1386  PIN_PUPDR_PULLDOWN(PF05) | \
1387  PIN_PUPDR_PULLDOWN(PF06) | \
1388  PIN_PUPDR_PULLDOWN(PF07) | \
1389  PIN_PUPDR_PULLDOWN(PF08) | \
1390  PIN_PUPDR_PULLDOWN(PF09) | \
1391  PIN_PUPDR_PULLDOWN(PF10) | \
1392  PIN_PUPDR_PULLDOWN(PF11) | \
1393  PIN_PUPDR_PULLDOWN(PF12) | \
1394  PIN_PUPDR_PULLDOWN(PF13) | \
1395  PIN_PUPDR_PULLDOWN(PF14) | \
1396  PIN_PUPDR_PULLDOWN(PF15))
1397 
1398 #define VAL_GPIOF_ODR (PIN_ODR_LEVEL_LOW(PF00) | \
1399  PIN_ODR_LEVEL_LOW(PF01) | \
1400  PIN_ODR_LEVEL_LOW(PF02) | \
1401  PIN_ODR_LEVEL_LOW(PF03) | \
1402  PIN_ODR_LEVEL_LOW(PF04) | \
1403  PIN_ODR_LEVEL_LOW(PF05) | \
1404  PIN_ODR_LEVEL_LOW(PF06) | \
1405  PIN_ODR_LEVEL_LOW(PF07) | \
1406  PIN_ODR_LEVEL_LOW(PF08) | \
1407  PIN_ODR_LEVEL_LOW(PF09) | \
1408  PIN_ODR_LEVEL_LOW(PF10) | \
1409  PIN_ODR_LEVEL_LOW(PF11) | \
1410  PIN_ODR_LEVEL_LOW(PF12) | \
1411  PIN_ODR_LEVEL_LOW(PF13) | \
1412  PIN_ODR_LEVEL_LOW(PF14) | \
1413  PIN_ODR_LEVEL_LOW(PF15))
1414 
1415 #define VAL_GPIOF_AFRL (PIN_AFIO_AF(PF00, 0) | \
1416  PIN_AFIO_AF(PF01, 0) | \
1417  PIN_AFIO_AF(PF02, 0) | \
1418  PIN_AFIO_AF(PF03, 0) | \
1419  PIN_AFIO_AF(PF04, 0) | \
1420  PIN_AFIO_AF(PF05, 0) | \
1421  PIN_AFIO_AF(PF06, 0) | \
1422  PIN_AFIO_AF(PF07, 0))
1423 
1424 #define VAL_GPIOF_AFRH (PIN_AFIO_AF(PF08, 0) | \
1425  PIN_AFIO_AF(PF09, 0) | \
1426  PIN_AFIO_AF(PF10, 0) | \
1427  PIN_AFIO_AF(PF11, 0) | \
1428  PIN_AFIO_AF(PF12, 0) | \
1429  PIN_AFIO_AF(PF13, 0) | \
1430  PIN_AFIO_AF(PF14, 0) | \
1431  PIN_AFIO_AF(PF15, 0))
1432 
1433 #define VAL_GPIOG_MODER (PIN_MODE_INPUT(PG00) | \
1434  PIN_MODE_INPUT(PG01) | \
1435  PIN_MODE_INPUT(PG02) | \
1436  PIN_MODE_INPUT(PG03) | \
1437  PIN_MODE_INPUT(PG04) | \
1438  PIN_MODE_INPUT(PG05) | \
1439  PIN_MODE_INPUT(PG06) | \
1440  PIN_MODE_INPUT(PG07) | \
1441  PIN_MODE_INPUT(PG08) | \
1442  PIN_MODE_INPUT(PG09) | \
1443  PIN_MODE_INPUT(PG10) | \
1444  PIN_MODE_INPUT(PG11) | \
1445  PIN_MODE_INPUT(PG12) | \
1446  PIN_MODE_INPUT(PG13) | \
1447  PIN_MODE_INPUT(PG14) | \
1448  PIN_MODE_INPUT(PG15))
1449 
1450 #define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(PG00) | \
1451  PIN_OTYPE_PUSHPULL(PG01) | \
1452  PIN_OTYPE_PUSHPULL(PG02) | \
1453  PIN_OTYPE_PUSHPULL(PG03) | \
1454  PIN_OTYPE_PUSHPULL(PG04) | \
1455  PIN_OTYPE_PUSHPULL(PG05) | \
1456  PIN_OTYPE_PUSHPULL(PG06) | \
1457  PIN_OTYPE_PUSHPULL(PG07) | \
1458  PIN_OTYPE_PUSHPULL(PG08) | \
1459  PIN_OTYPE_PUSHPULL(PG09) | \
1460  PIN_OTYPE_PUSHPULL(PG10) | \
1461  PIN_OTYPE_PUSHPULL(PG11) | \
1462  PIN_OTYPE_PUSHPULL(PG12) | \
1463  PIN_OTYPE_PUSHPULL(PG13) | \
1464  PIN_OTYPE_PUSHPULL(PG14) | \
1465  PIN_OTYPE_PUSHPULL(PG15))
1466 
1467 #define VAL_GPIOG_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PG00) | \
1468  PIN_OSPEED_SPEED_VERYLOW(PG01) | \
1469  PIN_OSPEED_SPEED_VERYLOW(PG02) | \
1470  PIN_OSPEED_SPEED_VERYLOW(PG03) | \
1471  PIN_OSPEED_SPEED_VERYLOW(PG04) | \
1472  PIN_OSPEED_SPEED_VERYLOW(PG05) | \
1473  PIN_OSPEED_SPEED_VERYLOW(PG06) | \
1474  PIN_OSPEED_SPEED_VERYLOW(PG07) | \
1475  PIN_OSPEED_SPEED_VERYLOW(PG08) | \
1476  PIN_OSPEED_SPEED_VERYLOW(PG09) | \
1477  PIN_OSPEED_SPEED_VERYLOW(PG10) | \
1478  PIN_OSPEED_SPEED_VERYLOW(PG11) | \
1479  PIN_OSPEED_SPEED_VERYLOW(PG12) | \
1480  PIN_OSPEED_SPEED_VERYLOW(PG13) | \
1481  PIN_OSPEED_SPEED_VERYLOW(PG14) | \
1482  PIN_OSPEED_SPEED_VERYLOW(PG15))
1483 
1484 #define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLDOWN(PG00) | \
1485  PIN_PUPDR_PULLDOWN(PG01) | \
1486  PIN_PUPDR_PULLDOWN(PG02) | \
1487  PIN_PUPDR_PULLDOWN(PG03) | \
1488  PIN_PUPDR_PULLDOWN(PG04) | \
1489  PIN_PUPDR_PULLDOWN(PG05) | \
1490  PIN_PUPDR_PULLDOWN(PG06) | \
1491  PIN_PUPDR_PULLDOWN(PG07) | \
1492  PIN_PUPDR_PULLDOWN(PG08) | \
1493  PIN_PUPDR_PULLDOWN(PG09) | \
1494  PIN_PUPDR_PULLDOWN(PG10) | \
1495  PIN_PUPDR_PULLDOWN(PG11) | \
1496  PIN_PUPDR_PULLDOWN(PG12) | \
1497  PIN_PUPDR_PULLDOWN(PG13) | \
1498  PIN_PUPDR_PULLDOWN(PG14) | \
1499  PIN_PUPDR_PULLDOWN(PG15))
1500 
1501 #define VAL_GPIOG_ODR (PIN_ODR_LEVEL_LOW(PG00) | \
1502  PIN_ODR_LEVEL_LOW(PG01) | \
1503  PIN_ODR_LEVEL_LOW(PG02) | \
1504  PIN_ODR_LEVEL_LOW(PG03) | \
1505  PIN_ODR_LEVEL_LOW(PG04) | \
1506  PIN_ODR_LEVEL_LOW(PG05) | \
1507  PIN_ODR_LEVEL_LOW(PG06) | \
1508  PIN_ODR_LEVEL_LOW(PG07) | \
1509  PIN_ODR_LEVEL_LOW(PG08) | \
1510  PIN_ODR_LEVEL_LOW(PG09) | \
1511  PIN_ODR_LEVEL_LOW(PG10) | \
1512  PIN_ODR_LEVEL_LOW(PG11) | \
1513  PIN_ODR_LEVEL_LOW(PG12) | \
1514  PIN_ODR_LEVEL_LOW(PG13) | \
1515  PIN_ODR_LEVEL_LOW(PG14) | \
1516  PIN_ODR_LEVEL_LOW(PG15))
1517 
1518 #define VAL_GPIOG_AFRL (PIN_AFIO_AF(PG00, 0) | \
1519  PIN_AFIO_AF(PG01, 0) | \
1520  PIN_AFIO_AF(PG02, 0) | \
1521  PIN_AFIO_AF(PG03, 0) | \
1522  PIN_AFIO_AF(PG04, 0) | \
1523  PIN_AFIO_AF(PG05, 0) | \
1524  PIN_AFIO_AF(PG06, 0) | \
1525  PIN_AFIO_AF(PG07, 0))
1526 
1527 #define VAL_GPIOG_AFRH (PIN_AFIO_AF(PG08, 0) | \
1528  PIN_AFIO_AF(PG09, 0) | \
1529  PIN_AFIO_AF(PG10, 0) | \
1530  PIN_AFIO_AF(PG11, 0) | \
1531  PIN_AFIO_AF(PG12, 0) | \
1532  PIN_AFIO_AF(PG13, 0) | \
1533  PIN_AFIO_AF(PG14, 0) | \
1534  PIN_AFIO_AF(PG15, 0))
1535 
1536 #define VAL_GPIOH_MODER (PIN_MODE_ALTERNATE(OSC_IN) | \
1537  PIN_MODE_ALTERNATE(OSC_OUT) | \
1538  PIN_MODE_INPUT(PH02) | \
1539  PIN_MODE_INPUT(PH03) | \
1540  PIN_MODE_INPUT(PH04) | \
1541  PIN_MODE_INPUT(PH05) | \
1542  PIN_MODE_INPUT(PH06) | \
1543  PIN_MODE_INPUT(PH07) | \
1544  PIN_MODE_INPUT(PH08) | \
1545  PIN_MODE_INPUT(PH09) | \
1546  PIN_MODE_INPUT(PH10) | \
1547  PIN_MODE_INPUT(PH11) | \
1548  PIN_MODE_INPUT(PH12) | \
1549  PIN_MODE_INPUT(PH13) | \
1550  PIN_MODE_INPUT(PH14) | \
1551  PIN_MODE_INPUT(PH15))
1552 
1553 #define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(OSC_IN) | \
1554  PIN_OTYPE_PUSHPULL(OSC_OUT) | \
1555  PIN_OTYPE_PUSHPULL(PH02) | \
1556  PIN_OTYPE_PUSHPULL(PH03) | \
1557  PIN_OTYPE_PUSHPULL(PH04) | \
1558  PIN_OTYPE_PUSHPULL(PH05) | \
1559  PIN_OTYPE_PUSHPULL(PH06) | \
1560  PIN_OTYPE_PUSHPULL(PH07) | \
1561  PIN_OTYPE_PUSHPULL(PH08) | \
1562  PIN_OTYPE_PUSHPULL(PH09) | \
1563  PIN_OTYPE_PUSHPULL(PH10) | \
1564  PIN_OTYPE_PUSHPULL(PH11) | \
1565  PIN_OTYPE_PUSHPULL(PH12) | \
1566  PIN_OTYPE_PUSHPULL(PH13) | \
1567  PIN_OTYPE_PUSHPULL(PH14) | \
1568  PIN_OTYPE_PUSHPULL(PH15))
1569 
1570 #define VAL_GPIOH_OSPEEDR (PIN_OSPEED_SPEED_HIGH(OSC_IN) | \
1571  PIN_OSPEED_SPEED_HIGH(OSC_OUT) | \
1572  PIN_OSPEED_SPEED_VERYLOW(PH02) | \
1573  PIN_OSPEED_SPEED_VERYLOW(PH03) | \
1574  PIN_OSPEED_SPEED_VERYLOW(PH04) | \
1575  PIN_OSPEED_SPEED_VERYLOW(PH05) | \
1576  PIN_OSPEED_SPEED_VERYLOW(PH06) | \
1577  PIN_OSPEED_SPEED_VERYLOW(PH07) | \
1578  PIN_OSPEED_SPEED_VERYLOW(PH08) | \
1579  PIN_OSPEED_SPEED_VERYLOW(PH09) | \
1580  PIN_OSPEED_SPEED_VERYLOW(PH10) | \
1581  PIN_OSPEED_SPEED_VERYLOW(PH11) | \
1582  PIN_OSPEED_SPEED_VERYLOW(PH12) | \
1583  PIN_OSPEED_SPEED_VERYLOW(PH13) | \
1584  PIN_OSPEED_SPEED_VERYLOW(PH14) | \
1585  PIN_OSPEED_SPEED_VERYLOW(PH15))
1586 
1587 #define VAL_GPIOH_PUPDR (PIN_PUPDR_FLOATING(OSC_IN) | \
1588  PIN_PUPDR_FLOATING(OSC_OUT) | \
1589  PIN_PUPDR_PULLDOWN(PH02) | \
1590  PIN_PUPDR_PULLDOWN(PH03) | \
1591  PIN_PUPDR_PULLDOWN(PH04) | \
1592  PIN_PUPDR_PULLDOWN(PH05) | \
1593  PIN_PUPDR_PULLDOWN(PH06) | \
1594  PIN_PUPDR_PULLDOWN(PH07) | \
1595  PIN_PUPDR_PULLDOWN(PH08) | \
1596  PIN_PUPDR_PULLDOWN(PH09) | \
1597  PIN_PUPDR_PULLDOWN(PH10) | \
1598  PIN_PUPDR_PULLDOWN(PH11) | \
1599  PIN_PUPDR_PULLDOWN(PH12) | \
1600  PIN_PUPDR_PULLDOWN(PH13) | \
1601  PIN_PUPDR_PULLDOWN(PH14) | \
1602  PIN_PUPDR_PULLDOWN(PH15))
1603 
1604 #define VAL_GPIOH_ODR (PIN_ODR_LEVEL_HIGH(OSC_IN) | \
1605  PIN_ODR_LEVEL_HIGH(OSC_OUT) | \
1606  PIN_ODR_LEVEL_LOW(PH02) | \
1607  PIN_ODR_LEVEL_LOW(PH03) | \
1608  PIN_ODR_LEVEL_LOW(PH04) | \
1609  PIN_ODR_LEVEL_LOW(PH05) | \
1610  PIN_ODR_LEVEL_LOW(PH06) | \
1611  PIN_ODR_LEVEL_LOW(PH07) | \
1612  PIN_ODR_LEVEL_LOW(PH08) | \
1613  PIN_ODR_LEVEL_LOW(PH09) | \
1614  PIN_ODR_LEVEL_LOW(PH10) | \
1615  PIN_ODR_LEVEL_LOW(PH11) | \
1616  PIN_ODR_LEVEL_LOW(PH12) | \
1617  PIN_ODR_LEVEL_LOW(PH13) | \
1618  PIN_ODR_LEVEL_LOW(PH14) | \
1619  PIN_ODR_LEVEL_LOW(PH15))
1620 
1621 #define VAL_GPIOH_AFRL (PIN_AFIO_AF(OSC_IN, 0) | \
1622  PIN_AFIO_AF(OSC_OUT, 0) | \
1623  PIN_AFIO_AF(PH02, 0) | \
1624  PIN_AFIO_AF(PH03, 0) | \
1625  PIN_AFIO_AF(PH04, 0) | \
1626  PIN_AFIO_AF(PH05, 0) | \
1627  PIN_AFIO_AF(PH06, 0) | \
1628  PIN_AFIO_AF(PH07, 0))
1629 
1630 #define VAL_GPIOH_AFRH (PIN_AFIO_AF(PH08, 0) | \
1631  PIN_AFIO_AF(PH09, 0) | \
1632  PIN_AFIO_AF(PH10, 0) | \
1633  PIN_AFIO_AF(PH11, 0) | \
1634  PIN_AFIO_AF(PH12, 0) | \
1635  PIN_AFIO_AF(PH13, 0) | \
1636  PIN_AFIO_AF(PH14, 0) | \
1637  PIN_AFIO_AF(PH15, 0))
1638 
1639 #define VAL_GPIOI_MODER (PIN_MODE_INPUT(PI00) | \
1640  PIN_MODE_INPUT(PI01) | \
1641  PIN_MODE_INPUT(PI02) | \
1642  PIN_MODE_INPUT(PI03) | \
1643  PIN_MODE_INPUT(PI04) | \
1644  PIN_MODE_INPUT(PI05) | \
1645  PIN_MODE_INPUT(PI06) | \
1646  PIN_MODE_INPUT(PI07) | \
1647  PIN_MODE_INPUT(PI08) | \
1648  PIN_MODE_INPUT(PI09) | \
1649  PIN_MODE_INPUT(PI10) | \
1650  PIN_MODE_INPUT(PI11) | \
1651  PIN_MODE_INPUT(PI12) | \
1652  PIN_MODE_INPUT(PI13) | \
1653  PIN_MODE_INPUT(PI14) | \
1654  PIN_MODE_INPUT(PI15))
1655 
1656 #define VAL_GPIOI_OTYPER (PIN_OTYPE_PUSHPULL(PI00) | \
1657  PIN_OTYPE_PUSHPULL(PI01) | \
1658  PIN_OTYPE_PUSHPULL(PI02) | \
1659  PIN_OTYPE_PUSHPULL(PI03) | \
1660  PIN_OTYPE_PUSHPULL(PI04) | \
1661  PIN_OTYPE_PUSHPULL(PI05) | \
1662  PIN_OTYPE_PUSHPULL(PI06) | \
1663  PIN_OTYPE_PUSHPULL(PI07) | \
1664  PIN_OTYPE_PUSHPULL(PI08) | \
1665  PIN_OTYPE_PUSHPULL(PI09) | \
1666  PIN_OTYPE_PUSHPULL(PI10) | \
1667  PIN_OTYPE_PUSHPULL(PI11) | \
1668  PIN_OTYPE_PUSHPULL(PI12) | \
1669  PIN_OTYPE_PUSHPULL(PI13) | \
1670  PIN_OTYPE_PUSHPULL(PI14) | \
1671  PIN_OTYPE_PUSHPULL(PI15))
1672 
1673 #define VAL_GPIOI_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PI00) | \
1674  PIN_OSPEED_SPEED_VERYLOW(PI01) | \
1675  PIN_OSPEED_SPEED_VERYLOW(PI02) | \
1676  PIN_OSPEED_SPEED_VERYLOW(PI03) | \
1677  PIN_OSPEED_SPEED_VERYLOW(PI04) | \
1678  PIN_OSPEED_SPEED_VERYLOW(PI05) | \
1679  PIN_OSPEED_SPEED_VERYLOW(PI06) | \
1680  PIN_OSPEED_SPEED_VERYLOW(PI07) | \
1681  PIN_OSPEED_SPEED_VERYLOW(PI08) | \
1682  PIN_OSPEED_SPEED_VERYLOW(PI09) | \
1683  PIN_OSPEED_SPEED_VERYLOW(PI10) | \
1684  PIN_OSPEED_SPEED_VERYLOW(PI11) | \
1685  PIN_OSPEED_SPEED_VERYLOW(PI12) | \
1686  PIN_OSPEED_SPEED_VERYLOW(PI13) | \
1687  PIN_OSPEED_SPEED_VERYLOW(PI14) | \
1688  PIN_OSPEED_SPEED_VERYLOW(PI15))
1689 
1690 #define VAL_GPIOI_PUPDR (PIN_PUPDR_PULLDOWN(PI00) | \
1691  PIN_PUPDR_PULLDOWN(PI01) | \
1692  PIN_PUPDR_PULLDOWN(PI02) | \
1693  PIN_PUPDR_PULLDOWN(PI03) | \
1694  PIN_PUPDR_PULLDOWN(PI04) | \
1695  PIN_PUPDR_PULLDOWN(PI05) | \
1696  PIN_PUPDR_PULLDOWN(PI06) | \
1697  PIN_PUPDR_PULLDOWN(PI07) | \
1698  PIN_PUPDR_PULLDOWN(PI08) | \
1699  PIN_PUPDR_PULLDOWN(PI09) | \
1700  PIN_PUPDR_PULLDOWN(PI10) | \
1701  PIN_PUPDR_PULLDOWN(PI11) | \
1702  PIN_PUPDR_PULLDOWN(PI12) | \
1703  PIN_PUPDR_PULLDOWN(PI13) | \
1704  PIN_PUPDR_PULLDOWN(PI14) | \
1705  PIN_PUPDR_PULLDOWN(PI15))
1706 
1707 #define VAL_GPIOI_ODR (PIN_ODR_LEVEL_LOW(PI00) | \
1708  PIN_ODR_LEVEL_LOW(PI01) | \
1709  PIN_ODR_LEVEL_LOW(PI02) | \
1710  PIN_ODR_LEVEL_LOW(PI03) | \
1711  PIN_ODR_LEVEL_LOW(PI04) | \
1712  PIN_ODR_LEVEL_LOW(PI05) | \
1713  PIN_ODR_LEVEL_LOW(PI06) | \
1714  PIN_ODR_LEVEL_LOW(PI07) | \
1715  PIN_ODR_LEVEL_LOW(PI08) | \
1716  PIN_ODR_LEVEL_LOW(PI09) | \
1717  PIN_ODR_LEVEL_LOW(PI10) | \
1718  PIN_ODR_LEVEL_LOW(PI11) | \
1719  PIN_ODR_LEVEL_LOW(PI12) | \
1720  PIN_ODR_LEVEL_LOW(PI13) | \
1721  PIN_ODR_LEVEL_LOW(PI14) | \
1722  PIN_ODR_LEVEL_LOW(PI15))
1723 
1724 #define VAL_GPIOI_AFRL (PIN_AFIO_AF(PI00, 0) | \
1725  PIN_AFIO_AF(PI01, 0) | \
1726  PIN_AFIO_AF(PI02, 0) | \
1727  PIN_AFIO_AF(PI03, 0) | \
1728  PIN_AFIO_AF(PI04, 0) | \
1729  PIN_AFIO_AF(PI05, 0) | \
1730  PIN_AFIO_AF(PI06, 0) | \
1731  PIN_AFIO_AF(PI07, 0))
1732 
1733 #define VAL_GPIOI_AFRH (PIN_AFIO_AF(PI08, 0) | \
1734  PIN_AFIO_AF(PI09, 0) | \
1735  PIN_AFIO_AF(PI10, 0) | \
1736  PIN_AFIO_AF(PI11, 0) | \
1737  PIN_AFIO_AF(PI12, 0) | \
1738  PIN_AFIO_AF(PI13, 0) | \
1739  PIN_AFIO_AF(PI14, 0) | \
1740  PIN_AFIO_AF(PI15, 0))
1741 
1742 #define VAL_GPIOJ_MODER (PIN_MODE_INPUT(PJ00) | \
1743  PIN_MODE_INPUT(PJ01) | \
1744  PIN_MODE_INPUT(PJ02) | \
1745  PIN_MODE_INPUT(PJ03) | \
1746  PIN_MODE_INPUT(PJ04) | \
1747  PIN_MODE_INPUT(PJ05) | \
1748  PIN_MODE_INPUT(PJ06) | \
1749  PIN_MODE_INPUT(PJ07) | \
1750  PIN_MODE_INPUT(PJ08) | \
1751  PIN_MODE_INPUT(PJ09) | \
1752  PIN_MODE_INPUT(PJ10) | \
1753  PIN_MODE_INPUT(PJ11) | \
1754  PIN_MODE_INPUT(PJ12) | \
1755  PIN_MODE_INPUT(PJ13) | \
1756  PIN_MODE_INPUT(PJ14) | \
1757  PIN_MODE_INPUT(PJ15))
1758 
1759 #define VAL_GPIOJ_OTYPER (PIN_OTYPE_PUSHPULL(PJ00) | \
1760  PIN_OTYPE_PUSHPULL(PJ01) | \
1761  PIN_OTYPE_PUSHPULL(PJ02) | \
1762  PIN_OTYPE_PUSHPULL(PJ03) | \
1763  PIN_OTYPE_PUSHPULL(PJ04) | \
1764  PIN_OTYPE_PUSHPULL(PJ05) | \
1765  PIN_OTYPE_PUSHPULL(PJ06) | \
1766  PIN_OTYPE_PUSHPULL(PJ07) | \
1767  PIN_OTYPE_PUSHPULL(PJ08) | \
1768  PIN_OTYPE_PUSHPULL(PJ09) | \
1769  PIN_OTYPE_PUSHPULL(PJ10) | \
1770  PIN_OTYPE_PUSHPULL(PJ11) | \
1771  PIN_OTYPE_PUSHPULL(PJ12) | \
1772  PIN_OTYPE_PUSHPULL(PJ13) | \
1773  PIN_OTYPE_PUSHPULL(PJ14) | \
1774  PIN_OTYPE_PUSHPULL(PJ15))
1775 
1776 #define VAL_GPIOJ_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PJ00) | \
1777  PIN_OSPEED_SPEED_VERYLOW(PJ01) | \
1778  PIN_OSPEED_SPEED_VERYLOW(PJ02) | \
1779  PIN_OSPEED_SPEED_VERYLOW(PJ03) | \
1780  PIN_OSPEED_SPEED_VERYLOW(PJ04) | \
1781  PIN_OSPEED_SPEED_VERYLOW(PJ05) | \
1782  PIN_OSPEED_SPEED_VERYLOW(PJ06) | \
1783  PIN_OSPEED_SPEED_VERYLOW(PJ07) | \
1784  PIN_OSPEED_SPEED_VERYLOW(PJ08) | \
1785  PIN_OSPEED_SPEED_VERYLOW(PJ09) | \
1786  PIN_OSPEED_SPEED_VERYLOW(PJ10) | \
1787  PIN_OSPEED_SPEED_VERYLOW(PJ11) | \
1788  PIN_OSPEED_SPEED_VERYLOW(PJ12) | \
1789  PIN_OSPEED_SPEED_VERYLOW(PJ13) | \
1790  PIN_OSPEED_SPEED_VERYLOW(PJ14) | \
1791  PIN_OSPEED_SPEED_VERYLOW(PJ15))
1792 
1793 #define VAL_GPIOJ_PUPDR (PIN_PUPDR_PULLDOWN(PJ00) | \
1794  PIN_PUPDR_PULLDOWN(PJ01) | \
1795  PIN_PUPDR_PULLDOWN(PJ02) | \
1796  PIN_PUPDR_PULLDOWN(PJ03) | \
1797  PIN_PUPDR_PULLDOWN(PJ04) | \
1798  PIN_PUPDR_PULLDOWN(PJ05) | \
1799  PIN_PUPDR_PULLDOWN(PJ06) | \
1800  PIN_PUPDR_PULLDOWN(PJ07) | \
1801  PIN_PUPDR_PULLDOWN(PJ08) | \
1802  PIN_PUPDR_PULLDOWN(PJ09) | \
1803  PIN_PUPDR_PULLDOWN(PJ10) | \
1804  PIN_PUPDR_PULLDOWN(PJ11) | \
1805  PIN_PUPDR_PULLDOWN(PJ12) | \
1806  PIN_PUPDR_PULLDOWN(PJ13) | \
1807  PIN_PUPDR_PULLDOWN(PJ14) | \
1808  PIN_PUPDR_PULLDOWN(PJ15))
1809 
1810 #define VAL_GPIOJ_ODR (PIN_ODR_LEVEL_LOW(PJ00) | \
1811  PIN_ODR_LEVEL_LOW(PJ01) | \
1812  PIN_ODR_LEVEL_LOW(PJ02) | \
1813  PIN_ODR_LEVEL_LOW(PJ03) | \
1814  PIN_ODR_LEVEL_LOW(PJ04) | \
1815  PIN_ODR_LEVEL_LOW(PJ05) | \
1816  PIN_ODR_LEVEL_LOW(PJ06) | \
1817  PIN_ODR_LEVEL_LOW(PJ07) | \
1818  PIN_ODR_LEVEL_LOW(PJ08) | \
1819  PIN_ODR_LEVEL_LOW(PJ09) | \
1820  PIN_ODR_LEVEL_LOW(PJ10) | \
1821  PIN_ODR_LEVEL_LOW(PJ11) | \
1822  PIN_ODR_LEVEL_LOW(PJ12) | \
1823  PIN_ODR_LEVEL_LOW(PJ13) | \
1824  PIN_ODR_LEVEL_LOW(PJ14) | \
1825  PIN_ODR_LEVEL_LOW(PJ15))
1826 
1827 #define VAL_GPIOJ_AFRL (PIN_AFIO_AF(PJ00, 0) | \
1828  PIN_AFIO_AF(PJ01, 0) | \
1829  PIN_AFIO_AF(PJ02, 0) | \
1830  PIN_AFIO_AF(PJ03, 0) | \
1831  PIN_AFIO_AF(PJ04, 0) | \
1832  PIN_AFIO_AF(PJ05, 0) | \
1833  PIN_AFIO_AF(PJ06, 0) | \
1834  PIN_AFIO_AF(PJ07, 0))
1835 
1836 #define VAL_GPIOJ_AFRH (PIN_AFIO_AF(PJ08, 0) | \
1837  PIN_AFIO_AF(PJ09, 0) | \
1838  PIN_AFIO_AF(PJ10, 0) | \
1839  PIN_AFIO_AF(PJ11, 0) | \
1840  PIN_AFIO_AF(PJ12, 0) | \
1841  PIN_AFIO_AF(PJ13, 0) | \
1842  PIN_AFIO_AF(PJ14, 0) | \
1843  PIN_AFIO_AF(PJ15, 0))
1844 
1845 #define VAL_GPIOK_MODER (PIN_MODE_INPUT(PK00) | \
1846  PIN_MODE_INPUT(PK01) | \
1847  PIN_MODE_INPUT(PK02) | \
1848  PIN_MODE_INPUT(PK03) | \
1849  PIN_MODE_INPUT(PK04) | \
1850  PIN_MODE_INPUT(PK05) | \
1851  PIN_MODE_INPUT(PK06) | \
1852  PIN_MODE_INPUT(PK07) | \
1853  PIN_MODE_INPUT(PK08) | \
1854  PIN_MODE_INPUT(PK09) | \
1855  PIN_MODE_INPUT(PK10) | \
1856  PIN_MODE_INPUT(PK11) | \
1857  PIN_MODE_INPUT(PK12) | \
1858  PIN_MODE_INPUT(PK13) | \
1859  PIN_MODE_INPUT(PK14) | \
1860  PIN_MODE_INPUT(PK15))
1861 
1862 #define VAL_GPIOK_OTYPER (PIN_OTYPE_PUSHPULL(PK00) | \
1863  PIN_OTYPE_PUSHPULL(PK01) | \
1864  PIN_OTYPE_PUSHPULL(PK02) | \
1865  PIN_OTYPE_PUSHPULL(PK03) | \
1866  PIN_OTYPE_PUSHPULL(PK04) | \
1867  PIN_OTYPE_PUSHPULL(PK05) | \
1868  PIN_OTYPE_PUSHPULL(PK06) | \
1869  PIN_OTYPE_PUSHPULL(PK07) | \
1870  PIN_OTYPE_PUSHPULL(PK08) | \
1871  PIN_OTYPE_PUSHPULL(PK09) | \
1872  PIN_OTYPE_PUSHPULL(PK10) | \
1873  PIN_OTYPE_PUSHPULL(PK11) | \
1874  PIN_OTYPE_PUSHPULL(PK12) | \
1875  PIN_OTYPE_PUSHPULL(PK13) | \
1876  PIN_OTYPE_PUSHPULL(PK14) | \
1877  PIN_OTYPE_PUSHPULL(PK15))
1878 
1879 #define VAL_GPIOK_OSPEEDR (PIN_OSPEED_SPEED_VERYLOW(PK00) | \
1880  PIN_OSPEED_SPEED_VERYLOW(PK01) | \
1881  PIN_OSPEED_SPEED_VERYLOW(PK02) | \
1882  PIN_OSPEED_SPEED_VERYLOW(PK03) | \
1883  PIN_OSPEED_SPEED_VERYLOW(PK04) | \
1884  PIN_OSPEED_SPEED_VERYLOW(PK05) | \
1885  PIN_OSPEED_SPEED_VERYLOW(PK06) | \
1886  PIN_OSPEED_SPEED_VERYLOW(PK07) | \
1887  PIN_OSPEED_SPEED_VERYLOW(PK08) | \
1888  PIN_OSPEED_SPEED_VERYLOW(PK09) | \
1889  PIN_OSPEED_SPEED_VERYLOW(PK10) | \
1890  PIN_OSPEED_SPEED_VERYLOW(PK11) | \
1891  PIN_OSPEED_SPEED_VERYLOW(PK12) | \
1892  PIN_OSPEED_SPEED_VERYLOW(PK13) | \
1893  PIN_OSPEED_SPEED_VERYLOW(PK14) | \
1894  PIN_OSPEED_SPEED_VERYLOW(PK15))
1895 
1896 #define VAL_GPIOK_PUPDR (PIN_PUPDR_PULLDOWN(PK00) | \
1897  PIN_PUPDR_PULLDOWN(PK01) | \
1898  PIN_PUPDR_PULLDOWN(PK02) | \
1899  PIN_PUPDR_PULLDOWN(PK03) | \
1900  PIN_PUPDR_PULLDOWN(PK04) | \
1901  PIN_PUPDR_PULLDOWN(PK05) | \
1902  PIN_PUPDR_PULLDOWN(PK06) | \
1903  PIN_PUPDR_PULLDOWN(PK07) | \
1904  PIN_PUPDR_PULLDOWN(PK08) | \
1905  PIN_PUPDR_PULLDOWN(PK09) | \
1906  PIN_PUPDR_PULLDOWN(PK10) | \
1907  PIN_PUPDR_PULLDOWN(PK11) | \
1908  PIN_PUPDR_PULLDOWN(PK12) | \
1909  PIN_PUPDR_PULLDOWN(PK13) | \
1910  PIN_PUPDR_PULLDOWN(PK14) | \
1911  PIN_PUPDR_PULLDOWN(PK15))
1912 
1913 #define VAL_GPIOK_ODR (PIN_ODR_LEVEL_LOW(PK00) | \
1914  PIN_ODR_LEVEL_LOW(PK01) | \
1915  PIN_ODR_LEVEL_LOW(PK02) | \
1916  PIN_ODR_LEVEL_LOW(PK03) | \
1917  PIN_ODR_LEVEL_LOW(PK04) | \
1918  PIN_ODR_LEVEL_LOW(PK05) | \
1919  PIN_ODR_LEVEL_LOW(PK06) | \
1920  PIN_ODR_LEVEL_LOW(PK07) | \
1921  PIN_ODR_LEVEL_LOW(PK08) | \
1922  PIN_ODR_LEVEL_LOW(PK09) | \
1923  PIN_ODR_LEVEL_LOW(PK10) | \
1924  PIN_ODR_LEVEL_LOW(PK11) | \
1925  PIN_ODR_LEVEL_LOW(PK12) | \
1926  PIN_ODR_LEVEL_LOW(PK13) | \
1927  PIN_ODR_LEVEL_LOW(PK14) | \
1928  PIN_ODR_LEVEL_LOW(PK15))
1929 
1930 #define VAL_GPIOK_AFRL (PIN_AFIO_AF(PK00, 0) | \
1931  PIN_AFIO_AF(PK01, 0) | \
1932  PIN_AFIO_AF(PK02, 0) | \
1933  PIN_AFIO_AF(PK03, 0) | \
1934  PIN_AFIO_AF(PK04, 0) | \
1935  PIN_AFIO_AF(PK05, 0) | \
1936  PIN_AFIO_AF(PK06, 0) | \
1937  PIN_AFIO_AF(PK07, 0))
1938 
1939 #define VAL_GPIOK_AFRH (PIN_AFIO_AF(PK08, 0) | \
1940  PIN_AFIO_AF(PK09, 0) | \
1941  PIN_AFIO_AF(PK10, 0) | \
1942  PIN_AFIO_AF(PK11, 0) | \
1943  PIN_AFIO_AF(PK12, 0) | \
1944  PIN_AFIO_AF(PK13, 0) | \
1945  PIN_AFIO_AF(PK14, 0) | \
1946  PIN_AFIO_AF(PK15, 0))
1947 
1948 #define AF_UART4_TX 8U
1949 #define AF_LINE_UART4_TX 8U
1950 #define AF_UART4_RX 8U
1951 #define AF_LINE_UART4_RX 8U
1952 #define AF_SERVO1 1U
1953 #define AF_LINE_SERVO1 1U
1954 #define AF_UART2_RX 7U
1955 #define AF_LINE_UART2_RX 7U
1956 #define AF_SPI1_SCK 5U
1957 #define AF_LINE_SPI1_SCK 5U
1958 #define AF_SPI1_MISO 5U
1959 #define AF_LINE_SPI1_MISO 5U
1960 #define AF_SPI1_MOSI 5U
1961 #define AF_LINE_SPI1_MOSI 5U
1962 #define AF_CU1_CH1 1U
1963 #define AF_LINE_CU1_CH1 1U
1964 #define AF_USART1_RX 7U
1965 #define AF_LINE_USART1_RX 7U
1966 #define AF_OTG_FS_DM 10U
1967 #define AF_LINE_OTG_FS_DM 10U
1968 #define AF_OTG_FS_DP 10U
1969 #define AF_LINE_OTG_FS_DP 10U
1970 #define AF_SWDIO 0U
1971 #define AF_LINE_SWDIO 0U
1972 #define AF_SWCLK 0U
1973 #define AF_LINE_SWCLK 0U
1974 #define AF_SERVO5 1U
1975 #define AF_LINE_SERVO5 1U
1976 #define AF_SERVO0 2U
1977 #define AF_LINE_SERVO0 2U
1978 #define AF_SERVO6 2U
1979 #define AF_LINE_SERVO6 2U
1980 #define AF_SERVO4 1U
1981 #define AF_LINE_SERVO4 1U
1982 #define AF_SERVO3 2U
1983 #define AF_LINE_SERVO3 2U
1984 #define AF_SERVO2 2U
1985 #define AF_LINE_SERVO2 2U
1986 #define AF_USART1_TX 7U
1987 #define AF_LINE_USART1_TX 7U
1988 #define AF_I2C1_SDA 4U
1989 #define AF_LINE_I2C1_SDA 4U
1990 #define AF_I2C1_SCL 4U
1991 #define AF_LINE_I2C1_SCL 4U
1992 #define AF_I2C2_SCL 4U
1993 #define AF_LINE_I2C2_SCL 4U
1994 #define AF_I2C2_SDA 4U
1995 #define AF_LINE_I2C2_SDA 4U
1996 #define AF_USART6_TX 8U
1997 #define AF_LINE_USART6_TX 8U
1998 #define AF_USART6_RX 8U
1999 #define AF_LINE_USART6_RX 8U
2000 #define AF_SDIO_D0 12U
2001 #define AF_LINE_SDIO_D0 12U
2002 #define AF_SDIO_D1 12U
2003 #define AF_LINE_SDIO_D1 12U
2004 #define AF_SDIO_D2 12U
2005 #define AF_LINE_SDIO_D2 12U
2006 #define AF_SDIO_D3 12U
2007 #define AF_LINE_SDIO_D3 12U
2008 #define AF_SDIO_CK 12U
2009 #define AF_LINE_SDIO_CK 12U
2010 #define AF_OSC32_IN 0U
2011 #define AF_LINE_OSC32_IN 0U
2012 #define AF_OSC32_OUT 0U
2013 #define AF_LINE_OSC32_OUT 0U
2014 #define AF_SDIO_CMD 12U
2015 #define AF_LINE_SDIO_CMD 12U
2016 #define AF_OSC_IN 0U
2017 #define AF_LINE_OSC_IN 0U
2018 #define AF_OSC_OUT 0U
2019 #define AF_LINE_OSC_OUT 0U
2020 
2021 
2022 #define SERVO1_TIM 2
2023 #define SERVO1_TIM_FN CH
2024 #define SERVO1_TIM_CH 3
2025 #define SERVO1_TIM_AF 1
2026 #define SERVO5_TIM 2
2027 #define SERVO5_TIM_FN CH
2028 #define SERVO5_TIM_CH 1
2029 #define SERVO5_TIM_AF 1
2030 #define SERVO0_TIM 3
2031 #define SERVO0_TIM_FN CH
2032 #define SERVO0_TIM_CH 3
2033 #define SERVO0_TIM_AF 2
2034 #define SERVO6_TIM 3
2035 #define SERVO6_TIM_FN CH
2036 #define SERVO6_TIM_CH 4
2037 #define SERVO6_TIM_AF 2
2038 #define SERVO4_TIM 2
2039 #define SERVO4_TIM_FN CH
2040 #define SERVO4_TIM_CH 2
2041 #define SERVO4_TIM_AF 1
2042 #define SERVO3_TIM 3
2043 #define SERVO3_TIM_FN CH
2044 #define SERVO3_TIM_CH 1
2045 #define SERVO3_TIM_AF 2
2046 #define SERVO2_TIM 3
2047 #define SERVO2_TIM_FN CH
2048 #define SERVO2_TIM_CH 2
2049 #define SERVO2_TIM_AF 2
2050 
2051 #define BOARD_GROUP_DECLFOREACH(line, group) \
2052  static const ioline_t group ## _ARRAY[] = {group}; \
2053  for (ioline_t i=0, line = group ## _ARRAY[i]; (i < group ## _SIZE) && (line = group ## _ARRAY[i]); i++)
2054 
2055 #define BOARD_GROUP_FOREACH(line, group) \
2056  for (ioline_t i=0, line = group ## _ARRAY[i]; (i < group ## _SIZE) && (line = group ## _ARRAY[i]); i++)
2057 
2058 
2059 #define BOARD_GROUP_DECLFOR(array, index, group) \
2060  static const ioline_t group ## _ARRAY[] = {group}; \
2061  for (ioline_t index=0, *array = (ioline_t *) group ## _ARRAY; index < group ## _SIZE; index++)
2062 
2063 #define BOARD_GROUP_FOR(array, index, group) \
2064  for (ioline_t index=0, *array = (ioline_t *) group ## _ARRAY; index < group ## _SIZE; index++)
2065 
2066 #define ENERGY_SAVE_INPUT \
2067  LINE_SERVO1, \
2068  LINE_SERVO5, \
2069  LINE_SERVO0, \
2070  LINE_SERVO6, \
2071  LINE_SERVO4, \
2072  LINE_SERVO3, \
2073  LINE_SERVO2, \
2074  LINE_SPI1_CS, \
2075  LINE_AUX4, \
2076  LINE_LED1, \
2077  LINE_LED3, \
2078  LINE_LED4, \
2079  LINE_AUX3, \
2080  LINE_AUX2, \
2081  LINE_LED2
2082 #define ENERGY_SAVE_INPUT_SIZE 15
2083 
2084 #if !defined(_FROM_ASM_)
2085 #ifdef __cplusplus
2086 extern "C" {
2087 #endif
2088  void boardInit(void);
2089 #ifdef __cplusplus
2090 }
2091 #endif
2092 #endif /* _FROM_ASM_ */
2093 
boardInit
void boardInit(void)
Board-specific initialization code.
Definition: board.c:312