Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / board.h @ a3ac2400

History | View | Annotate | Download (108.36 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3 84f0ce9e Thomas Schöpping
Copyright (C) 2016..2019  Thomas Schöpping et al.
4 e545e620 Thomas Schöpping

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19 53710ca3 Marc Rothmann
/**
20 37bacabf Thomas Schöpping
 * @file
21 53710ca3 Marc Rothmann
 * @brief   PowerManagement v1.1 Board specific macros.
22
 *
23
 * @addtogroup powermanagement_board
24
 * @{
25
 */
26
27 6ff06bbf Thomas Schöpping
#ifndef BOARD_H
28
#define BOARD_H
29 e545e620 Thomas Schöpping
30
/*
31 043cdf33 Thomas Schöpping
 * Setup for AMiRo PowerManagement v1.1 board.
32 e545e620 Thomas Schöpping
 */
33
34
/*
35
 * Board identifier.
36
 */
37 3cb82b1a Thomas Schöpping
#define BOARD_POWERMANAGEMENT_1_1
38
#define BOARD_NAME                      "AMiRo PowerManagement v1.1"
39 e545e620 Thomas Schöpping
40
/*
41
 * Board oscillators-related settings.
42
 * NOTE: LSE not fitted.
43
 */
44
#if !defined(STM32_LSECLK)
45
#define STM32_LSECLK                    0U
46
#endif
47
48
#if !defined(STM32_HSECLK)
49
#define STM32_HSECLK                    8000000U
50
#endif
51
52
/*
53
 * Board voltages.
54
 * Required for performance limits calculation.
55
 */
56
#define STM32_VDD                       330U
57
58
/*
59
 * MCU type as defined in the ST header.
60
 */
61
#define STM32F405xx
62
63
/*
64
 * STM32F4 alternate function definitions
65
 */
66
#define STM32F4xx_AF_system             0U
67
#define STM32F4xx_AF_TIM1to2            1U
68
#define STM32F4xx_AF_TIM3to5            2U
69
#define STM32F4xx_AF_TIM8to11           3U
70
#define STM32F4xx_AF_I2C1to3            4U
71
#define STM32F4xx_AF_SPI1to2            5U
72
#define STM32F4xx_AF_SPI3               6U
73
#define STM32F4xx_AF_USART1to3          7U
74
#define STM32F4xx_AF_USART4to6          8U
75
#define STM32F4xx_AF_CAN1to2_TIM12to14  9U
76
#define STM32F4xx_AF_OTG_HSFS           10U
77
#define STM32F4xx_AF_ETH                11U
78
#define STM32F4xx_AF_FSMC_SDIO_OTGHS    12U
79
#define STM32F4xx_AF_DCMI               13U
80
#define STM32F4xx_AF_EVENTOUT           15U
81
82
/*
83 8be006e0 Thomas Schöpping
 * Identifiers for the several sensor rings, which can be attached to the PowerManagement v1.1 module.
84
 */
85
#define BOARD_NOSENSORRING              0
86
#define BOARD_PROXIMITYSENSOR           1
87
#define BOARD_DISTANCESENSOR_VL53L0X    2
88
#define BOARD_DISTANCESENSOR_VL53L1X    3
89
90
/*
91
 * Configuration macro to define which type of sensor ring is attached.
92
 */
93 4c72a54c Thomas Schöpping
#if !defined(BOARD_SENSORRING) || defined(__DOXYGEN__)
94 ddf34c3d Thomas Schöpping
#define BOARD_SENSORRING                BOARD_PROXIMITYSENSOR
95 4c72a54c Thomas Schöpping
#endif
96 8be006e0 Thomas Schöpping
97
/*
98 e545e620 Thomas Schöpping
 * IO pins assignments.
99
 */
100
#define GPIOA_WKUP                      0U
101
#define GPIOA_PIN1                      1U
102
#define GPIOA_SYS_UART_TX               2U
103
#define GPIOA_SYS_UART_RX               3U
104
#define GPIOA_SYS_SPI_SS0_N             4U
105
#define GPIOA_SYS_SPI_SCLK              5U
106
#define GPIOA_SYS_SPI_MISO              6U
107
#define GPIOA_SYS_SPI_MOSI              7U
108
#define GPIOA_SYS_REG_EN                8U
109
#define GPIOA_PROG_RX                   9U
110
#define GPIOA_PROG_TX                   10U
111
#define GPIOA_CAN_RX                    11U
112
#define GPIOA_CAN_TX                    12U
113
#define GPIOA_SWDIO                     13U
114
#define GPIOA_SWCLK                     14U
115
#define GPIOA_SYS_SPI_SS1_N             15U
116
117
#define GPIOB_IR_INT1_N                 0U
118
#define GPIOB_VSYS_SENSE                1U
119
#define GPIOB_POWER_EN                  2U
120
#define GPIOB_SYS_UART_DN               3U
121
#define GPIOB_CHARGE_STAT2A             4U
122
#define GPIOB_BUZZER                    5U
123
#define GPIOB_GAUGE_BATLOW2             6U
124
#define GPIOB_GAUGE_BATGD2_N            7U
125
#define GPIOB_GAUGE_SCL2                8U
126
#define GPIOB_GAUGE_SDA2                9U
127
#define GPIOB_GAUGE_SCL1                10U
128
#define GPIOB_GAUGE_SDA1                11U
129
#define GPIOB_LED                       12U
130
#define GPIOB_BT_RTS                    13U
131
#define GPIOB_BT_CTS                    14U
132
#define GPIOB_SYS_UART_UP               15U
133
134
#define GPIOC_CHARGE_STAT1A             0U
135
#define GPIOC_GAUGE_BATLOW1             1U
136
#define GPIOC_GAUGE_BATGD1_N            2U
137
#define GPIOC_CHARGE_EN1_N              3U
138
#define GPIOC_IR_INT2_N                 4U
139
#define GPIOC_TOUCH_INT_N               5U
140
#define GPIOC_SYS_DONE                  6U
141
#define GPIOC_SYS_PROG_N                7U
142
#define GPIOC_PATH_DC                   8U
143
#define GPIOC_SYS_SPI_DIR               9U
144
#define GPIOC_BT_RX                     10U
145
#define GPIOC_BT_TX                     11U
146
#define GPIOC_SYS_INT_N                 12U
147
#define GPIOC_SYS_PD_N                  13U
148
#define GPIOC_SYS_WARMRST_N             14U
149
#define GPIOC_BT_RST                    15U
150
151
#define GPIOD_PIN0                      0U
152
#define GPIOD_PIN1                      1U
153
#define GPIOD_CHARGE_EN2_N              2U
154
#define GPIOD_PIN3                      3U
155
#define GPIOD_PIN4                      4U
156
#define GPIOD_PIN5                      5U
157
#define GPIOD_PIN6                      6U
158
#define GPIOD_PIN7                      7U
159
#define GPIOD_PIN8                      8U
160
#define GPIOD_PIN9                      9U
161
#define GPIOD_PIN10                     10U
162
#define GPIOD_PIN11                     11U
163
#define GPIOD_PIN12                     12U
164
#define GPIOD_PIN13                     13U
165
#define GPIOD_PIN14                     14U
166
#define GPIOD_PIN15                     15U
167
168
#define GPIOE_PIN0                      0U
169
#define GPIOE_PIN1                      1U
170
#define GPIOE_PIN2                      2U
171
#define GPIOE_PIN3                      3U
172
#define GPIOE_PIN4                      4U
173
#define GPIOE_PIN5                      5U
174
#define GPIOE_PIN6                      6U
175
#define GPIOE_PIN7                      7U
176
#define GPIOE_PIN8                      8U
177
#define GPIOE_PIN9                      9U
178
#define GPIOE_PIN10                     10U
179
#define GPIOE_PIN11                     11U
180
#define GPIOE_PIN12                     12U
181
#define GPIOE_PIN13                     13U
182
#define GPIOE_PIN14                     14U
183
#define GPIOE_PIN15                     15U
184
185
#define GPIOF_PIN0                      0U
186
#define GPIOF_PIN1                      1U
187
#define GPIOF_PIN2                      2U
188
#define GPIOF_PIN3                      3U
189
#define GPIOF_PIN4                      4U
190
#define GPIOF_PIN5                      5U
191
#define GPIOF_PIN6                      6U
192
#define GPIOF_PIN7                      7U
193
#define GPIOF_PIN8                      8U
194
#define GPIOF_PIN9                      9U
195
#define GPIOF_PIN10                     10U
196
#define GPIOF_PIN11                     11U
197
#define GPIOF_PIN12                     12U
198
#define GPIOF_PIN13                     13U
199
#define GPIOF_PIN14                     14U
200
#define GPIOF_PIN15                     15U
201
202
#define GPIOG_PIN0                      0U
203
#define GPIOG_PIN1                      1U
204
#define GPIOG_PIN2                      2U
205
#define GPIOG_PIN3                      3U
206
#define GPIOG_PIN4                      4U
207
#define GPIOG_PIN5                      5U
208
#define GPIOG_PIN6                      6U
209
#define GPIOG_PIN7                      7U
210
#define GPIOG_PIN8                      8U
211
#define GPIOG_PIN9                      9U
212
#define GPIOG_PIN10                     10U
213
#define GPIOG_PIN11                     11U
214
#define GPIOG_PIN12                     12U
215
#define GPIOG_PIN13                     13U
216
#define GPIOG_PIN14                     14U
217
#define GPIOG_PIN15                     15U
218
219
#define GPIOH_OSC_IN                    0U
220
#define GPIOH_OSC_OUT                   1U
221
#define GPIOH_PIN2                      2U
222
#define GPIOH_PIN3                      3U
223
#define GPIOH_PIN4                      4U
224
#define GPIOH_PIN5                      5U
225
#define GPIOH_PIN6                      6U
226
#define GPIOH_PIN7                      7U
227
#define GPIOH_PIN8                      8U
228
#define GPIOH_PIN9                      9U
229
#define GPIOH_PIN10                     10U
230
#define GPIOH_PIN11                     11U
231
#define GPIOH_PIN12                     12U
232
#define GPIOH_PIN13                     13U
233
#define GPIOH_PIN14                     14U
234
#define GPIOH_PIN15                     15U
235
236
#define GPIOI_PIN0                      0U
237
#define GPIOI_PIN1                      1U
238
#define GPIOI_PIN2                      2U
239
#define GPIOI_PIN3                      3U
240
#define GPIOI_PIN4                      4U
241
#define GPIOI_PIN5                      5U
242
#define GPIOI_PIN6                      6U
243
#define GPIOI_PIN7                      7U
244
#define GPIOI_PIN8                      8U
245
#define GPIOI_PIN9                      9U
246
#define GPIOI_PIN10                     10U
247
#define GPIOI_PIN11                     11U
248
#define GPIOI_PIN12                     12U
249
#define GPIOI_PIN13                     13U
250
#define GPIOI_PIN14                     14U
251
#define GPIOI_PIN15                     15U
252
253
/*
254
 * IO lines assignments.
255
 */
256
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
257
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
258
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
259
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
260
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
261
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
262
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
263
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
264
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
265
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
266
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
267
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
268
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
269
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
270
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
271
272
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
273
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
274
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
275
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
276
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
277
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
278
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
279
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
280
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
281
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
282
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
283
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
284
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
285
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
286
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
287
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
288
289
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
290
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
291
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
292
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
293
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
294
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
295
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
296
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
297
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
298
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
299
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
300
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
301
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
302
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
303
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
304
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
305
306
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
307
308
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
309
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
310
311
/*
312
 * I/O ports initial setup, this configuration is established soon after reset
313
 * in the initialization code.
314
 * Please refer to the STM32 Reference Manual for details.
315
 */
316
#define PIN_MODE_INPUT(n)               (0U << ((n) * 2U))
317
#define PIN_MODE_OUTPUT(n)              (1U << ((n) * 2U))
318
#define PIN_MODE_ALTERNATE(n)           (2U << ((n) * 2U))
319
#define PIN_MODE_ANALOG(n)              (3U << ((n) * 2U))
320
#define PIN_ODR_LOW(n)                  (0U << (n))
321
#define PIN_ODR_HIGH(n)                 (1U << (n))
322
#define PIN_OTYPE_PUSHPULL(n)           (0U << (n))
323
#define PIN_OTYPE_OPENDRAIN(n)          (1U << (n))
324
#define PIN_OSPEED_LOW(n)               (0U << ((n) * 2U))
325
#define PIN_OSPEED_MEDIUM(n)            (1U << ((n) * 2U))
326
#define PIN_OSPEED_HIGH(n)              (2U << ((n) * 2U))
327
#define PIN_OSPEED_VERYHIGH(n)          (3U << ((n) * 2U))
328
#define PIN_PUPDR_FLOATING(n)           (0U << ((n) * 2U))
329
#define PIN_PUPDR_PULLUP(n)             (1U << ((n) * 2U))
330
#define PIN_PUPDR_PULLDOWN(n)           (2U << ((n) * 2U))
331
#define PIN_AFIO_AF(n, v)               ((v) << (((n) % 8U) * 4U))
332
333
/*
334
 * GPIOA setup:
335
 *
336
 * PA0  - WKUP                          (input floating)
337
 * PA1  - PIN1                          (input pullup)
338
 * PA2  - SYS_UART_TX                   (input floating)
339
 * PA3  - SYS_UART_RX                   (alternate 7 pushpull floating)
340
 * PA4  - SYS_SPI_SS0_N                 (input floating)
341
 * PA5  - SYS_SPI_SCLK                  (alternate 5 pushpull floating)
342
 * PA6  - SYS_SPI_MISO                  (alternate 5 pushpull floating)
343
 * PA7  - SYS_SPI_MOSI                  (alternate 5 pushpull floating)
344
 * PA8  - SYS_REG_EN                    (output pushpull high)
345
 * PA9  - PROG_RX                       (alternate 7 pushpull floating)
346
 * PA10 - PROG_TX                       (alternate 7 pushpull pullup)
347
 * PA11 - CAN_RX                        (alternate 9 pushpull floating)
348 933df08e Thomas Schöpping
 * PA12 - CAN_TX                        (alternate 9 pushpull floating)
349 e545e620 Thomas Schöpping
 * PA13 - SWDIO                         (alternate 0 pushpull floating)
350
 * PA14 - SWCLK                         (alternate 0 pushpull floating)
351
 * PA15 - SYS_SPI_SS1_N                 (input floating)
352
 */
353
#define VAL_GPIOA_MODER                 (PIN_MODE_INPUT(GPIOA_WKUP) |                                 \
354
                                         PIN_MODE_INPUT(GPIOA_PIN1) |                                 \
355
                                         PIN_MODE_INPUT(GPIOA_SYS_UART_TX) |                          \
356
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_UART_RX) |                      \
357
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS0_N) |                        \
358
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_SCLK) |                     \
359
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MISO) |                     \
360
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MOSI) |                     \
361
                                         PIN_MODE_OUTPUT(GPIOA_SYS_REG_EN) |                          \
362
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_RX) |                          \
363
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_TX) |                          \
364
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_RX) |                           \
365 933df08e Thomas Schöpping
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_TX) |                           \
366 e545e620 Thomas Schöpping
                                         PIN_MODE_ALTERNATE(GPIOA_SWDIO) |                            \
367
                                         PIN_MODE_ALTERNATE(GPIOA_SWCLK) |                            \
368
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS1_N))
369
#define VAL_GPIOA_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOA_WKUP) |                             \
370
                                         PIN_OTYPE_PUSHPULL(GPIOA_PIN1) |                             \
371
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_TX) |                      \
372
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_RX) |                      \
373
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS0_N) |                    \
374
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SCLK) |                     \
375
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MISO) |                     \
376
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MOSI) |                     \
377
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_REG_EN) |                       \
378
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_RX) |                          \
379
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_TX) |                          \
380
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_RX) |                           \
381
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_TX) |                           \
382
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) |                            \
383
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) |                            \
384
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS1_N))
385
#define VAL_GPIOA_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOA_WKUP) |                            \
386
                                         PIN_OSPEED_VERYHIGH(GPIOA_PIN1) |                            \
387
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_TX) |                     \
388
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_RX) |                     \
389
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS0_N) |                   \
390
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SCLK) |                    \
391
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MISO) |                    \
392
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MOSI) |                    \
393
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_REG_EN) |                      \
394
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_RX) |                         \
395
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_TX) |                         \
396
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_RX) |                          \
397
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_TX) |                          \
398
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWDIO) |                           \
399
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWCLK) |                           \
400
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS1_N))
401
#define VAL_GPIOA_PUPDR                 (PIN_PUPDR_FLOATING(GPIOA_WKUP) |                             \
402
                                         PIN_PUPDR_PULLUP(GPIOA_PIN1) |                               \
403
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_TX) |                      \
404
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_RX) |                      \
405
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS0_N) |                    \
406
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SCLK) |                     \
407
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MISO) |                     \
408
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MOSI) |                     \
409
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_REG_EN) |                       \
410
                                         PIN_PUPDR_FLOATING(GPIOA_PROG_RX) |                          \
411
                                         PIN_PUPDR_PULLUP(GPIOA_PROG_TX) |                            \
412
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_RX) |                           \
413
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_TX) |                           \
414
                                         PIN_PUPDR_FLOATING(GPIOA_SWDIO) |                            \
415
                                         PIN_PUPDR_FLOATING(GPIOA_SWCLK) |                            \
416
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS1_N))
417
#define VAL_GPIOA_ODR                   (PIN_ODR_HIGH(GPIOA_WKUP) |                                   \
418
                                         PIN_ODR_HIGH(GPIOA_PIN1) |                                   \
419
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_TX) |                            \
420
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_RX) |                            \
421
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS0_N) |                          \
422
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SCLK) |                           \
423
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MISO) |                           \
424
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MOSI) |                           \
425
                                         PIN_ODR_HIGH(GPIOA_SYS_REG_EN) |                             \
426
                                         PIN_ODR_HIGH(GPIOA_PROG_RX) |                                \
427
                                         PIN_ODR_HIGH(GPIOA_PROG_TX) |                                \
428
                                         PIN_ODR_HIGH(GPIOA_CAN_RX) |                                 \
429
                                         PIN_ODR_HIGH(GPIOA_CAN_TX) |                                 \
430
                                         PIN_ODR_HIGH(GPIOA_SWDIO) |                                  \
431
                                         PIN_ODR_HIGH(GPIOA_SWCLK) |                                  \
432
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS1_N))
433
#define VAL_GPIOA_AFRL                  (PIN_AFIO_AF(GPIOA_WKUP, STM32F4xx_AF_system) |               \
434
                                         PIN_AFIO_AF(GPIOA_PIN1, STM32F4xx_AF_system) |               \
435
                                         PIN_AFIO_AF(GPIOA_SYS_UART_TX, STM32F4xx_AF_USART1to3) |     \
436
                                         PIN_AFIO_AF(GPIOA_SYS_UART_RX, STM32F4xx_AF_USART1to3) |     \
437
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS0_N, STM32F4xx_AF_system) |      \
438
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SCLK, STM32F4xx_AF_SPI1to2) |      \
439
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MISO, STM32F4xx_AF_SPI1to2) |      \
440
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MOSI, STM32F4xx_AF_SPI1to2))
441
#define VAL_GPIOA_AFRH                  (PIN_AFIO_AF(GPIOA_SYS_REG_EN, STM32F4xx_AF_system) |         \
442
                                         PIN_AFIO_AF(GPIOA_PROG_RX, STM32F4xx_AF_USART1to3) |         \
443
                                         PIN_AFIO_AF(GPIOA_PROG_TX, STM32F4xx_AF_USART1to3) |         \
444
                                         PIN_AFIO_AF(GPIOA_CAN_RX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
445
                                         PIN_AFIO_AF(GPIOA_CAN_TX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
446
                                         PIN_AFIO_AF(GPIOA_SWDIO, STM32F4xx_AF_system) |              \
447
                                         PIN_AFIO_AF(GPIOA_SWCLK, STM32F4xx_AF_system) |              \
448
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS1_N, STM32F4xx_AF_system))
449
450
/*
451
 * GPIOB setup:
452
 *
453
 * PB0  - IR_INT1_N                     (input floating)
454
 * PB1  - VSYS_SENSE                    (analog)
455
 * PB2  - POWER_EN                      (output pushpull high)
456
 * PB3  - SYS_UART_DN                   (output opendrain high)
457
 * PB4  - CHARGE_STAT2A                 (inout floating)
458
 * PB5  - BUZZER                        (alternate 2 pushpull floating)
459
 * PB6  - GAUGE_BATLOW2                 (input floating)
460
 * PB7  - GAUGE_BATGD2_N                (input floating)
461
 * PB8  - GAUGE_SCL2                    (alternate 4 opendrain floating)
462
 * PB9  - GAUGE_SDA2                    (alternate 4 opendrain floating)
463
 * PB10 - GAUGE_SCL1                    (alternate 4 opendrain floating)
464
 * PB11 - GAUGE_SDA1                    (alternate 4 opendrain floating)
465
 * PB12 - LED                           (output opendrain high)
466
 * PB13 - BT_RTS                        (alternate 7 pushpull floating)
467
 * PB14 - BT_CTS                        (inout floating)
468
 * PB15 - SYS_UART_UP                   (output opendrain high)
469
 */
470
#define VAL_GPIOB_MODER                 (PIN_MODE_INPUT(GPIOB_IR_INT1_N) |                            \
471
                                         PIN_MODE_ANALOG(GPIOB_VSYS_SENSE) |                          \
472
                                         PIN_MODE_OUTPUT(GPIOB_POWER_EN) |                            \
473
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_DN) |                         \
474
                                         PIN_MODE_INPUT(GPIOB_CHARGE_STAT2A) |                        \
475
                                         PIN_MODE_ALTERNATE(GPIOB_BUZZER) |                           \
476
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATLOW2) |                        \
477
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATGD2_N) |                       \
478
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL2) |                       \
479
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA2) |                       \
480
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL1) |                       \
481
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA1) |                       \
482
                                         PIN_MODE_OUTPUT(GPIOB_LED) |                                 \
483
                                         PIN_MODE_ALTERNATE(GPIOB_BT_RTS) |                           \
484
                                         PIN_MODE_INPUT(GPIOB_BT_CTS) |                               \
485
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_UP))
486
#define VAL_GPIOB_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOB_IR_INT1_N) |                        \
487
                                         PIN_OTYPE_PUSHPULL(GPIOB_VSYS_SENSE) |                       \
488
                                         PIN_OTYPE_PUSHPULL(GPIOB_POWER_EN) |                         \
489
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_DN) |                     \
490
                                         PIN_OTYPE_PUSHPULL(GPIOB_CHARGE_STAT2A) |                    \
491
                                         PIN_OTYPE_PUSHPULL(GPIOB_BUZZER) |                           \
492
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATLOW2) |                    \
493
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATGD2_N) |                   \
494
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL2) |                      \
495
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA2) |                      \
496
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL1) |                      \
497
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA1) |                      \
498
                                         PIN_OTYPE_OPENDRAIN(GPIOB_LED) |                             \
499
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_RTS) |                           \
500
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_CTS) |                           \
501
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_UP))
502
#define VAL_GPIOB_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOB_IR_INT1_N) |                       \
503
                                         PIN_OSPEED_VERYHIGH(GPIOB_VSYS_SENSE) |                      \
504
                                         PIN_OSPEED_VERYHIGH(GPIOB_POWER_EN) |                        \
505
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_DN) |                     \
506
                                         PIN_OSPEED_VERYHIGH(GPIOB_CHARGE_STAT2A) |                   \
507
                                         PIN_OSPEED_VERYHIGH(GPIOB_BUZZER) |                          \
508
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATLOW2) |                   \
509
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATGD2_N) |                  \
510
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL2) |                      \
511
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA2) |                      \
512
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL1) |                      \
513
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA1) |                      \
514
                                         PIN_OSPEED_VERYHIGH(GPIOB_LED) |                             \
515
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_RTS) |                          \
516
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_CTS) |                          \
517
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_UP))
518
#define VAL_GPIOB_PUPDR                 (PIN_PUPDR_FLOATING(GPIOB_IR_INT1_N) |                        \
519
                                         PIN_PUPDR_FLOATING(GPIOB_VSYS_SENSE) |                       \
520
                                         PIN_PUPDR_FLOATING(GPIOB_POWER_EN) |                         \
521
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_DN) |                      \
522
                                         PIN_PUPDR_FLOATING(GPIOB_CHARGE_STAT2A) |                    \
523
                                         PIN_PUPDR_FLOATING(GPIOB_BUZZER) |                           \
524
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATLOW2) |                    \
525
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATGD2_N) |                   \
526
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL2) |                       \
527
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA2) |                       \
528
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL1) |                       \
529
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA1) |                       \
530
                                         PIN_PUPDR_FLOATING(GPIOB_LED) |                              \
531
                                         PIN_PUPDR_FLOATING(GPIOB_BT_RTS) |                           \
532
                                         PIN_PUPDR_FLOATING(GPIOB_BT_CTS) |                           \
533
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_UP))
534
#define VAL_GPIOB_ODR                   (PIN_ODR_HIGH(GPIOB_IR_INT1_N) |                              \
535
                                         PIN_ODR_HIGH(GPIOB_VSYS_SENSE) |                             \
536
                                         PIN_ODR_HIGH(GPIOB_POWER_EN) |                               \
537
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_DN) |                            \
538
                                         PIN_ODR_HIGH(GPIOB_CHARGE_STAT2A) |                          \
539
                                         PIN_ODR_HIGH(GPIOB_BUZZER) |                                 \
540
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATLOW2) |                          \
541
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATGD2_N) |                         \
542
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL2) |                             \
543
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA2) |                             \
544
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL1) |                             \
545
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA1) |                             \
546
                                         PIN_ODR_HIGH(GPIOB_LED) |                                    \
547
                                         PIN_ODR_HIGH(GPIOB_BT_RTS) |                                 \
548
                                         PIN_ODR_HIGH(GPIOB_BT_CTS) |                                 \
549
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_UP))
550
#define VAL_GPIOB_AFRL                  (PIN_AFIO_AF(GPIOB_IR_INT1_N, STM32F4xx_AF_system) |          \
551
                                         PIN_AFIO_AF(GPIOB_VSYS_SENSE, STM32F4xx_AF_system) |         \
552
                                         PIN_AFIO_AF(GPIOB_POWER_EN, STM32F4xx_AF_system) |           \
553
                                         PIN_AFIO_AF(GPIOB_SYS_UART_DN, STM32F4xx_AF_system) |        \
554
                                         PIN_AFIO_AF(GPIOB_CHARGE_STAT2A, STM32F4xx_AF_system) |      \
555
                                         PIN_AFIO_AF(GPIOB_BUZZER, STM32F4xx_AF_TIM3to5) |            \
556
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATLOW2, STM32F4xx_AF_system) |      \
557
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATGD2_N, STM32F4xx_AF_system))
558
#define VAL_GPIOB_AFRH                  (PIN_AFIO_AF(GPIOB_GAUGE_SCL2, STM32F4xx_AF_I2C1to3) |        \
559
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA2, STM32F4xx_AF_I2C1to3) |        \
560
                                         PIN_AFIO_AF(GPIOB_GAUGE_SCL1, STM32F4xx_AF_I2C1to3) |        \
561
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA1, STM32F4xx_AF_I2C1to3) |        \
562
                                         PIN_AFIO_AF(GPIOB_LED, STM32F4xx_AF_system) |                \
563
                                         PIN_AFIO_AF(GPIOB_BT_RTS, STM32F4xx_AF_USART1to3) |          \
564
                                         PIN_AFIO_AF(GPIOB_BT_CTS, STM32F4xx_AF_USART1to3) |          \
565
                                         PIN_AFIO_AF(GPIOB_SYS_UART_UP, STM32F4xx_AF_system))
566
567
/*
568
 * GPIOC setup:
569
 *
570
 * PC0  - CHARGE_STAT1A                 (input floating)
571
 * PC1  - GAUGE_BATLOW1                 (input floating)
572
 * PC2  - GAUGE_BATGD1_N                (input floating)
573
 * PC3  - CHARGE_EN1_N                  (output opendrain high)
574
 * PC4  - IR_INT2_N                     (input floating)
575
 * PC5  - TOUCH_INT_N                   (input floating)
576
 * PC6  - SYS_DONE                      (input floating)
577
 * PC7  - SYS_PROG_N                    (output opendrain high)
578
 * PC8  - PATH_DC                       (input floating)
579
 * PC9  - SYS_SPI_DIR                   (output opendrain high)
580
 * PC10 - BT_RX                         (alternate 7 pushpull floating)
581
 * PC11 - BT_TX                         (alternate 7 pushpull floating)
582
 * PC12 - SYS_INT_N                     (output opendrain low)
583
 * PC13 - SYS_PD_N                      (output opendrain high)
584
 * PC14 - SYS_WARMRST_N                 (output opendrain high)
585
 * PC15 - BT_RST                        (output opendrain high)
586
 */
587
#define VAL_GPIOC_MODER                 (PIN_MODE_INPUT(GPIOC_CHARGE_STAT1A) |                        \
588
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATLOW1) |                        \
589
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATGD1_N) |                       \
590
                                         PIN_MODE_OUTPUT(GPIOC_CHARGE_EN1_N) |                        \
591
                                         PIN_MODE_INPUT(GPIOC_IR_INT2_N) |                            \
592
                                         PIN_MODE_INPUT(GPIOC_TOUCH_INT_N) |                          \
593
                                         PIN_MODE_INPUT(GPIOC_SYS_DONE) |                             \
594
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PROG_N) |                          \
595
                                         PIN_MODE_INPUT(GPIOC_PATH_DC) |                              \
596
                                         PIN_MODE_OUTPUT(GPIOC_SYS_SPI_DIR) |                         \
597
                                         PIN_MODE_ALTERNATE(GPIOC_BT_RX) |                            \
598
                                         PIN_MODE_ALTERNATE(GPIOC_BT_TX) |                            \
599
                                         PIN_MODE_OUTPUT(GPIOC_SYS_INT_N) |                           \
600
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PD_N) |                            \
601
                                         PIN_MODE_OUTPUT(GPIOC_SYS_WARMRST_N) |                       \
602
                                         PIN_MODE_OUTPUT(GPIOC_BT_RST))
603
#define VAL_GPIOC_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOC_CHARGE_STAT1A) |                    \
604
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATLOW1) |                    \
605
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATGD1_N) |                   \
606
                                         PIN_OTYPE_OPENDRAIN(GPIOC_CHARGE_EN1_N) |                    \
607
                                         PIN_OTYPE_PUSHPULL(GPIOC_IR_INT2_N) |                        \
608
                                         PIN_OTYPE_PUSHPULL(GPIOC_TOUCH_INT_N) |                      \
609
                                         PIN_OTYPE_PUSHPULL(GPIOC_SYS_DONE) |                         \
610
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PROG_N) |                      \
611
                                         PIN_OTYPE_PUSHPULL(GPIOC_PATH_DC) |                          \
612
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_SPI_DIR) |                     \
613
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_RX) |                            \
614
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_TX) |                            \
615
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_INT_N) |                       \
616
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PD_N) |                        \
617
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_WARMRST_N) |                   \
618
                                         PIN_OTYPE_OPENDRAIN(GPIOC_BT_RST))
619
#define VAL_GPIOC_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_STAT1A) |                   \
620
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATLOW1) |                   \
621
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATGD1_N) |                  \
622
                                         PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_EN1_N) |                    \
623
                                         PIN_OSPEED_VERYHIGH(GPIOC_IR_INT2_N) |                       \
624
                                         PIN_OSPEED_VERYHIGH(GPIOC_TOUCH_INT_N) |                     \
625
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_DONE) |                        \
626
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PROG_N) |                      \
627
                                         PIN_OSPEED_VERYHIGH(GPIOC_PATH_DC) |                         \
628
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_SPI_DIR) |                     \
629
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RX) |                           \
630
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_TX) |                           \
631
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_INT_N) |                       \
632
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PD_N) |                        \
633
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_WARMRST_N) |                   \
634
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RST))
635
#define VAL_GPIOC_PUPDR                 (PIN_PUPDR_FLOATING(GPIOC_CHARGE_STAT1A) |                    \
636
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATLOW1) |                    \
637
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATGD1_N) |                   \
638
                                         PIN_PUPDR_FLOATING(GPIOC_CHARGE_EN1_N) |                     \
639
                                         PIN_PUPDR_FLOATING(GPIOC_IR_INT2_N) |                        \
640
                                         PIN_PUPDR_FLOATING(GPIOC_TOUCH_INT_N) |                      \
641
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_DONE) |                         \
642
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PROG_N) |                       \
643
                                         PIN_PUPDR_FLOATING(GPIOC_PATH_DC) |                          \
644
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_SPI_DIR) |                      \
645
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RX) |                            \
646
                                         PIN_PUPDR_FLOATING(GPIOC_BT_TX) |                            \
647
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_INT_N) |                        \
648
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PD_N) |                         \
649
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_WARMRST_N) |                    \
650
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RST))
651
#define VAL_GPIOC_ODR                   (PIN_ODR_HIGH(GPIOC_CHARGE_STAT1A) |                          \
652
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATLOW1) |                          \
653
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATGD1_N) |                         \
654
                                         PIN_ODR_HIGH(GPIOC_CHARGE_EN1_N) |                           \
655
                                         PIN_ODR_HIGH(GPIOC_IR_INT2_N) |                              \
656
                                         PIN_ODR_HIGH(GPIOC_TOUCH_INT_N) |                            \
657
                                         PIN_ODR_HIGH(GPIOC_SYS_DONE) |                               \
658
                                         PIN_ODR_HIGH(GPIOC_SYS_PROG_N) |                             \
659
                                         PIN_ODR_LOW(GPIOC_PATH_DC) |                                 \
660
                                         PIN_ODR_HIGH(GPIOC_SYS_SPI_DIR) |                            \
661
                                         PIN_ODR_HIGH(GPIOC_BT_RX) |                                  \
662
                                         PIN_ODR_HIGH(GPIOC_BT_TX) |                                  \
663
                                         PIN_ODR_LOW(GPIOC_SYS_INT_N) |                               \
664
                                         PIN_ODR_HIGH(GPIOC_SYS_PD_N) |                               \
665
                                         PIN_ODR_HIGH(GPIOC_SYS_WARMRST_N) |                          \
666
                                         PIN_ODR_HIGH(GPIOC_BT_RST))
667
#define VAL_GPIOC_AFRL                  (PIN_AFIO_AF(GPIOC_CHARGE_STAT1A, STM32F4xx_AF_system) |      \
668
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATLOW1, STM32F4xx_AF_system) |      \
669
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATGD1_N, STM32F4xx_AF_system) |     \
670
                                         PIN_AFIO_AF(GPIOC_CHARGE_EN1_N, STM32F4xx_AF_system) |       \
671
                                         PIN_AFIO_AF(GPIOC_IR_INT2_N, STM32F4xx_AF_system) |          \
672
                                         PIN_AFIO_AF(GPIOC_TOUCH_INT_N, STM32F4xx_AF_system) |        \
673
                                         PIN_AFIO_AF(GPIOC_SYS_DONE, STM32F4xx_AF_system) |           \
674
                                         PIN_AFIO_AF(GPIOC_SYS_PROG_N, STM32F4xx_AF_system))
675
#define VAL_GPIOC_AFRH                  (PIN_AFIO_AF(GPIOC_PATH_DC, STM32F4xx_AF_system) |            \
676
                                         PIN_AFIO_AF(GPIOC_SYS_SPI_DIR, STM32F4xx_AF_system) |        \
677
                                         PIN_AFIO_AF(GPIOC_BT_RX, STM32F4xx_AF_USART1to3) |           \
678
                                         PIN_AFIO_AF(GPIOC_BT_TX, STM32F4xx_AF_USART1to3) |           \
679
                                         PIN_AFIO_AF(GPIOC_SYS_INT_N, STM32F4xx_AF_system) |          \
680
                                         PIN_AFIO_AF(GPIOC_SYS_PD_N, STM32F4xx_AF_system) |           \
681
                                         PIN_AFIO_AF(GPIOC_SYS_WARMRST_N, STM32F4xx_AF_system) |      \
682
                                         PIN_AFIO_AF(GPIOC_BT_RST, STM32F4xx_AF_system))
683
684
/*
685
 * GPIOD setup:
686
 *
687
 * PD0  - PIN0                          (input floating)
688
 * PD1  - PIN1                          (input floating)
689
 * PD2  - CHARGE_EN2_N                  (output opendrain high)
690
 * PD3  - PIN3                          (input floating)
691
 * PD4  - PIN4                          (input floating)
692
 * PD5  - PIN5                          (input floating)
693
 * PD6  - PIN6                          (input floating)
694
 * PD7  - PIN7                          (input floating)
695
 * PD8  - PIN8                          (input floating)
696
 * PD9  - PIN9                          (input floating)
697
 * PD10 - PIN10                         (input floating)
698
 * PD11 - PIN11                         (input floating)
699
 * PD12 - PIN12                         (input floating)
700
 * PD13 - PIN13                         (input floating)
701
 * PD14 - PIN14                         (input floating)
702
 * PD15 - PIN15                         (input floating)
703
 */
704
#define VAL_GPIOD_MODER                 (PIN_MODE_INPUT(GPIOD_PIN0) |                                 \
705
                                         PIN_MODE_INPUT(GPIOD_PIN1) |                                 \
706
                                         PIN_MODE_OUTPUT(GPIOD_CHARGE_EN2_N) |                        \
707
                                         PIN_MODE_INPUT(GPIOD_PIN3) |                                 \
708
                                         PIN_MODE_INPUT(GPIOD_PIN4) |                                 \
709
                                         PIN_MODE_INPUT(GPIOD_PIN5) |                                 \
710
                                         PIN_MODE_INPUT(GPIOD_PIN6) |                                 \
711
                                         PIN_MODE_INPUT(GPIOD_PIN7) |                                 \
712
                                         PIN_MODE_INPUT(GPIOD_PIN8) |                                 \
713
                                         PIN_MODE_INPUT(GPIOD_PIN9) |                                 \
714
                                         PIN_MODE_INPUT(GPIOD_PIN10) |                                \
715
                                         PIN_MODE_INPUT(GPIOD_PIN11) |                                \
716
                                         PIN_MODE_INPUT(GPIOD_PIN12) |                                \
717
                                         PIN_MODE_INPUT(GPIOD_PIN13) |                                \
718
                                         PIN_MODE_INPUT(GPIOD_PIN14) |                                \
719
                                         PIN_MODE_INPUT(GPIOD_PIN15))
720
#define VAL_GPIOD_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) |                             \
721
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN1) |                             \
722
                                         PIN_OTYPE_OPENDRAIN(GPIOD_CHARGE_EN2_N) |                    \
723
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN3) |                             \
724
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN4) |                             \
725
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN5) |                             \
726
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN6) |                             \
727
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN7) |                             \
728
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN8) |                             \
729
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN9) |                             \
730
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN10) |                            \
731
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN11) |                            \
732
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN12) |                            \
733
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN13) |                            \
734
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN14) |                            \
735
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
736
#define VAL_GPIOD_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOD_PIN0) |                            \
737
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN1) |                            \
738
                                         PIN_OSPEED_VERYHIGH(GPIOD_CHARGE_EN2_N) |                    \
739
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN3) |                            \
740
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN4) |                            \
741
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN5) |                            \
742
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN6) |                            \
743
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN7) |                            \
744
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN8) |                            \
745
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN9) |                            \
746
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN10) |                           \
747
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN11) |                           \
748
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN12) |                           \
749
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN13) |                           \
750
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN14) |                           \
751
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN15))
752
#define VAL_GPIOD_PUPDR                 (PIN_PUPDR_PULLUP(GPIOD_PIN0) |                               \
753
                                         PIN_PUPDR_PULLUP(GPIOD_PIN1) |                               \
754
                                         PIN_PUPDR_FLOATING(GPIOD_CHARGE_EN2_N) |                     \
755
                                         PIN_PUPDR_PULLUP(GPIOD_PIN3) |                               \
756
                                         PIN_PUPDR_PULLUP(GPIOD_PIN4) |                               \
757
                                         PIN_PUPDR_PULLUP(GPIOD_PIN5) |                               \
758
                                         PIN_PUPDR_PULLUP(GPIOD_PIN6) |                               \
759
                                         PIN_PUPDR_PULLUP(GPIOD_PIN7) |                               \
760
                                         PIN_PUPDR_PULLUP(GPIOD_PIN8) |                               \
761
                                         PIN_PUPDR_PULLUP(GPIOD_PIN9) |                               \
762
                                         PIN_PUPDR_PULLUP(GPIOD_PIN10) |                              \
763
                                         PIN_PUPDR_PULLUP(GPIOD_PIN11) |                              \
764
                                         PIN_PUPDR_PULLUP(GPIOD_PIN12) |                              \
765
                                         PIN_PUPDR_PULLUP(GPIOD_PIN13) |                              \
766
                                         PIN_PUPDR_PULLUP(GPIOD_PIN14) |                              \
767
                                         PIN_PUPDR_PULLUP(GPIOD_PIN15))
768
#define VAL_GPIOD_ODR                   (PIN_ODR_HIGH(GPIOD_PIN0) |                                   \
769
                                         PIN_ODR_HIGH(GPIOD_PIN1) |                                   \
770
                                         PIN_ODR_HIGH(GPIOD_CHARGE_EN2_N) |                           \
771
                                         PIN_ODR_HIGH(GPIOD_PIN3) |                                   \
772
                                         PIN_ODR_HIGH(GPIOD_PIN4) |                                   \
773
                                         PIN_ODR_HIGH(GPIOD_PIN5) |                                   \
774
                                         PIN_ODR_HIGH(GPIOD_PIN6) |                                   \
775
                                         PIN_ODR_HIGH(GPIOD_PIN7) |                                   \
776
                                         PIN_ODR_HIGH(GPIOD_PIN8) |                                   \
777
                                         PIN_ODR_HIGH(GPIOD_PIN9) |                                   \
778
                                         PIN_ODR_HIGH(GPIOD_PIN10) |                                  \
779
                                         PIN_ODR_HIGH(GPIOD_PIN11) |                                  \
780
                                         PIN_ODR_HIGH(GPIOD_PIN12) |                                  \
781
                                         PIN_ODR_HIGH(GPIOD_PIN13) |                                  \
782
                                         PIN_ODR_HIGH(GPIOD_PIN14) |                                  \
783
                                         PIN_ODR_HIGH(GPIOD_PIN15))
784
#define VAL_GPIOD_AFRL                  (PIN_AFIO_AF(GPIOD_PIN0, STM32F4xx_AF_system) |               \
785
                                         PIN_AFIO_AF(GPIOD_PIN1, STM32F4xx_AF_system) |               \
786
                                         PIN_AFIO_AF(GPIOD_CHARGE_EN2_N, STM32F4xx_AF_system) |       \
787
                                         PIN_AFIO_AF(GPIOD_PIN3, STM32F4xx_AF_system) |               \
788
                                         PIN_AFIO_AF(GPIOD_PIN4, STM32F4xx_AF_system) |               \
789
                                         PIN_AFIO_AF(GPIOD_PIN5, STM32F4xx_AF_system) |               \
790
                                         PIN_AFIO_AF(GPIOD_PIN6, STM32F4xx_AF_system) |               \
791
                                         PIN_AFIO_AF(GPIOD_PIN7, STM32F4xx_AF_system))
792
#define VAL_GPIOD_AFRH                  (PIN_AFIO_AF(GPIOD_PIN8, STM32F4xx_AF_system) |               \
793
                                         PIN_AFIO_AF(GPIOD_PIN9, STM32F4xx_AF_system) |               \
794
                                         PIN_AFIO_AF(GPIOD_PIN10, STM32F4xx_AF_system) |              \
795
                                         PIN_AFIO_AF(GPIOD_PIN11, STM32F4xx_AF_system) |              \
796
                                         PIN_AFIO_AF(GPIOD_PIN12, STM32F4xx_AF_system) |              \
797
                                         PIN_AFIO_AF(GPIOD_PIN13, STM32F4xx_AF_system) |              \
798
                                         PIN_AFIO_AF(GPIOD_PIN14, STM32F4xx_AF_system) |              \
799
                                         PIN_AFIO_AF(GPIOD_PIN15, STM32F4xx_AF_system))
800
801
/*
802
 * GPIOE setup:
803
 *
804
 * PE0  - PIN0                          (input floating)
805
 * PE1  - PIN1                          (input floating)
806
 * PE2  - PIN2                          (input floating)
807
 * PE3  - PIN3                          (input floating)
808
 * PE4  - PIN4                          (input floating)
809
 * PE5  - PIN5                          (input floating)
810
 * PE6  - PIN6                          (input floating)
811
 * PE7  - PIN7                          (input floating)
812
 * PE8  - PIN8                          (input floating)
813
 * PE9  - PIN9                          (input floating)
814
 * PE10 - PIN10                         (input floating)
815
 * PE11 - PIN11                         (input floating)
816
 * PE12 - PIN12                         (input floating)
817
 * PE13 - PIN13                         (input floating)
818
 * PE14 - PIN14                         (input floating)
819
 * PE15 - PIN15                         (input floating)
820
 */
821
#define VAL_GPIOE_MODER                 (PIN_MODE_INPUT(GPIOE_PIN0) |                                 \
822
                                         PIN_MODE_INPUT(GPIOE_PIN1) |                                 \
823
                                         PIN_MODE_INPUT(GPIOE_PIN2) |                                 \
824
                                         PIN_MODE_INPUT(GPIOE_PIN3) |                                 \
825
                                         PIN_MODE_INPUT(GPIOE_PIN4) |                                 \
826
                                         PIN_MODE_INPUT(GPIOE_PIN5) |                                 \
827
                                         PIN_MODE_INPUT(GPIOE_PIN6) |                                 \
828
                                         PIN_MODE_INPUT(GPIOE_PIN7) |                                 \
829
                                         PIN_MODE_INPUT(GPIOE_PIN8) |                                 \
830
                                         PIN_MODE_INPUT(GPIOE_PIN9) |                                 \
831
                                         PIN_MODE_INPUT(GPIOE_PIN10) |                                \
832
                                         PIN_MODE_INPUT(GPIOE_PIN11) |                                \
833
                                         PIN_MODE_INPUT(GPIOE_PIN12) |                                \
834
                                         PIN_MODE_INPUT(GPIOE_PIN13) |                                \
835
                                         PIN_MODE_INPUT(GPIOE_PIN14) |                                \
836
                                         PIN_MODE_INPUT(GPIOE_PIN15))
837
#define VAL_GPIOE_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) |                             \
838
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN1) |                             \
839
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN2) |                             \
840
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN3) |                             \
841
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN4) |                             \
842
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN5) |                             \
843
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN6) |                             \
844
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN7) |                             \
845
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN8) |                             \
846
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN9) |                             \
847
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN10) |                            \
848
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN11) |                            \
849
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN12) |                            \
850
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN13) |                            \
851
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN14) |                            \
852
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
853
#define VAL_GPIOE_OSPEEDR               (PIN_OSPEED_LOW(GPIOE_PIN0) |                                 \
854
                                         PIN_OSPEED_LOW(GPIOE_PIN1) |                                 \
855
                                         PIN_OSPEED_LOW(GPIOE_PIN2) |                                 \
856
                                         PIN_OSPEED_LOW(GPIOE_PIN3) |                                 \
857
                                         PIN_OSPEED_LOW(GPIOE_PIN4) |                                 \
858
                                         PIN_OSPEED_LOW(GPIOE_PIN5) |                                 \
859
                                         PIN_OSPEED_LOW(GPIOE_PIN6) |                                 \
860
                                         PIN_OSPEED_LOW(GPIOE_PIN7) |                                 \
861
                                         PIN_OSPEED_LOW(GPIOE_PIN8) |                                 \
862
                                         PIN_OSPEED_LOW(GPIOE_PIN9) |                                 \
863
                                         PIN_OSPEED_LOW(GPIOE_PIN10) |                                \
864
                                         PIN_OSPEED_LOW(GPIOE_PIN11) |                                \
865
                                         PIN_OSPEED_LOW(GPIOE_PIN12) |                                \
866
                                         PIN_OSPEED_LOW(GPIOE_PIN13) |                                \
867
                                         PIN_OSPEED_LOW(GPIOE_PIN14) |                                \
868
                                         PIN_OSPEED_LOW(GPIOE_PIN15))
869
#define VAL_GPIOE_PUPDR                 (PIN_PUPDR_FLOATING(GPIOE_PIN0) |                             \
870
                                         PIN_PUPDR_FLOATING(GPIOE_PIN1) |                             \
871
                                         PIN_PUPDR_FLOATING(GPIOE_PIN2) |                             \
872
                                         PIN_PUPDR_FLOATING(GPIOE_PIN3) |                             \
873
                                         PIN_PUPDR_FLOATING(GPIOE_PIN4) |                             \
874
                                         PIN_PUPDR_FLOATING(GPIOE_PIN5) |                             \
875
                                         PIN_PUPDR_FLOATING(GPIOE_PIN6) |                             \
876
                                         PIN_PUPDR_FLOATING(GPIOE_PIN7) |                             \
877
                                         PIN_PUPDR_FLOATING(GPIOE_PIN8) |                             \
878
                                         PIN_PUPDR_FLOATING(GPIOE_PIN9) |                             \
879
                                         PIN_PUPDR_FLOATING(GPIOE_PIN10) |                            \
880
                                         PIN_PUPDR_FLOATING(GPIOE_PIN11) |                            \
881
                                         PIN_PUPDR_FLOATING(GPIOE_PIN12) |                            \
882
                                         PIN_PUPDR_FLOATING(GPIOE_PIN13) |                            \
883
                                         PIN_PUPDR_FLOATING(GPIOE_PIN14) |                            \
884
                                         PIN_PUPDR_FLOATING(GPIOE_PIN15))
885
#define VAL_GPIOE_ODR                   (PIN_ODR_LOW(GPIOE_PIN0) |                                    \
886
                                         PIN_ODR_LOW(GPIOE_PIN1) |                                    \
887
                                         PIN_ODR_LOW(GPIOE_PIN2) |                                    \
888
                                         PIN_ODR_LOW(GPIOE_PIN3) |                                    \
889
                                         PIN_ODR_LOW(GPIOE_PIN4) |                                    \
890
                                         PIN_ODR_LOW(GPIOE_PIN5) |                                    \
891
                                         PIN_ODR_LOW(GPIOE_PIN6) |                                    \
892
                                         PIN_ODR_LOW(GPIOE_PIN7) |                                    \
893
                                         PIN_ODR_LOW(GPIOE_PIN8) |                                    \
894
                                         PIN_ODR_LOW(GPIOE_PIN9) |                                    \
895
                                         PIN_ODR_LOW(GPIOE_PIN10) |                                   \
896
                                         PIN_ODR_LOW(GPIOE_PIN11) |                                   \
897
                                         PIN_ODR_LOW(GPIOE_PIN12) |                                   \
898
                                         PIN_ODR_LOW(GPIOE_PIN13) |                                   \
899
                                         PIN_ODR_LOW(GPIOE_PIN14) |                                   \
900
                                         PIN_ODR_LOW(GPIOE_PIN15))
901
#define VAL_GPIOE_AFRL                  (PIN_AFIO_AF(GPIOE_PIN0, STM32F4xx_AF_system) |               \
902
                                         PIN_AFIO_AF(GPIOE_PIN1, STM32F4xx_AF_system) |               \
903
                                         PIN_AFIO_AF(GPIOE_PIN2, STM32F4xx_AF_system) |               \
904
                                         PIN_AFIO_AF(GPIOE_PIN3, STM32F4xx_AF_system) |               \
905
                                         PIN_AFIO_AF(GPIOE_PIN4, STM32F4xx_AF_system) |               \
906
                                         PIN_AFIO_AF(GPIOE_PIN5, STM32F4xx_AF_system) |               \
907
                                         PIN_AFIO_AF(GPIOE_PIN6, STM32F4xx_AF_system) |               \
908
                                         PIN_AFIO_AF(GPIOE_PIN7, STM32F4xx_AF_system))
909
#define VAL_GPIOE_AFRH                  (PIN_AFIO_AF(GPIOE_PIN8, STM32F4xx_AF_system) |               \
910
                                         PIN_AFIO_AF(GPIOE_PIN9, STM32F4xx_AF_system) |               \
911
                                         PIN_AFIO_AF(GPIOE_PIN10, STM32F4xx_AF_system) |              \
912
                                         PIN_AFIO_AF(GPIOE_PIN11, STM32F4xx_AF_system) |              \
913
                                         PIN_AFIO_AF(GPIOE_PIN12, STM32F4xx_AF_system) |              \
914
                                         PIN_AFIO_AF(GPIOE_PIN13, STM32F4xx_AF_system) |              \
915
                                         PIN_AFIO_AF(GPIOE_PIN14, STM32F4xx_AF_system) |              \
916
                                         PIN_AFIO_AF(GPIOE_PIN15, STM32F4xx_AF_system))
917
918
/*
919
 * GPIOF setup:
920
 *
921
 * PF0  - PIN0                          (input floating)
922
 * PF1  - PIN1                          (input floating)
923
 * PF2  - PIN2                          (input floating)
924
 * PF3  - PIN3                          (input floating)
925
 * PF4  - PIN4                          (input floating)
926
 * PF5  - PIN5                          (input floating)
927
 * PF6  - PIN6                          (input floating)
928
 * PF7  - PIN7                          (input floating)
929
 * PF8  - PIN8                          (input floating)
930
 * PF9  - PIN9                          (input floating)
931
 * PF10 - PIN10                         (input floating)
932
 * PF11 - PIN11                         (input floating)
933
 * PF12 - PIN12                         (input floating)
934
 * PF13 - PIN13                         (input floating)
935
 * PF14 - PIN14                         (input floating)
936
 * PF15 - PIN15                         (input floating)
937
 */
938
#define VAL_GPIOF_MODER                 (PIN_MODE_INPUT(GPIOF_PIN0) |                                 \
939
                                         PIN_MODE_INPUT(GPIOF_PIN1) |                                 \
940
                                         PIN_MODE_INPUT(GPIOF_PIN2) |                                 \
941
                                         PIN_MODE_INPUT(GPIOF_PIN3) |                                 \
942
                                         PIN_MODE_INPUT(GPIOF_PIN4) |                                 \
943
                                         PIN_MODE_INPUT(GPIOF_PIN5) |                                 \
944
                                         PIN_MODE_INPUT(GPIOF_PIN6) |                                 \
945
                                         PIN_MODE_INPUT(GPIOF_PIN7) |                                 \
946
                                         PIN_MODE_INPUT(GPIOF_PIN8) |                                 \
947
                                         PIN_MODE_INPUT(GPIOF_PIN9) |                                 \
948
                                         PIN_MODE_INPUT(GPIOF_PIN10) |                                \
949
                                         PIN_MODE_INPUT(GPIOF_PIN11) |                                \
950
                                         PIN_MODE_INPUT(GPIOF_PIN12) |                                \
951
                                         PIN_MODE_INPUT(GPIOF_PIN13) |                                \
952
                                         PIN_MODE_INPUT(GPIOF_PIN14) |                                \
953
                                         PIN_MODE_INPUT(GPIOF_PIN15))
954
#define VAL_GPIOF_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) |                             \
955
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN1) |                             \
956
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN2) |                             \
957
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN3) |                             \
958
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN4) |                             \
959
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN5) |                             \
960
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN6) |                             \
961
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN7) |                             \
962
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN8) |                             \
963
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN9) |                             \
964
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN10) |                            \
965
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN11) |                            \
966
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN12) |                            \
967
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN13) |                            \
968
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN14) |                            \
969
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
970
#define VAL_GPIOF_OSPEEDR               (PIN_OSPEED_LOW(GPIOF_PIN0) |                                 \
971
                                         PIN_OSPEED_LOW(GPIOF_PIN1) |                                 \
972
                                         PIN_OSPEED_LOW(GPIOF_PIN2) |                                 \
973
                                         PIN_OSPEED_LOW(GPIOF_PIN3) |                                 \
974
                                         PIN_OSPEED_LOW(GPIOF_PIN4) |                                 \
975
                                         PIN_OSPEED_LOW(GPIOF_PIN5) |                                 \
976
                                         PIN_OSPEED_LOW(GPIOF_PIN6) |                                 \
977
                                         PIN_OSPEED_LOW(GPIOF_PIN7) |                                 \
978
                                         PIN_OSPEED_LOW(GPIOF_PIN8) |                                 \
979
                                         PIN_OSPEED_LOW(GPIOF_PIN9) |                                 \
980
                                         PIN_OSPEED_LOW(GPIOF_PIN10) |                                \
981
                                         PIN_OSPEED_LOW(GPIOF_PIN11) |                                \
982
                                         PIN_OSPEED_LOW(GPIOF_PIN12) |                                \
983
                                         PIN_OSPEED_LOW(GPIOF_PIN13) |                                \
984
                                         PIN_OSPEED_LOW(GPIOF_PIN14) |                                \
985
                                         PIN_OSPEED_LOW(GPIOF_PIN15))
986
#define VAL_GPIOF_PUPDR                 (PIN_PUPDR_FLOATING(GPIOF_PIN0) |                             \
987
                                         PIN_PUPDR_FLOATING(GPIOF_PIN1) |                             \
988
                                         PIN_PUPDR_FLOATING(GPIOF_PIN2) |                             \
989
                                         PIN_PUPDR_FLOATING(GPIOF_PIN3) |                             \
990
                                         PIN_PUPDR_FLOATING(GPIOF_PIN4) |                             \
991
                                         PIN_PUPDR_FLOATING(GPIOF_PIN5) |                             \
992
                                         PIN_PUPDR_FLOATING(GPIOF_PIN6) |                             \
993
                                         PIN_PUPDR_FLOATING(GPIOF_PIN7) |                             \
994
                                         PIN_PUPDR_FLOATING(GPIOF_PIN8) |                             \
995
                                         PIN_PUPDR_FLOATING(GPIOF_PIN9) |                             \
996
                                         PIN_PUPDR_FLOATING(GPIOF_PIN10) |                            \
997
                                         PIN_PUPDR_FLOATING(GPIOF_PIN11) |                            \
998
                                         PIN_PUPDR_FLOATING(GPIOF_PIN12) |                            \
999
                                         PIN_PUPDR_FLOATING(GPIOF_PIN13) |                            \
1000
                                         PIN_PUPDR_FLOATING(GPIOF_PIN14) |                            \
1001
                                         PIN_PUPDR_FLOATING(GPIOF_PIN15))
1002
#define VAL_GPIOF_ODR                   (PIN_ODR_LOW(GPIOF_PIN0) |                                    \
1003
                                         PIN_ODR_LOW(GPIOF_PIN1) |                                    \
1004
                                         PIN_ODR_LOW(GPIOF_PIN2) |                                    \
1005
                                         PIN_ODR_LOW(GPIOF_PIN3) |                                    \
1006
                                         PIN_ODR_LOW(GPIOF_PIN4) |                                    \
1007
                                         PIN_ODR_LOW(GPIOF_PIN5) |                                    \
1008
                                         PIN_ODR_LOW(GPIOF_PIN6) |                                    \
1009
                                         PIN_ODR_LOW(GPIOF_PIN7) |                                    \
1010
                                         PIN_ODR_LOW(GPIOF_PIN8) |                                    \
1011
                                         PIN_ODR_LOW(GPIOF_PIN9) |                                    \
1012
                                         PIN_ODR_LOW(GPIOF_PIN10) |                                   \
1013
                                         PIN_ODR_LOW(GPIOF_PIN11) |                                   \
1014
                                         PIN_ODR_LOW(GPIOF_PIN12) |                                   \
1015
                                         PIN_ODR_LOW(GPIOF_PIN13) |                                   \
1016
                                         PIN_ODR_LOW(GPIOF_PIN14) |                                   \
1017
                                         PIN_ODR_LOW(GPIOF_PIN15))
1018
#define VAL_GPIOF_AFRL                  (PIN_AFIO_AF(GPIOF_PIN0, STM32F4xx_AF_system) |               \
1019
                                         PIN_AFIO_AF(GPIOF_PIN1, STM32F4xx_AF_system) |               \
1020
                                         PIN_AFIO_AF(GPIOF_PIN2, STM32F4xx_AF_system) |               \
1021
                                         PIN_AFIO_AF(GPIOF_PIN3, STM32F4xx_AF_system) |               \
1022
                                         PIN_AFIO_AF(GPIOF_PIN4, STM32F4xx_AF_system) |               \
1023
                                         PIN_AFIO_AF(GPIOF_PIN5, STM32F4xx_AF_system) |               \
1024
                                         PIN_AFIO_AF(GPIOF_PIN6, STM32F4xx_AF_system) |               \
1025
                                         PIN_AFIO_AF(GPIOF_PIN7, STM32F4xx_AF_system))
1026
#define VAL_GPIOF_AFRH                  (PIN_AFIO_AF(GPIOF_PIN8, STM32F4xx_AF_system) |               \
1027
                                         PIN_AFIO_AF(GPIOF_PIN9, STM32F4xx_AF_system) |               \
1028
                                         PIN_AFIO_AF(GPIOF_PIN10, STM32F4xx_AF_system) |              \
1029
                                         PIN_AFIO_AF(GPIOF_PIN11, STM32F4xx_AF_system) |              \
1030
                                         PIN_AFIO_AF(GPIOF_PIN12, STM32F4xx_AF_system) |              \
1031
                                         PIN_AFIO_AF(GPIOF_PIN13, STM32F4xx_AF_system) |              \
1032
                                         PIN_AFIO_AF(GPIOF_PIN14, STM32F4xx_AF_system) |              \
1033
                                         PIN_AFIO_AF(GPIOF_PIN15, STM32F4xx_AF_system))
1034
1035
/*
1036
 * GPIOG setup:
1037
 *
1038
 * PG0  - PIN0                          (input floating)
1039
 * PG1  - PIN1                          (input floating)
1040
 * PG2  - PIN2                          (input floating)
1041
 * PG3  - PIN3                          (input floating)
1042
 * PG4  - PIN4                          (input floating)
1043
 * PG5  - PIN5                          (input floating)
1044
 * PG6  - PIN6                          (input floating)
1045
 * PG7  - PIN7                          (input floating)
1046
 * PG8  - PIN8                          (input floating)
1047
 * PG9  - PIN9                          (input floating)
1048
 * PG10 - PIN10                         (input floating)
1049
 * PG11 - PIN11                         (input floating)
1050
 * PG12 - PIN12                         (input floating)
1051
 * PG13 - PIN13                         (input floating)
1052
 * PG14 - PIN14                         (input floating)
1053
 * PG15 - PIN15                         (input floating)
1054
 */
1055
#define VAL_GPIOG_MODER                 (PIN_MODE_INPUT(GPIOG_PIN0) |                                 \
1056
                                         PIN_MODE_INPUT(GPIOG_PIN1) |                                 \
1057
                                         PIN_MODE_INPUT(GPIOG_PIN2) |                                 \
1058
                                         PIN_MODE_INPUT(GPIOG_PIN3) |                                 \
1059
                                         PIN_MODE_INPUT(GPIOG_PIN4) |                                 \
1060
                                         PIN_MODE_INPUT(GPIOG_PIN5) |                                 \
1061
                                         PIN_MODE_INPUT(GPIOG_PIN6) |                                 \
1062
                                         PIN_MODE_INPUT(GPIOG_PIN7) |                                 \
1063
                                         PIN_MODE_INPUT(GPIOG_PIN8) |                                 \
1064
                                         PIN_MODE_INPUT(GPIOG_PIN9) |                                 \
1065
                                         PIN_MODE_INPUT(GPIOG_PIN10) |                                \
1066
                                         PIN_MODE_INPUT(GPIOG_PIN11) |                                \
1067
                                         PIN_MODE_INPUT(GPIOG_PIN12) |                                \
1068
                                         PIN_MODE_INPUT(GPIOG_PIN13) |                                \
1069
                                         PIN_MODE_INPUT(GPIOG_PIN14) |                                \
1070
                                         PIN_MODE_INPUT(GPIOG_PIN15))
1071
#define VAL_GPIOG_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) |                             \
1072
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN1) |                             \
1073
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN2) |                             \
1074
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN3) |                             \
1075
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN4) |                             \
1076
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN5) |                             \
1077
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN6) |                             \
1078
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN7) |                             \
1079
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN8) |                             \
1080
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN9) |                             \
1081
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN10) |                            \
1082
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN11) |                            \
1083
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN12) |                            \
1084
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN13) |                            \
1085
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN14) |                            \
1086
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN15))
1087
#define VAL_GPIOG_OSPEEDR               (PIN_OSPEED_LOW(GPIOG_PIN0) |                                 \
1088
                                         PIN_OSPEED_LOW(GPIOG_PIN1) |                                 \
1089
                                         PIN_OSPEED_LOW(GPIOG_PIN2) |                                 \
1090
                                         PIN_OSPEED_LOW(GPIOG_PIN3) |                                 \
1091
                                         PIN_OSPEED_LOW(GPIOG_PIN4) |                                 \
1092
                                         PIN_OSPEED_LOW(GPIOG_PIN5) |                                 \
1093
                                         PIN_OSPEED_LOW(GPIOG_PIN6) |                                 \
1094
                                         PIN_OSPEED_LOW(GPIOG_PIN7) |                                 \
1095
                                         PIN_OSPEED_LOW(GPIOG_PIN8) |                                 \
1096
                                         PIN_OSPEED_LOW(GPIOG_PIN9) |                                 \
1097
                                         PIN_OSPEED_LOW(GPIOG_PIN10) |                                \
1098
                                         PIN_OSPEED_LOW(GPIOG_PIN11) |                                \
1099
                                         PIN_OSPEED_LOW(GPIOG_PIN12) |                                \
1100
                                         PIN_OSPEED_LOW(GPIOG_PIN13) |                                \
1101
                                         PIN_OSPEED_LOW(GPIOG_PIN14) |                                \
1102
                                         PIN_OSPEED_LOW(GPIOG_PIN15))
1103
#define VAL_GPIOG_PUPDR                 (PIN_PUPDR_FLOATING(GPIOG_PIN0) |                             \
1104
                                         PIN_PUPDR_FLOATING(GPIOG_PIN1) |                             \
1105
                                         PIN_PUPDR_FLOATING(GPIOG_PIN2) |                             \
1106
                                         PIN_PUPDR_FLOATING(GPIOG_PIN3) |                             \
1107
                                         PIN_PUPDR_FLOATING(GPIOG_PIN4) |                             \
1108
                                         PIN_PUPDR_FLOATING(GPIOG_PIN5) |                             \
1109
                                         PIN_PUPDR_FLOATING(GPIOG_PIN6) |                             \
1110
                                         PIN_PUPDR_FLOATING(GPIOG_PIN7) |                             \
1111
                                         PIN_PUPDR_FLOATING(GPIOG_PIN8) |                             \
1112
                                         PIN_PUPDR_FLOATING(GPIOG_PIN9) |                             \
1113
                                         PIN_PUPDR_FLOATING(GPIOG_PIN10) |                            \
1114
                                         PIN_PUPDR_FLOATING(GPIOG_PIN11) |                            \
1115
                                         PIN_PUPDR_FLOATING(GPIOG_PIN12) |                            \
1116
                                         PIN_PUPDR_FLOATING(GPIOG_PIN13) |                            \
1117
                                         PIN_PUPDR_FLOATING(GPIOG_PIN14) |                            \
1118
                                         PIN_PUPDR_FLOATING(GPIOG_PIN15))
1119
#define VAL_GPIOG_ODR                   (PIN_ODR_LOW(GPIOG_PIN0) |                                    \
1120
                                         PIN_ODR_LOW(GPIOG_PIN1) |                                    \
1121
                                         PIN_ODR_LOW(GPIOG_PIN2) |                                    \
1122
                                         PIN_ODR_LOW(GPIOG_PIN3) |                                    \
1123
                                         PIN_ODR_LOW(GPIOG_PIN4) |                                    \
1124
                                         PIN_ODR_LOW(GPIOG_PIN5) |                                    \
1125
                                         PIN_ODR_LOW(GPIOG_PIN6) |                                    \
1126
                                         PIN_ODR_LOW(GPIOG_PIN7) |                                    \
1127
                                         PIN_ODR_LOW(GPIOG_PIN8) |                                    \
1128
                                         PIN_ODR_LOW(GPIOG_PIN9) |                                    \
1129
                                         PIN_ODR_LOW(GPIOG_PIN10) |                                   \
1130
                                         PIN_ODR_LOW(GPIOG_PIN11) |                                   \
1131
                                         PIN_ODR_LOW(GPIOG_PIN12) |                                   \
1132
                                         PIN_ODR_LOW(GPIOG_PIN13) |                                   \
1133
                                         PIN_ODR_LOW(GPIOG_PIN14) |                                   \
1134
                                         PIN_ODR_LOW(GPIOG_PIN15))
1135
#define VAL_GPIOG_AFRL                  (PIN_AFIO_AF(GPIOG_PIN0, STM32F4xx_AF_system) |               \
1136
                                         PIN_AFIO_AF(GPIOG_PIN1, STM32F4xx_AF_system) |               \
1137
                                         PIN_AFIO_AF(GPIOG_PIN2, STM32F4xx_AF_system) |               \
1138
                                         PIN_AFIO_AF(GPIOG_PIN3, STM32F4xx_AF_system) |               \
1139
                                         PIN_AFIO_AF(GPIOG_PIN4, STM32F4xx_AF_system) |               \
1140
                                         PIN_AFIO_AF(GPIOG_PIN5, STM32F4xx_AF_system) |               \
1141
                                         PIN_AFIO_AF(GPIOG_PIN6, STM32F4xx_AF_system) |               \
1142
                                         PIN_AFIO_AF(GPIOG_PIN7, STM32F4xx_AF_system))
1143
#define VAL_GPIOG_AFRH                  (PIN_AFIO_AF(GPIOG_PIN8, STM32F4xx_AF_system) |               \
1144
                                         PIN_AFIO_AF(GPIOG_PIN9, STM32F4xx_AF_system) |               \
1145
                                         PIN_AFIO_AF(GPIOG_PIN10, STM32F4xx_AF_system) |              \
1146
                                         PIN_AFIO_AF(GPIOG_PIN11, STM32F4xx_AF_system) |              \
1147
                                         PIN_AFIO_AF(GPIOG_PIN12, STM32F4xx_AF_system) |              \
1148
                                         PIN_AFIO_AF(GPIOG_PIN13, STM32F4xx_AF_system) |              \
1149
                                         PIN_AFIO_AF(GPIOG_PIN14, STM32F4xx_AF_system) |              \
1150
                                         PIN_AFIO_AF(GPIOG_PIN15, STM32F4xx_AF_system))
1151
1152
/*
1153
 * GPIOH setup:
1154
 *
1155
 * PH0  - OSC_IN                        (input floating)
1156
 * PH1  - OSC_OUT                       (input floating)
1157
 * PH2  - PIN2                          (input floating)
1158
 * PH3  - PIN3                          (input floating)
1159
 * PH4  - PIN4                          (input floating)
1160
 * PH5  - PIN5                          (input floating)
1161
 * PH6  - PIN6                          (input floating)
1162
 * PH7  - PIN7                          (input floating)
1163
 * PH8  - PIN8                          (input floating)
1164
 * PH9  - PIN9                          (input floating)
1165
 * PH10 - PIN10                         (input floating)
1166
 * PH11 - PIN11                         (input floating)
1167
 * PH12 - PIN12                         (input floating)
1168
 * PH13 - PIN13                         (input floating)
1169
 * PH14 - PIN14                         (input floating)
1170
 * PH15 - PIN15                         (input floating)
1171
 */
1172
#define VAL_GPIOH_MODER                 (PIN_MODE_INPUT(GPIOH_OSC_IN) |                               \
1173
                                         PIN_MODE_INPUT(GPIOH_OSC_OUT) |                              \
1174
                                         PIN_MODE_INPUT(GPIOH_PIN2) |                                 \
1175
                                         PIN_MODE_INPUT(GPIOH_PIN3) |                                 \
1176
                                         PIN_MODE_INPUT(GPIOH_PIN4) |                                 \
1177
                                         PIN_MODE_INPUT(GPIOH_PIN5) |                                 \
1178
                                         PIN_MODE_INPUT(GPIOH_PIN6) |                                 \
1179
                                         PIN_MODE_INPUT(GPIOH_PIN7) |                                 \
1180
                                         PIN_MODE_INPUT(GPIOH_PIN8) |                                 \
1181
                                         PIN_MODE_INPUT(GPIOH_PIN9) |                                 \
1182
                                         PIN_MODE_INPUT(GPIOH_PIN10) |                                \
1183
                                         PIN_MODE_INPUT(GPIOH_PIN11) |                                \
1184
                                         PIN_MODE_INPUT(GPIOH_PIN12) |                                \
1185
                                         PIN_MODE_INPUT(GPIOH_PIN13) |                                \
1186
                                         PIN_MODE_INPUT(GPIOH_PIN14) |                                \
1187
                                         PIN_MODE_INPUT(GPIOH_PIN15))
1188
#define VAL_GPIOH_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) |                           \
1189
                                         PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) |                          \
1190
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN2) |                             \
1191
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN3) |                             \
1192
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN4) |                             \
1193
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN5) |                             \
1194
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN6) |                             \
1195
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN7) |                             \
1196
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN8) |                             \
1197
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN9) |                             \
1198
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN10) |                            \
1199
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN11) |                            \
1200
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN12) |                            \
1201
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN13) |                            \
1202
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN14) |                            \
1203
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN15))
1204
#define VAL_GPIOH_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOH_OSC_IN) |                          \
1205
                                         PIN_OSPEED_VERYHIGH(GPIOH_OSC_OUT) |                         \
1206
                                         PIN_OSPEED_LOW(GPIOH_PIN2) |                                 \
1207
                                         PIN_OSPEED_LOW(GPIOH_PIN3) |                                 \
1208
                                         PIN_OSPEED_LOW(GPIOH_PIN4) |                                 \
1209
                                         PIN_OSPEED_LOW(GPIOH_PIN5) |                                 \
1210
                                         PIN_OSPEED_LOW(GPIOH_PIN6) |                                 \
1211
                                         PIN_OSPEED_LOW(GPIOH_PIN7) |                                 \
1212
                                         PIN_OSPEED_LOW(GPIOH_PIN8) |                                 \
1213
                                         PIN_OSPEED_LOW(GPIOH_PIN9) |                                 \
1214
                                         PIN_OSPEED_LOW(GPIOH_PIN10) |                                \
1215
                                         PIN_OSPEED_LOW(GPIOH_PIN11) |                                \
1216
                                         PIN_OSPEED_LOW(GPIOH_PIN12) |                                \
1217
                                         PIN_OSPEED_LOW(GPIOH_PIN13) |                                \
1218
                                         PIN_OSPEED_LOW(GPIOH_PIN14) |                                \
1219
                                         PIN_OSPEED_LOW(GPIOH_PIN15))
1220
#define VAL_GPIOH_PUPDR                 (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) |                           \
1221
                                         PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) |                          \
1222
                                         PIN_PUPDR_FLOATING(GPIOH_PIN2) |                             \
1223
                                         PIN_PUPDR_FLOATING(GPIOH_PIN3) |                             \
1224
                                         PIN_PUPDR_FLOATING(GPIOH_PIN4) |                             \
1225
                                         PIN_PUPDR_FLOATING(GPIOH_PIN5) |                             \
1226
                                         PIN_PUPDR_FLOATING(GPIOH_PIN6) |                             \
1227
                                         PIN_PUPDR_FLOATING(GPIOH_PIN7) |                             \
1228
                                         PIN_PUPDR_FLOATING(GPIOH_PIN8) |                             \
1229
                                         PIN_PUPDR_FLOATING(GPIOH_PIN9) |                             \
1230
                                         PIN_PUPDR_FLOATING(GPIOH_PIN10) |                            \
1231
                                         PIN_PUPDR_FLOATING(GPIOH_PIN11) |                            \
1232
                                         PIN_PUPDR_FLOATING(GPIOH_PIN12) |                            \
1233
                                         PIN_PUPDR_FLOATING(GPIOH_PIN13) |                            \
1234
                                         PIN_PUPDR_FLOATING(GPIOH_PIN14) |                            \
1235
                                         PIN_PUPDR_FLOATING(GPIOH_PIN15))
1236
#define VAL_GPIOH_ODR                   (PIN_ODR_HIGH(GPIOH_OSC_IN) |                                 \
1237
                                         PIN_ODR_HIGH(GPIOH_OSC_OUT) |                                \
1238
                                         PIN_ODR_HIGH(GPIOH_PIN2) |                                   \
1239
                                         PIN_ODR_HIGH(GPIOH_PIN3) |                                   \
1240
                                         PIN_ODR_HIGH(GPIOH_PIN4) |                                   \
1241
                                         PIN_ODR_HIGH(GPIOH_PIN5) |                                   \
1242
                                         PIN_ODR_HIGH(GPIOH_PIN6) |                                   \
1243
                                         PIN_ODR_HIGH(GPIOH_PIN7) |                                   \
1244
                                         PIN_ODR_HIGH(GPIOH_PIN8) |                                   \
1245
                                         PIN_ODR_HIGH(GPIOH_PIN9) |                                   \
1246
                                         PIN_ODR_HIGH(GPIOH_PIN10) |                                  \
1247
                                         PIN_ODR_HIGH(GPIOH_PIN11) |                                  \
1248
                                         PIN_ODR_HIGH(GPIOH_PIN12) |                                  \
1249
                                         PIN_ODR_HIGH(GPIOH_PIN13) |                                  \
1250
                                         PIN_ODR_HIGH(GPIOH_PIN14) |                                  \
1251
                                         PIN_ODR_HIGH(GPIOH_PIN15))
1252
#define VAL_GPIOH_AFRL                  (PIN_AFIO_AF(GPIOH_OSC_IN, STM32F4xx_AF_system) |             \
1253
                                         PIN_AFIO_AF(GPIOH_OSC_OUT, STM32F4xx_AF_system) |            \
1254
                                         PIN_AFIO_AF(GPIOH_PIN2, STM32F4xx_AF_system) |               \
1255
                                         PIN_AFIO_AF(GPIOH_PIN3, STM32F4xx_AF_system) |               \
1256
                                         PIN_AFIO_AF(GPIOH_PIN4, STM32F4xx_AF_system) |               \
1257
                                         PIN_AFIO_AF(GPIOH_PIN5, STM32F4xx_AF_system) |               \
1258
                                         PIN_AFIO_AF(GPIOH_PIN6, STM32F4xx_AF_system) |               \
1259
                                         PIN_AFIO_AF(GPIOH_PIN7, STM32F4xx_AF_system))
1260
#define VAL_GPIOH_AFRH                  (PIN_AFIO_AF(GPIOH_PIN8, STM32F4xx_AF_system) |               \
1261
                                         PIN_AFIO_AF(GPIOH_PIN9, STM32F4xx_AF_system) |               \
1262
                                         PIN_AFIO_AF(GPIOH_PIN10, STM32F4xx_AF_system) |              \
1263
                                         PIN_AFIO_AF(GPIOH_PIN11, STM32F4xx_AF_system) |              \
1264
                                         PIN_AFIO_AF(GPIOH_PIN12, STM32F4xx_AF_system) |              \
1265
                                         PIN_AFIO_AF(GPIOH_PIN13, STM32F4xx_AF_system) |              \
1266
                                         PIN_AFIO_AF(GPIOH_PIN14, STM32F4xx_AF_system) |              \
1267
                                         PIN_AFIO_AF(GPIOH_PIN15, STM32F4xx_AF_system))
1268
1269
/*
1270
 * GPIOI setup:
1271
 *
1272
 * PI0  - PIN0                          (input floating)
1273
 * PI1  - PIN1                          (input floating)
1274
 * PI2  - PIN2                          (input floating)
1275
 * PI3  - PIN3                          (input floating)
1276
 * PI4  - PIN4                          (input floating)
1277
 * PI5  - PIN5                          (input floating)
1278
 * PI6  - PIN6                          (input floating)
1279
 * PI7  - PIN7                          (input floating)
1280
 * PI8  - PIN8                          (input floating)
1281
 * PI9  - PIN9                          (input floating)
1282
 * PI10 - PIN10                         (input floating)
1283
 * PI11 - PIN11                         (input floating)
1284
 * PI12 - PIN12                         (input floating)
1285
 * PI13 - PIN13                         (input floating)
1286
 * PI14 - PIN14                         (input floating)
1287
 * PI15 - PIN15                         (input floating)
1288
 */
1289
#define VAL_GPIOI_MODER                 (PIN_MODE_INPUT(GPIOI_PIN0) |                                 \
1290
                                         PIN_MODE_INPUT(GPIOI_PIN1) |                                 \
1291
                                         PIN_MODE_INPUT(GPIOI_PIN2) |                                 \
1292
                                         PIN_MODE_INPUT(GPIOI_PIN3) |                                 \
1293
                                         PIN_MODE_INPUT(GPIOI_PIN4) |                                 \
1294
                                         PIN_MODE_INPUT(GPIOI_PIN5) |                                 \
1295
                                         PIN_MODE_INPUT(GPIOI_PIN6) |                                 \
1296
                                         PIN_MODE_INPUT(GPIOI_PIN7) |                                 \
1297
                                         PIN_MODE_INPUT(GPIOI_PIN8) |                                 \
1298
                                         PIN_MODE_INPUT(GPIOI_PIN9) |                                 \
1299
                                         PIN_MODE_INPUT(GPIOI_PIN10) |                                \
1300
                                         PIN_MODE_INPUT(GPIOI_PIN11) |                                \
1301
                                         PIN_MODE_INPUT(GPIOI_PIN12) |                                \
1302
                                         PIN_MODE_INPUT(GPIOI_PIN13) |                                \
1303
                                         PIN_MODE_INPUT(GPIOI_PIN14) |                                \
1304
                                         PIN_MODE_INPUT(GPIOI_PIN15))
1305
#define VAL_GPIOI_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) |                             \
1306
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN1) |                             \
1307
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN2) |                             \
1308
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN3) |                             \
1309
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN4) |                             \
1310
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN5) |                             \
1311
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN6) |                             \
1312
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN7) |                             \
1313
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN8) |                             \
1314
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN9) |                             \
1315
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN10) |                            \
1316
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN11) |                            \
1317
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN12) |                            \
1318
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN13) |                            \
1319
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN14) |                            \
1320
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN15))
1321
#define VAL_GPIOI_OSPEEDR               (PIN_OSPEED_LOW(GPIOI_PIN0) |                                 \
1322
                                         PIN_OSPEED_LOW(GPIOI_PIN1) |                                 \
1323
                                         PIN_OSPEED_LOW(GPIOI_PIN2) |                                 \
1324
                                         PIN_OSPEED_LOW(GPIOI_PIN3) |                                 \
1325
                                         PIN_OSPEED_LOW(GPIOI_PIN4) |                                 \
1326
                                         PIN_OSPEED_LOW(GPIOI_PIN5) |                                 \
1327
                                         PIN_OSPEED_LOW(GPIOI_PIN6) |                                 \
1328
                                         PIN_OSPEED_LOW(GPIOI_PIN7) |                                 \
1329
                                         PIN_OSPEED_LOW(GPIOI_PIN8) |                                 \
1330
                                         PIN_OSPEED_LOW(GPIOI_PIN9) |                                 \
1331
                                         PIN_OSPEED_LOW(GPIOI_PIN10) |                                \
1332
                                         PIN_OSPEED_LOW(GPIOI_PIN11) |                                \
1333
                                         PIN_OSPEED_LOW(GPIOI_PIN12) |                                \
1334
                                         PIN_OSPEED_LOW(GPIOI_PIN13) |                                \
1335
                                         PIN_OSPEED_LOW(GPIOI_PIN14) |                                \
1336
                                         PIN_OSPEED_LOW(GPIOI_PIN15))
1337
#define VAL_GPIOI_PUPDR                 (PIN_PUPDR_FLOATING(GPIOI_PIN0) |                             \
1338
                                         PIN_PUPDR_FLOATING(GPIOI_PIN1) |                             \
1339
                                         PIN_PUPDR_FLOATING(GPIOI_PIN2) |                             \
1340
                                         PIN_PUPDR_FLOATING(GPIOI_PIN3) |                             \
1341
                                         PIN_PUPDR_FLOATING(GPIOI_PIN4) |                             \
1342
                                         PIN_PUPDR_FLOATING(GPIOI_PIN5) |                             \
1343
                                         PIN_PUPDR_FLOATING(GPIOI_PIN6) |                             \
1344
                                         PIN_PUPDR_FLOATING(GPIOI_PIN7) |                             \
1345
                                         PIN_PUPDR_FLOATING(GPIOI_PIN8) |                             \
1346
                                         PIN_PUPDR_FLOATING(GPIOI_PIN9) |                             \
1347
                                         PIN_PUPDR_FLOATING(GPIOI_PIN10) |                            \
1348
                                         PIN_PUPDR_FLOATING(GPIOI_PIN11) |                            \
1349
                                         PIN_PUPDR_FLOATING(GPIOI_PIN12) |                            \
1350
                                         PIN_PUPDR_FLOATING(GPIOI_PIN13) |                            \
1351
                                         PIN_PUPDR_FLOATING(GPIOI_PIN14) |                            \
1352
                                         PIN_PUPDR_FLOATING(GPIOI_PIN15))
1353
#define VAL_GPIOI_ODR                   (PIN_ODR_LOW(GPIOI_PIN0) |                                    \
1354
                                         PIN_ODR_LOW(GPIOI_PIN1) |                                    \
1355
                                         PIN_ODR_LOW(GPIOI_PIN2) |                                    \
1356
                                         PIN_ODR_LOW(GPIOI_PIN3) |                                    \
1357
                                         PIN_ODR_LOW(GPIOI_PIN4) |                                    \
1358
                                         PIN_ODR_LOW(GPIOI_PIN5) |                                    \
1359
                                         PIN_ODR_LOW(GPIOI_PIN6) |                                    \
1360
                                         PIN_ODR_LOW(GPIOI_PIN7) |                                    \
1361
                                         PIN_ODR_LOW(GPIOI_PIN8) |                                    \
1362
                                         PIN_ODR_LOW(GPIOI_PIN9) |                                    \
1363
                                         PIN_ODR_LOW(GPIOI_PIN10) |                                   \
1364
                                         PIN_ODR_LOW(GPIOI_PIN11) |                                   \
1365
                                         PIN_ODR_LOW(GPIOI_PIN12) |                                   \
1366
                                         PIN_ODR_LOW(GPIOI_PIN13) |                                   \
1367
                                         PIN_ODR_LOW(GPIOI_PIN14) |                                   \
1368
                                         PIN_ODR_LOW(GPIOI_PIN15))
1369
#define VAL_GPIOI_AFRL                  (PIN_AFIO_AF(GPIOI_PIN0, STM32F4xx_AF_system) |               \
1370
                                         PIN_AFIO_AF(GPIOI_PIN1, STM32F4xx_AF_system) |               \
1371
                                         PIN_AFIO_AF(GPIOI_PIN2, STM32F4xx_AF_system) |               \
1372
                                         PIN_AFIO_AF(GPIOI_PIN3, STM32F4xx_AF_system) |               \
1373
                                         PIN_AFIO_AF(GPIOI_PIN4, STM32F4xx_AF_system) |               \
1374
                                         PIN_AFIO_AF(GPIOI_PIN5, STM32F4xx_AF_system) |               \
1375
                                         PIN_AFIO_AF(GPIOI_PIN6, STM32F4xx_AF_system) |               \
1376
                                         PIN_AFIO_AF(GPIOI_PIN7, STM32F4xx_AF_system))
1377
#define VAL_GPIOI_AFRH                  (PIN_AFIO_AF(GPIOI_PIN8, STM32F4xx_AF_system) |               \
1378
                                         PIN_AFIO_AF(GPIOI_PIN9, STM32F4xx_AF_system) |               \
1379
                                         PIN_AFIO_AF(GPIOI_PIN10, STM32F4xx_AF_system) |              \
1380
                                         PIN_AFIO_AF(GPIOI_PIN11, STM32F4xx_AF_system) |              \
1381
                                         PIN_AFIO_AF(GPIOI_PIN12, STM32F4xx_AF_system) |              \
1382
                                         PIN_AFIO_AF(GPIOI_PIN13, STM32F4xx_AF_system) |              \
1383
                                         PIN_AFIO_AF(GPIOI_PIN14, STM32F4xx_AF_system) |              \
1384
                                         PIN_AFIO_AF(GPIOI_PIN15, STM32F4xx_AF_system))
1385
1386
#if !defined(_FROM_ASM_)
1387
#ifdef __cplusplus
1388
extern "C" {
1389
#endif
1390
  void boardInit(void);
1391
#ifdef __cplusplus
1392
}
1393
#endif
1394
#endif /* _FROM_ASM_ */
1395
1396 6ff06bbf Thomas Schöpping
#endif /* BOARD_H */
1397 53710ca3 Marc Rothmann
1398
/** @} */