Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-2 / board.h @ c7dcc892

History | View | Annotate | Download (109.404 KB)

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

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
/**
20
 * @file
21
 * @brief   PowerManagement v1.2 Board specific macros.
22
 *
23
 * @addtogroup powermanagement_board
24
 * @{
25
 */
26

    
27
#ifndef BOARD_H
28
#define BOARD_H
29

    
30
/*
31
 * Setup for AMiRo PowerManagement v1.2 board.
32
 */
33

    
34
/*
35
 * Board identifier.
36
 */
37
#define BOARD_POWERMANAGEMENT_1_2
38
#define BOARD_NAME                      "AMiRo PowerManagement v1.2"
39

    
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
 * Identifiers for the several sensor rings, which can be attached to the PowerManagement v1.2 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
#define BOARD_SENSORRING                BOARD_PROXIMITYSENSOR
94

    
95
/*
96
 * IO pins assignments.
97
 */
98
#define GPIOA_WKUP                      0U
99
#define GPIOA_SWITCH_STATUS_N           1U
100
#define GPIOA_SYS_UART_TX               2U
101
#define GPIOA_SYS_UART_RX               3U
102
#define GPIOA_SYS_SPI_SS0_N             4U
103
#define GPIOA_SYS_SPI_SCLK              5U
104
#define GPIOA_SYS_SPI_MISO              6U
105
#define GPIOA_SYS_SPI_MOSI              7U
106
#define GPIOA_SYS_REG_EN                8U
107
#define GPIOA_PROG_RX                   9U
108
#define GPIOA_PROG_TX                   10U
109
#define GPIOA_CAN_RX                    11U
110
#define GPIOA_CAN_TX                    12U
111
#define GPIOA_SWDIO                     13U
112
#define GPIOA_SWCLK                     14U
113
#define GPIOA_SYS_SPI_SS1_N             15U
114

    
115
#define GPIOB_IR_INT1_N                 0U
116
#define GPIOB_VSYS_SENSE                1U
117
#define GPIOB_POWER_EN                  2U
118
#define GPIOB_SYS_UART_DN               3U
119
#define GPIOB_CHARGE_STAT2A             4U
120
#define GPIOB_BUZZER                    5U
121
#define GPIOB_GAUGE_BATLOW2             6U
122
#define GPIOB_GAUGE_BATGD2_N            7U
123
#define GPIOB_GAUGE_SCL2                8U
124
#define GPIOB_GAUGE_SDA2                9U
125
#define GPIOB_GAUGE_SCL1                10U
126
#define GPIOB_GAUGE_SDA1                11U
127
#define GPIOB_LED                       12U
128
#define GPIOB_BT_RTS                    13U
129
#define GPIOB_BT_CTS                    14U
130
#define GPIOB_SYS_UART_UP               15U
131

    
132
#define GPIOC_CHARGE_STAT1A             0U
133
#define GPIOC_GAUGE_BATLOW1             1U
134
#define GPIOC_GAUGE_BATGD1_N            2U
135
#define GPIOC_CHARGE_EN1_N              3U
136
#define GPIOC_IR_INT2_N                 4U
137
#define GPIOC_TOUCH_INT_N               5U
138
#define GPIOC_SYS_DONE                  6U
139
#define GPIOC_SYS_PROG_N                7U
140
#define GPIOC_PATH_DC                   8U
141
#define GPIOC_SYS_SPI_DIR               9U
142
#define GPIOC_BT_RX                     10U
143
#define GPIOC_BT_TX                     11U
144
#define GPIOC_SYS_INT_N                 12U
145
#define GPIOC_SYS_PD_N                  13U
146
#define GPIOC_SYS_WARMRST_N             14U
147
#define GPIOC_BT_RST                    15U
148

    
149
#define GPIOD_PIN0                      0U
150
#define GPIOD_PIN1                      1U
151
#define GPIOD_CHARGE_EN2_N              2U
152
#define GPIOD_PIN3                      3U
153
#define GPIOD_PIN4                      4U
154
#define GPIOD_PIN5                      5U
155
#define GPIOD_PIN6                      6U
156
#define GPIOD_PIN7                      7U
157
#define GPIOD_PIN8                      8U
158
#define GPIOD_PIN9                      9U
159
#define GPIOD_PIN10                     10U
160
#define GPIOD_PIN11                     11U
161
#define GPIOD_PIN12                     12U
162
#define GPIOD_PIN13                     13U
163
#define GPIOD_PIN14                     14U
164
#define GPIOD_PIN15                     15U
165

    
166
#define GPIOE_PIN0                      0U
167
#define GPIOE_PIN1                      1U
168
#define GPIOE_PIN2                      2U
169
#define GPIOE_PIN3                      3U
170
#define GPIOE_PIN4                      4U
171
#define GPIOE_PIN5                      5U
172
#define GPIOE_PIN6                      6U
173
#define GPIOE_PIN7                      7U
174
#define GPIOE_PIN8                      8U
175
#define GPIOE_PIN9                      9U
176
#define GPIOE_PIN10                     10U
177
#define GPIOE_PIN11                     11U
178
#define GPIOE_PIN12                     12U
179
#define GPIOE_PIN13                     13U
180
#define GPIOE_PIN14                     14U
181
#define GPIOE_PIN15                     15U
182

    
183
#define GPIOF_PIN0                      0U
184
#define GPIOF_PIN1                      1U
185
#define GPIOF_PIN2                      2U
186
#define GPIOF_PIN3                      3U
187
#define GPIOF_PIN4                      4U
188
#define GPIOF_PIN5                      5U
189
#define GPIOF_PIN6                      6U
190
#define GPIOF_PIN7                      7U
191
#define GPIOF_PIN8                      8U
192
#define GPIOF_PIN9                      9U
193
#define GPIOF_PIN10                     10U
194
#define GPIOF_PIN11                     11U
195
#define GPIOF_PIN12                     12U
196
#define GPIOF_PIN13                     13U
197
#define GPIOF_PIN14                     14U
198
#define GPIOF_PIN15                     15U
199

    
200
#define GPIOG_PIN0                      0U
201
#define GPIOG_PIN1                      1U
202
#define GPIOG_PIN2                      2U
203
#define GPIOG_PIN3                      3U
204
#define GPIOG_PIN4                      4U
205
#define GPIOG_PIN5                      5U
206
#define GPIOG_PIN6                      6U
207
#define GPIOG_PIN7                      7U
208
#define GPIOG_PIN8                      8U
209
#define GPIOG_PIN9                      9U
210
#define GPIOG_PIN10                     10U
211
#define GPIOG_PIN11                     11U
212
#define GPIOG_PIN12                     12U
213
#define GPIOG_PIN13                     13U
214
#define GPIOG_PIN14                     14U
215
#define GPIOG_PIN15                     15U
216

    
217
#define GPIOH_OSC_IN                    0U
218
#define GPIOH_OSC_OUT                   1U
219
#define GPIOH_PIN2                      2U
220
#define GPIOH_PIN3                      3U
221
#define GPIOH_PIN4                      4U
222
#define GPIOH_PIN5                      5U
223
#define GPIOH_PIN6                      6U
224
#define GPIOH_PIN7                      7U
225
#define GPIOH_PIN8                      8U
226
#define GPIOH_PIN9                      9U
227
#define GPIOH_PIN10                     10U
228
#define GPIOH_PIN11                     11U
229
#define GPIOH_PIN12                     12U
230
#define GPIOH_PIN13                     13U
231
#define GPIOH_PIN14                     14U
232
#define GPIOH_PIN15                     15U
233

    
234
#define GPIOI_PIN0                      0U
235
#define GPIOI_PIN1                      1U
236
#define GPIOI_PIN2                      2U
237
#define GPIOI_PIN3                      3U
238
#define GPIOI_PIN4                      4U
239
#define GPIOI_PIN5                      5U
240
#define GPIOI_PIN6                      6U
241
#define GPIOI_PIN7                      7U
242
#define GPIOI_PIN8                      8U
243
#define GPIOI_PIN9                      9U
244
#define GPIOI_PIN10                     10U
245
#define GPIOI_PIN11                     11U
246
#define GPIOI_PIN12                     12U
247
#define GPIOI_PIN13                     13U
248
#define GPIOI_PIN14                     14U
249
#define GPIOI_PIN15                     15U
250

    
251
/*
252
 * IO lines assignments.
253
 */
254
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
255
#define LINE_SWITCH_STATUS_N            PAL_LINE(GPIOA, GPIOA_SWITCH_STATUS_N)
256
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
257
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
258
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
259
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
260
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
261
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
262
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
263
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
264
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
265
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
266
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
267
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
268
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
269
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
270

    
271
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
272
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
273
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
274
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
275
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
276
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
277
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
278
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
279
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
280
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
281
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
282
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
283
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
284
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
285
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
286
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
287

    
288
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
289
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
290
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
291
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
292
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
293
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
294
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
295
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
296
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
297
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
298
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
299
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
300
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
301
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
302
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
303
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
304

    
305
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
306

    
307
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
308
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
309

    
310
/*
311
 * I/O ports initial setup, this configuration is established soon after reset
312
 * in the initialization code.
313
 * Please refer to the STM32 Reference Manual for details.
314
 */
315
#define PIN_IGNORE(n)                   (1U << (n))
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  - SWITCH_STATUS_N               (input floating)
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
 * PA12 - CAN_TX                        (alternate 9 pushpull floating)
349
 * 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_IGNORE                0
354
#define VAL_GPIOA_MODER                 (PIN_MODE_INPUT(GPIOA_WKUP) |                                 \
355
                                         PIN_MODE_INPUT(GPIOA_SWITCH_STATUS_N) |                      \
356
                                         PIN_MODE_INPUT(GPIOA_SYS_UART_TX) |                          \
357
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_UART_RX) |                      \
358
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS0_N) |                        \
359
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_SCLK) |                     \
360
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MISO) |                     \
361
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MOSI) |                     \
362
                                         PIN_MODE_OUTPUT(GPIOA_SYS_REG_EN) |                          \
363
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_RX) |                          \
364
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_TX) |                          \
365
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_RX) |                           \
366
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_TX) |                           \
367
                                         PIN_MODE_ALTERNATE(GPIOA_SWDIO) |                            \
368
                                         PIN_MODE_ALTERNATE(GPIOA_SWCLK) |                            \
369
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS1_N))
370
#define VAL_GPIOA_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOA_WKUP) |                             \
371
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWITCH_STATUS_N) |                  \
372
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_TX) |                      \
373
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_RX) |                      \
374
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS0_N) |                    \
375
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SCLK) |                     \
376
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MISO) |                     \
377
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MOSI) |                     \
378
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_REG_EN) |                       \
379
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_RX) |                          \
380
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_TX) |                          \
381
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_RX) |                           \
382
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_TX) |                           \
383
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) |                            \
384
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) |                            \
385
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS1_N))
386
#define VAL_GPIOA_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOA_WKUP) |                            \
387
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWITCH_STATUS_N) |                 \
388
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_TX) |                     \
389
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_RX) |                     \
390
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS0_N) |                   \
391
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SCLK) |                    \
392
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MISO) |                    \
393
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MOSI) |                    \
394
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_REG_EN) |                      \
395
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_RX) |                         \
396
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_TX) |                         \
397
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_RX) |                          \
398
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_TX) |                          \
399
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWDIO) |                           \
400
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWCLK) |                           \
401
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS1_N))
402
#define VAL_GPIOA_PUPDR                 (PIN_PUPDR_FLOATING(GPIOA_WKUP) |                             \
403
                                         PIN_PUPDR_FLOATING(GPIOA_SWITCH_STATUS_N) |                  \
404
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_TX) |                      \
405
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_RX) |                      \
406
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS0_N) |                    \
407
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SCLK) |                     \
408
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MISO) |                     \
409
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MOSI) |                     \
410
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_REG_EN) |                       \
411
                                         PIN_PUPDR_FLOATING(GPIOA_PROG_RX) |                          \
412
                                         PIN_PUPDR_PULLUP(GPIOA_PROG_TX) |                            \
413
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_RX) |                           \
414
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_TX) |                           \
415
                                         PIN_PUPDR_FLOATING(GPIOA_SWDIO) |                            \
416
                                         PIN_PUPDR_FLOATING(GPIOA_SWCLK) |                            \
417
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS1_N))
418
#define VAL_GPIOA_ODR                   (PIN_ODR_HIGH(GPIOA_WKUP) |                                   \
419
                                         PIN_ODR_HIGH(GPIOA_SWITCH_STATUS_N) |                        \
420
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_TX) |                            \
421
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_RX) |                            \
422
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS0_N) |                          \
423
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SCLK) |                           \
424
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MISO) |                           \
425
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MOSI) |                           \
426
                                         PIN_ODR_HIGH(GPIOA_SYS_REG_EN) |                             \
427
                                         PIN_ODR_HIGH(GPIOA_PROG_RX) |                                \
428
                                         PIN_ODR_HIGH(GPIOA_PROG_TX) |                                \
429
                                         PIN_ODR_HIGH(GPIOA_CAN_RX) |                                 \
430
                                         PIN_ODR_HIGH(GPIOA_CAN_TX) |                                 \
431
                                         PIN_ODR_HIGH(GPIOA_SWDIO) |                                  \
432
                                         PIN_ODR_HIGH(GPIOA_SWCLK) |                                  \
433
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS1_N))
434
#define VAL_GPIOA_AFRL                  (PIN_AFIO_AF(GPIOA_WKUP, STM32F4xx_AF_system) |               \
435
                                         PIN_AFIO_AF(GPIOA_SWITCH_STATUS_N, STM32F4xx_AF_system) |    \
436
                                         PIN_AFIO_AF(GPIOA_SYS_UART_TX, STM32F4xx_AF_USART1to3) |     \
437
                                         PIN_AFIO_AF(GPIOA_SYS_UART_RX, STM32F4xx_AF_USART1to3) |     \
438
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS0_N, STM32F4xx_AF_system) |      \
439
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SCLK, STM32F4xx_AF_SPI1to2) |      \
440
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MISO, STM32F4xx_AF_SPI1to2) |      \
441
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MOSI, STM32F4xx_AF_SPI1to2))
442
#define VAL_GPIOA_AFRH                  (PIN_AFIO_AF(GPIOA_SYS_REG_EN, STM32F4xx_AF_system) |         \
443
                                         PIN_AFIO_AF(GPIOA_PROG_RX, STM32F4xx_AF_USART1to3) |         \
444
                                         PIN_AFIO_AF(GPIOA_PROG_TX, STM32F4xx_AF_USART1to3) |         \
445
                                         PIN_AFIO_AF(GPIOA_CAN_RX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
446
                                         PIN_AFIO_AF(GPIOA_CAN_TX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
447
                                         PIN_AFIO_AF(GPIOA_SWDIO, STM32F4xx_AF_system) |              \
448
                                         PIN_AFIO_AF(GPIOA_SWCLK, STM32F4xx_AF_system) |              \
449
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS1_N, STM32F4xx_AF_system))
450

    
451
/*
452
 * GPIOB setup:
453
 *
454
 * PB0  - IR_INT1_N                     (input floating)
455
 * PB1  - VSYS_SENSE                    (analog)
456
 * PB2  - POWER_EN                      (output pushpull high)
457
 * PB3  - SYS_UART_DN                   (output opendrain high)
458
 * PB4  - CHARGE_STAT2A                 (inout floating)
459
 * PB5  - BUZZER                        (alternate 2 pushpull floating)
460
 * PB6  - GAUGE_BATLOW2                 (input floating)
461
 * PB7  - GAUGE_BATGD2_N                (input floating)
462
 * PB8  - GAUGE_SCL2                    (alternate 4 opendrain floating)
463
 * PB9  - GAUGE_SDA2                    (alternate 4 opendrain floating)
464
 * PB10 - GAUGE_SCL1                    (alternate 4 opendrain floating)
465
 * PB11 - GAUGE_SDA1                    (alternate 4 opendrain floating)
466
 * PB12 - LED                           (output opendrain high)
467
 * PB13 - BT_RTS                        (alternate 7 pushpull floating)
468
 * PB14 - BT_CTS                        (inout floating)
469
 * PB15 - SYS_UART_UP                   (output opendrain high)
470
 */
471
#define VAL_GPIOB_IGNORE                (PIN_IGNORE(GPIOB_POWER_EN) |                                 \
472
                                         PIN_IGNORE(GPIOB_SYS_UART_DN) |                              \
473
                                         PIN_IGNORE(GPIOB_LED) |                                      \
474
                                         PIN_IGNORE(GPIOB_SYS_UART_UP)) & 0
475
#define VAL_GPIOB_MODER                 (PIN_MODE_INPUT(GPIOB_IR_INT1_N) |                            \
476
                                         PIN_MODE_ANALOG(GPIOB_VSYS_SENSE) |                          \
477
                                         PIN_MODE_OUTPUT(GPIOB_POWER_EN) |                            \
478
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_DN) |                         \
479
                                         PIN_MODE_INPUT(GPIOB_CHARGE_STAT2A) |                        \
480
                                         PIN_MODE_ALTERNATE(GPIOB_BUZZER) |                           \
481
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATLOW2) |                        \
482
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATGD2_N) |                       \
483
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL2) |                       \
484
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA2) |                       \
485
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL1) |                       \
486
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA1) |                       \
487
                                         PIN_MODE_OUTPUT(GPIOB_LED) |                                 \
488
                                         PIN_MODE_ALTERNATE(GPIOB_BT_RTS) |                           \
489
                                         PIN_MODE_INPUT(GPIOB_BT_CTS) |                               \
490
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_UP))
491
#define VAL_GPIOB_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOB_IR_INT1_N) |                        \
492
                                         PIN_OTYPE_PUSHPULL(GPIOB_VSYS_SENSE) |                       \
493
                                         PIN_OTYPE_PUSHPULL(GPIOB_POWER_EN) |                         \
494
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_DN) |                     \
495
                                         PIN_OTYPE_PUSHPULL(GPIOB_CHARGE_STAT2A) |                    \
496
                                         PIN_OTYPE_PUSHPULL(GPIOB_BUZZER) |                           \
497
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATLOW2) |                    \
498
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATGD2_N) |                   \
499
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL2) |                      \
500
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA2) |                      \
501
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL1) |                      \
502
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA1) |                      \
503
                                         PIN_OTYPE_OPENDRAIN(GPIOB_LED) |                             \
504
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_RTS) |                           \
505
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_CTS) |                           \
506
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_UP))
507
#define VAL_GPIOB_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOB_IR_INT1_N) |                       \
508
                                         PIN_OSPEED_VERYHIGH(GPIOB_VSYS_SENSE) |                      \
509
                                         PIN_OSPEED_VERYHIGH(GPIOB_POWER_EN) |                        \
510
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_DN) |                     \
511
                                         PIN_OSPEED_VERYHIGH(GPIOB_CHARGE_STAT2A) |                   \
512
                                         PIN_OSPEED_VERYHIGH(GPIOB_BUZZER) |                          \
513
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATLOW2) |                   \
514
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATGD2_N) |                  \
515
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL2) |                      \
516
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA2) |                      \
517
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL1) |                      \
518
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA1) |                      \
519
                                         PIN_OSPEED_VERYHIGH(GPIOB_LED) |                             \
520
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_RTS) |                          \
521
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_CTS) |                          \
522
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_UP))
523
#define VAL_GPIOB_PUPDR                 (PIN_PUPDR_FLOATING(GPIOB_IR_INT1_N) |                        \
524
                                         PIN_PUPDR_FLOATING(GPIOB_VSYS_SENSE) |                       \
525
                                         PIN_PUPDR_FLOATING(GPIOB_POWER_EN) |                         \
526
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_DN) |                      \
527
                                         PIN_PUPDR_FLOATING(GPIOB_CHARGE_STAT2A) |                    \
528
                                         PIN_PUPDR_FLOATING(GPIOB_BUZZER) |                           \
529
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATLOW2) |                    \
530
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATGD2_N) |                   \
531
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL2) |                       \
532
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA2) |                       \
533
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL1) |                       \
534
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA1) |                       \
535
                                         PIN_PUPDR_FLOATING(GPIOB_LED) |                              \
536
                                         PIN_PUPDR_FLOATING(GPIOB_BT_RTS) |                           \
537
                                         PIN_PUPDR_FLOATING(GPIOB_BT_CTS) |                           \
538
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_UP))
539
#define VAL_GPIOB_ODR                   (PIN_ODR_HIGH(GPIOB_IR_INT1_N) |                              \
540
                                         PIN_ODR_HIGH(GPIOB_VSYS_SENSE) |                             \
541
                                         PIN_ODR_HIGH(GPIOB_POWER_EN) |                               \
542
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_DN) |                            \
543
                                         PIN_ODR_HIGH(GPIOB_CHARGE_STAT2A) |                          \
544
                                         PIN_ODR_HIGH(GPIOB_BUZZER) |                                 \
545
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATLOW2) |                          \
546
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATGD2_N) |                         \
547
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL2) |                             \
548
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA2) |                             \
549
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL1) |                             \
550
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA1) |                             \
551
                                         PIN_ODR_HIGH(GPIOB_LED) |                                    \
552
                                         PIN_ODR_HIGH(GPIOB_BT_RTS) |                                 \
553
                                         PIN_ODR_HIGH(GPIOB_BT_CTS) |                                 \
554
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_UP))
555
#define VAL_GPIOB_AFRL                  (PIN_AFIO_AF(GPIOB_IR_INT1_N, STM32F4xx_AF_system) |          \
556
                                         PIN_AFIO_AF(GPIOB_VSYS_SENSE, STM32F4xx_AF_system) |         \
557
                                         PIN_AFIO_AF(GPIOB_POWER_EN, STM32F4xx_AF_system) |           \
558
                                         PIN_AFIO_AF(GPIOB_SYS_UART_DN, STM32F4xx_AF_system) |        \
559
                                         PIN_AFIO_AF(GPIOB_CHARGE_STAT2A, STM32F4xx_AF_system) |      \
560
                                         PIN_AFIO_AF(GPIOB_BUZZER, STM32F4xx_AF_TIM3to5) |            \
561
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATLOW2, STM32F4xx_AF_system) |      \
562
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATGD2_N, STM32F4xx_AF_system))
563
#define VAL_GPIOB_AFRH                  (PIN_AFIO_AF(GPIOB_GAUGE_SCL2, STM32F4xx_AF_I2C1to3) |        \
564
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA2, STM32F4xx_AF_I2C1to3) |        \
565
                                         PIN_AFIO_AF(GPIOB_GAUGE_SCL1, STM32F4xx_AF_I2C1to3) |        \
566
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA1, STM32F4xx_AF_I2C1to3) |        \
567
                                         PIN_AFIO_AF(GPIOB_LED, STM32F4xx_AF_system) |                \
568
                                         PIN_AFIO_AF(GPIOB_BT_RTS, STM32F4xx_AF_USART1to3) |          \
569
                                         PIN_AFIO_AF(GPIOB_BT_CTS, STM32F4xx_AF_USART1to3) |          \
570
                                         PIN_AFIO_AF(GPIOB_SYS_UART_UP, STM32F4xx_AF_system))
571

    
572
/*
573
 * GPIOC setup:
574
 *
575
 * PC0  - CHARGE_STAT1A                 (input floating)
576
 * PC1  - GAUGE_BATLOW1                 (input floating)
577
 * PC2  - GAUGE_BATGD1_N                (input floating)
578
 * PC3  - CHARGE_EN1_N                  (output opendrain high)
579
 * PC4  - IR_INT2_N                     (input floating)
580
 * PC5  - TOUCH_INT_N                   (input floating)
581
 * PC6  - SYS_DONE                      (input floating)
582
 * PC7  - SYS_PROG_N                    (output opendrain high)
583
 * PC8  - PATH_DC                       (input floating)
584
 * PC9  - SYS_SPI_DIR                   (output opendrain high)
585
 * PC10 - BT_RX                         (alternate 7 pushpull floating)
586
 * PC11 - BT_TX                         (alternate 7 pushpull floating)
587
 * PC12 - SYS_INT_N                     (output opendrain low)
588
 * PC13 - SYS_PD_N                      (output opendrain high)
589
 * PC14 - SYS_WARMRST_N                 (output opendrain high)
590
 * PC15 - BT_RST                        (output opendrain high)
591
 */
592
#define VAL_GPIOC_IGNORE                (PIN_IGNORE(GPIOC_CHARGE_EN1_N) |                             \
593
                                         PIN_IGNORE(GPIOC_SYS_INT_N) |                                \
594
                                         PIN_IGNORE(GPIOC_SYS_PD_N)) & 0
595
#define VAL_GPIOC_MODER                 (PIN_MODE_INPUT(GPIOC_CHARGE_STAT1A) |                        \
596
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATLOW1) |                        \
597
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATGD1_N) |                       \
598
                                         PIN_MODE_OUTPUT(GPIOC_CHARGE_EN1_N) |                        \
599
                                         PIN_MODE_INPUT(GPIOC_IR_INT2_N) |                            \
600
                                         PIN_MODE_INPUT(GPIOC_TOUCH_INT_N) |                          \
601
                                         PIN_MODE_INPUT(GPIOC_SYS_DONE) |                             \
602
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PROG_N) |                          \
603
                                         PIN_MODE_INPUT(GPIOC_PATH_DC) |                              \
604
                                         PIN_MODE_OUTPUT(GPIOC_SYS_SPI_DIR) |                         \
605
                                         PIN_MODE_ALTERNATE(GPIOC_BT_RX) |                            \
606
                                         PIN_MODE_ALTERNATE(GPIOC_BT_TX) |                            \
607
                                         PIN_MODE_OUTPUT(GPIOC_SYS_INT_N) |                           \
608
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PD_N) |                            \
609
                                         PIN_MODE_OUTPUT(GPIOC_SYS_WARMRST_N) |                       \
610
                                         PIN_MODE_OUTPUT(GPIOC_BT_RST))
611
#define VAL_GPIOC_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOC_CHARGE_STAT1A) |                    \
612
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATLOW1) |                    \
613
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATGD1_N) |                   \
614
                                         PIN_OTYPE_OPENDRAIN(GPIOC_CHARGE_EN1_N) |                    \
615
                                         PIN_OTYPE_PUSHPULL(GPIOC_IR_INT2_N) |                        \
616
                                         PIN_OTYPE_PUSHPULL(GPIOC_TOUCH_INT_N) |                      \
617
                                         PIN_OTYPE_PUSHPULL(GPIOC_SYS_DONE) |                         \
618
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PROG_N) |                      \
619
                                         PIN_OTYPE_PUSHPULL(GPIOC_PATH_DC) |                          \
620
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_SPI_DIR) |                     \
621
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_RX) |                            \
622
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_TX) |                            \
623
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_INT_N) |                       \
624
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PD_N) |                        \
625
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_WARMRST_N) |                   \
626
                                         PIN_OTYPE_OPENDRAIN(GPIOC_BT_RST))
627
#define VAL_GPIOC_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_STAT1A) |                   \
628
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATLOW1) |                   \
629
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATGD1_N) |                  \
630
                                         PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_EN1_N) |                    \
631
                                         PIN_OSPEED_VERYHIGH(GPIOC_IR_INT2_N) |                       \
632
                                         PIN_OSPEED_VERYHIGH(GPIOC_TOUCH_INT_N) |                     \
633
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_DONE) |                        \
634
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PROG_N) |                      \
635
                                         PIN_OSPEED_VERYHIGH(GPIOC_PATH_DC) |                         \
636
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_SPI_DIR) |                     \
637
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RX) |                           \
638
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_TX) |                           \
639
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_INT_N) |                       \
640
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PD_N) |                        \
641
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_WARMRST_N) |                   \
642
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RST))
643
#define VAL_GPIOC_PUPDR                 (PIN_PUPDR_FLOATING(GPIOC_CHARGE_STAT1A) |                    \
644
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATLOW1) |                    \
645
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATGD1_N) |                   \
646
                                         PIN_PUPDR_FLOATING(GPIOC_CHARGE_EN1_N) |                     \
647
                                         PIN_PUPDR_FLOATING(GPIOC_IR_INT2_N) |                        \
648
                                         PIN_PUPDR_FLOATING(GPIOC_TOUCH_INT_N) |                      \
649
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_DONE) |                         \
650
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PROG_N) |                       \
651
                                         PIN_PUPDR_FLOATING(GPIOC_PATH_DC) |                          \
652
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_SPI_DIR) |                      \
653
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RX) |                            \
654
                                         PIN_PUPDR_FLOATING(GPIOC_BT_TX) |                            \
655
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_INT_N) |                        \
656
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PD_N) |                         \
657
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_WARMRST_N) |                    \
658
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RST))
659
#define VAL_GPIOC_ODR                   (PIN_ODR_HIGH(GPIOC_CHARGE_STAT1A) |                          \
660
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATLOW1) |                          \
661
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATGD1_N) |                         \
662
                                         PIN_ODR_HIGH(GPIOC_CHARGE_EN1_N) |                           \
663
                                         PIN_ODR_HIGH(GPIOC_IR_INT2_N) |                              \
664
                                         PIN_ODR_HIGH(GPIOC_TOUCH_INT_N) |                            \
665
                                         PIN_ODR_HIGH(GPIOC_SYS_DONE) |                               \
666
                                         PIN_ODR_HIGH(GPIOC_SYS_PROG_N) |                             \
667
                                         PIN_ODR_LOW(GPIOC_PATH_DC) |                                 \
668
                                         PIN_ODR_HIGH(GPIOC_SYS_SPI_DIR) |                            \
669
                                         PIN_ODR_HIGH(GPIOC_BT_RX) |                                  \
670
                                         PIN_ODR_HIGH(GPIOC_BT_TX) |                                  \
671
                                         PIN_ODR_LOW(GPIOC_SYS_INT_N) |                               \
672
                                         PIN_ODR_HIGH(GPIOC_SYS_PD_N) |                               \
673
                                         PIN_ODR_HIGH(GPIOC_SYS_WARMRST_N) |                          \
674
                                         PIN_ODR_HIGH(GPIOC_BT_RST))
675
#define VAL_GPIOC_AFRL                  (PIN_AFIO_AF(GPIOC_CHARGE_STAT1A, STM32F4xx_AF_system) |      \
676
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATLOW1, STM32F4xx_AF_system) |      \
677
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATGD1_N, STM32F4xx_AF_system) |     \
678
                                         PIN_AFIO_AF(GPIOC_CHARGE_EN1_N, STM32F4xx_AF_system) |       \
679
                                         PIN_AFIO_AF(GPIOC_IR_INT2_N, STM32F4xx_AF_system) |          \
680
                                         PIN_AFIO_AF(GPIOC_TOUCH_INT_N, STM32F4xx_AF_system) |        \
681
                                         PIN_AFIO_AF(GPIOC_SYS_DONE, STM32F4xx_AF_system) |           \
682
                                         PIN_AFIO_AF(GPIOC_SYS_PROG_N, STM32F4xx_AF_system))
683
#define VAL_GPIOC_AFRH                  (PIN_AFIO_AF(GPIOC_PATH_DC, STM32F4xx_AF_system) |            \
684
                                         PIN_AFIO_AF(GPIOC_SYS_SPI_DIR, STM32F4xx_AF_system) |        \
685
                                         PIN_AFIO_AF(GPIOC_BT_RX, STM32F4xx_AF_USART1to3) |           \
686
                                         PIN_AFIO_AF(GPIOC_BT_TX, STM32F4xx_AF_USART1to3) |           \
687
                                         PIN_AFIO_AF(GPIOC_SYS_INT_N, STM32F4xx_AF_system) |          \
688
                                         PIN_AFIO_AF(GPIOC_SYS_PD_N, STM32F4xx_AF_system) |           \
689
                                         PIN_AFIO_AF(GPIOC_SYS_WARMRST_N, STM32F4xx_AF_system) |      \
690
                                         PIN_AFIO_AF(GPIOC_BT_RST, STM32F4xx_AF_system))
691

    
692
/*
693
 * GPIOD setup:
694
 *
695
 * PD0  - PIN0                          (input floating)
696
 * PD1  - PIN1                          (input floating)
697
 * PD2  - CHARGE_EN2_N                  (output opendrain high)
698
 * PD3  - PIN3                          (input floating)
699
 * PD4  - PIN4                          (input floating)
700
 * PD5  - PIN5                          (input floating)
701
 * PD6  - PIN6                          (input floating)
702
 * PD7  - PIN7                          (input floating)
703
 * PD8  - PIN8                          (input floating)
704
 * PD9  - PIN9                          (input floating)
705
 * PD10 - PIN10                         (input floating)
706
 * PD11 - PIN11                         (input floating)
707
 * PD12 - PIN12                         (input floating)
708
 * PD13 - PIN13                         (input floating)
709
 * PD14 - PIN14                         (input floating)
710
 * PD15 - PIN15                         (input floating)
711
 */
712
#define VAL_GPIOD_IGNORE                (PIN_IGNORE(GPIOD_CHARGE_EN2_N)) & 0
713
#define VAL_GPIOD_MODER                 (PIN_MODE_INPUT(GPIOD_PIN0) |                                 \
714
                                         PIN_MODE_INPUT(GPIOD_PIN1) |                                 \
715
                                         PIN_MODE_OUTPUT(GPIOD_CHARGE_EN2_N) |                        \
716
                                         PIN_MODE_INPUT(GPIOD_PIN3) |                                 \
717
                                         PIN_MODE_INPUT(GPIOD_PIN4) |                                 \
718
                                         PIN_MODE_INPUT(GPIOD_PIN5) |                                 \
719
                                         PIN_MODE_INPUT(GPIOD_PIN6) |                                 \
720
                                         PIN_MODE_INPUT(GPIOD_PIN7) |                                 \
721
                                         PIN_MODE_INPUT(GPIOD_PIN8) |                                 \
722
                                         PIN_MODE_INPUT(GPIOD_PIN9) |                                 \
723
                                         PIN_MODE_INPUT(GPIOD_PIN10) |                                \
724
                                         PIN_MODE_INPUT(GPIOD_PIN11) |                                \
725
                                         PIN_MODE_INPUT(GPIOD_PIN12) |                                \
726
                                         PIN_MODE_INPUT(GPIOD_PIN13) |                                \
727
                                         PIN_MODE_INPUT(GPIOD_PIN14) |                                \
728
                                         PIN_MODE_INPUT(GPIOD_PIN15))
729
#define VAL_GPIOD_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) |                             \
730
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN1) |                             \
731
                                         PIN_OTYPE_OPENDRAIN(GPIOD_CHARGE_EN2_N) |                    \
732
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN3) |                             \
733
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN4) |                             \
734
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN5) |                             \
735
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN6) |                             \
736
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN7) |                             \
737
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN8) |                             \
738
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN9) |                             \
739
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN10) |                            \
740
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN11) |                            \
741
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN12) |                            \
742
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN13) |                            \
743
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN14) |                            \
744
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
745
#define VAL_GPIOD_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOD_PIN0) |                            \
746
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN1) |                            \
747
                                         PIN_OSPEED_VERYHIGH(GPIOD_CHARGE_EN2_N) |                    \
748
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN3) |                            \
749
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN4) |                            \
750
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN5) |                            \
751
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN6) |                            \
752
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN7) |                            \
753
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN8) |                            \
754
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN9) |                            \
755
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN10) |                           \
756
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN11) |                           \
757
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN12) |                           \
758
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN13) |                           \
759
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN14) |                           \
760
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN15))
761
#define VAL_GPIOD_PUPDR                 (PIN_PUPDR_PULLUP(GPIOD_PIN0) |                               \
762
                                         PIN_PUPDR_PULLUP(GPIOD_PIN1) |                               \
763
                                         PIN_PUPDR_FLOATING(GPIOD_CHARGE_EN2_N) |                     \
764
                                         PIN_PUPDR_PULLUP(GPIOD_PIN3) |                               \
765
                                         PIN_PUPDR_PULLUP(GPIOD_PIN4) |                               \
766
                                         PIN_PUPDR_PULLUP(GPIOD_PIN5) |                               \
767
                                         PIN_PUPDR_PULLUP(GPIOD_PIN6) |                               \
768
                                         PIN_PUPDR_PULLUP(GPIOD_PIN7) |                               \
769
                                         PIN_PUPDR_PULLUP(GPIOD_PIN8) |                               \
770
                                         PIN_PUPDR_PULLUP(GPIOD_PIN9) |                               \
771
                                         PIN_PUPDR_PULLUP(GPIOD_PIN10) |                              \
772
                                         PIN_PUPDR_PULLUP(GPIOD_PIN11) |                              \
773
                                         PIN_PUPDR_PULLUP(GPIOD_PIN12) |                              \
774
                                         PIN_PUPDR_PULLUP(GPIOD_PIN13) |                              \
775
                                         PIN_PUPDR_PULLUP(GPIOD_PIN14) |                              \
776
                                         PIN_PUPDR_PULLUP(GPIOD_PIN15))
777
#define VAL_GPIOD_ODR                   (PIN_ODR_HIGH(GPIOD_PIN0) |                                   \
778
                                         PIN_ODR_HIGH(GPIOD_PIN1) |                                   \
779
                                         PIN_ODR_HIGH(GPIOD_CHARGE_EN2_N) |                           \
780
                                         PIN_ODR_HIGH(GPIOD_PIN3) |                                   \
781
                                         PIN_ODR_HIGH(GPIOD_PIN4) |                                   \
782
                                         PIN_ODR_HIGH(GPIOD_PIN5) |                                   \
783
                                         PIN_ODR_HIGH(GPIOD_PIN6) |                                   \
784
                                         PIN_ODR_HIGH(GPIOD_PIN7) |                                   \
785
                                         PIN_ODR_HIGH(GPIOD_PIN8) |                                   \
786
                                         PIN_ODR_HIGH(GPIOD_PIN9) |                                   \
787
                                         PIN_ODR_HIGH(GPIOD_PIN10) |                                  \
788
                                         PIN_ODR_HIGH(GPIOD_PIN11) |                                  \
789
                                         PIN_ODR_HIGH(GPIOD_PIN12) |                                  \
790
                                         PIN_ODR_HIGH(GPIOD_PIN13) |                                  \
791
                                         PIN_ODR_HIGH(GPIOD_PIN14) |                                  \
792
                                         PIN_ODR_HIGH(GPIOD_PIN15))
793
#define VAL_GPIOD_AFRL                  (PIN_AFIO_AF(GPIOD_PIN0, STM32F4xx_AF_system) |               \
794
                                         PIN_AFIO_AF(GPIOD_PIN1, STM32F4xx_AF_system) |               \
795
                                         PIN_AFIO_AF(GPIOD_CHARGE_EN2_N, STM32F4xx_AF_system) |       \
796
                                         PIN_AFIO_AF(GPIOD_PIN3, STM32F4xx_AF_system) |               \
797
                                         PIN_AFIO_AF(GPIOD_PIN4, STM32F4xx_AF_system) |               \
798
                                         PIN_AFIO_AF(GPIOD_PIN5, STM32F4xx_AF_system) |               \
799
                                         PIN_AFIO_AF(GPIOD_PIN6, STM32F4xx_AF_system) |               \
800
                                         PIN_AFIO_AF(GPIOD_PIN7, STM32F4xx_AF_system))
801
#define VAL_GPIOD_AFRH                  (PIN_AFIO_AF(GPIOD_PIN8, STM32F4xx_AF_system) |               \
802
                                         PIN_AFIO_AF(GPIOD_PIN9, STM32F4xx_AF_system) |               \
803
                                         PIN_AFIO_AF(GPIOD_PIN10, STM32F4xx_AF_system) |              \
804
                                         PIN_AFIO_AF(GPIOD_PIN11, STM32F4xx_AF_system) |              \
805
                                         PIN_AFIO_AF(GPIOD_PIN12, STM32F4xx_AF_system) |              \
806
                                         PIN_AFIO_AF(GPIOD_PIN13, STM32F4xx_AF_system) |              \
807
                                         PIN_AFIO_AF(GPIOD_PIN14, STM32F4xx_AF_system) |              \
808
                                         PIN_AFIO_AF(GPIOD_PIN15, STM32F4xx_AF_system))
809

    
810
/*
811
 * GPIOE setup:
812
 *
813
 * PE0  - PIN0                          (input floating)
814
 * PE1  - PIN1                          (input floating)
815
 * PE2  - PIN2                          (input floating)
816
 * PE3  - PIN3                          (input floating)
817
 * PE4  - PIN4                          (input floating)
818
 * PE5  - PIN5                          (input floating)
819
 * PE6  - PIN6                          (input floating)
820
 * PE7  - PIN7                          (input floating)
821
 * PE8  - PIN8                          (input floating)
822
 * PE9  - PIN9                          (input floating)
823
 * PE10 - PIN10                         (input floating)
824
 * PE11 - PIN11                         (input floating)
825
 * PE12 - PIN12                         (input floating)
826
 * PE13 - PIN13                         (input floating)
827
 * PE14 - PIN14                         (input floating)
828
 * PE15 - PIN15                         (input floating)
829
 */
830
#define VAL_GPIOE_IGNORE                0
831
#define VAL_GPIOE_MODER                 (PIN_MODE_INPUT(GPIOE_PIN0) |                                 \
832
                                         PIN_MODE_INPUT(GPIOE_PIN1) |                                 \
833
                                         PIN_MODE_INPUT(GPIOE_PIN2) |                                 \
834
                                         PIN_MODE_INPUT(GPIOE_PIN3) |                                 \
835
                                         PIN_MODE_INPUT(GPIOE_PIN4) |                                 \
836
                                         PIN_MODE_INPUT(GPIOE_PIN5) |                                 \
837
                                         PIN_MODE_INPUT(GPIOE_PIN6) |                                 \
838
                                         PIN_MODE_INPUT(GPIOE_PIN7) |                                 \
839
                                         PIN_MODE_INPUT(GPIOE_PIN8) |                                 \
840
                                         PIN_MODE_INPUT(GPIOE_PIN9) |                                 \
841
                                         PIN_MODE_INPUT(GPIOE_PIN10) |                                \
842
                                         PIN_MODE_INPUT(GPIOE_PIN11) |                                \
843
                                         PIN_MODE_INPUT(GPIOE_PIN12) |                                \
844
                                         PIN_MODE_INPUT(GPIOE_PIN13) |                                \
845
                                         PIN_MODE_INPUT(GPIOE_PIN14) |                                \
846
                                         PIN_MODE_INPUT(GPIOE_PIN15))
847
#define VAL_GPIOE_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) |                             \
848
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN1) |                             \
849
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN2) |                             \
850
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN3) |                             \
851
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN4) |                             \
852
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN5) |                             \
853
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN6) |                             \
854
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN7) |                             \
855
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN8) |                             \
856
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN9) |                             \
857
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN10) |                            \
858
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN11) |                            \
859
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN12) |                            \
860
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN13) |                            \
861
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN14) |                            \
862
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
863
#define VAL_GPIOE_OSPEEDR               (PIN_OSPEED_LOW(GPIOE_PIN0) |                                 \
864
                                         PIN_OSPEED_LOW(GPIOE_PIN1) |                                 \
865
                                         PIN_OSPEED_LOW(GPIOE_PIN2) |                                 \
866
                                         PIN_OSPEED_LOW(GPIOE_PIN3) |                                 \
867
                                         PIN_OSPEED_LOW(GPIOE_PIN4) |                                 \
868
                                         PIN_OSPEED_LOW(GPIOE_PIN5) |                                 \
869
                                         PIN_OSPEED_LOW(GPIOE_PIN6) |                                 \
870
                                         PIN_OSPEED_LOW(GPIOE_PIN7) |                                 \
871
                                         PIN_OSPEED_LOW(GPIOE_PIN8) |                                 \
872
                                         PIN_OSPEED_LOW(GPIOE_PIN9) |                                 \
873
                                         PIN_OSPEED_LOW(GPIOE_PIN10) |                                \
874
                                         PIN_OSPEED_LOW(GPIOE_PIN11) |                                \
875
                                         PIN_OSPEED_LOW(GPIOE_PIN12) |                                \
876
                                         PIN_OSPEED_LOW(GPIOE_PIN13) |                                \
877
                                         PIN_OSPEED_LOW(GPIOE_PIN14) |                                \
878
                                         PIN_OSPEED_LOW(GPIOE_PIN15))
879
#define VAL_GPIOE_PUPDR                 (PIN_PUPDR_FLOATING(GPIOE_PIN0) |                             \
880
                                         PIN_PUPDR_FLOATING(GPIOE_PIN1) |                             \
881
                                         PIN_PUPDR_FLOATING(GPIOE_PIN2) |                             \
882
                                         PIN_PUPDR_FLOATING(GPIOE_PIN3) |                             \
883
                                         PIN_PUPDR_FLOATING(GPIOE_PIN4) |                             \
884
                                         PIN_PUPDR_FLOATING(GPIOE_PIN5) |                             \
885
                                         PIN_PUPDR_FLOATING(GPIOE_PIN6) |                             \
886
                                         PIN_PUPDR_FLOATING(GPIOE_PIN7) |                             \
887
                                         PIN_PUPDR_FLOATING(GPIOE_PIN8) |                             \
888
                                         PIN_PUPDR_FLOATING(GPIOE_PIN9) |                             \
889
                                         PIN_PUPDR_FLOATING(GPIOE_PIN10) |                            \
890
                                         PIN_PUPDR_FLOATING(GPIOE_PIN11) |                            \
891
                                         PIN_PUPDR_FLOATING(GPIOE_PIN12) |                            \
892
                                         PIN_PUPDR_FLOATING(GPIOE_PIN13) |                            \
893
                                         PIN_PUPDR_FLOATING(GPIOE_PIN14) |                            \
894
                                         PIN_PUPDR_FLOATING(GPIOE_PIN15))
895
#define VAL_GPIOE_ODR                   (PIN_ODR_LOW(GPIOE_PIN0) |                                    \
896
                                         PIN_ODR_LOW(GPIOE_PIN1) |                                    \
897
                                         PIN_ODR_LOW(GPIOE_PIN2) |                                    \
898
                                         PIN_ODR_LOW(GPIOE_PIN3) |                                    \
899
                                         PIN_ODR_LOW(GPIOE_PIN4) |                                    \
900
                                         PIN_ODR_LOW(GPIOE_PIN5) |                                    \
901
                                         PIN_ODR_LOW(GPIOE_PIN6) |                                    \
902
                                         PIN_ODR_LOW(GPIOE_PIN7) |                                    \
903
                                         PIN_ODR_LOW(GPIOE_PIN8) |                                    \
904
                                         PIN_ODR_LOW(GPIOE_PIN9) |                                    \
905
                                         PIN_ODR_LOW(GPIOE_PIN10) |                                   \
906
                                         PIN_ODR_LOW(GPIOE_PIN11) |                                   \
907
                                         PIN_ODR_LOW(GPIOE_PIN12) |                                   \
908
                                         PIN_ODR_LOW(GPIOE_PIN13) |                                   \
909
                                         PIN_ODR_LOW(GPIOE_PIN14) |                                   \
910
                                         PIN_ODR_LOW(GPIOE_PIN15))
911
#define VAL_GPIOE_AFRL                  (PIN_AFIO_AF(GPIOE_PIN0, STM32F4xx_AF_system) |               \
912
                                         PIN_AFIO_AF(GPIOE_PIN1, STM32F4xx_AF_system) |               \
913
                                         PIN_AFIO_AF(GPIOE_PIN2, STM32F4xx_AF_system) |               \
914
                                         PIN_AFIO_AF(GPIOE_PIN3, STM32F4xx_AF_system) |               \
915
                                         PIN_AFIO_AF(GPIOE_PIN4, STM32F4xx_AF_system) |               \
916
                                         PIN_AFIO_AF(GPIOE_PIN5, STM32F4xx_AF_system) |               \
917
                                         PIN_AFIO_AF(GPIOE_PIN6, STM32F4xx_AF_system) |               \
918
                                         PIN_AFIO_AF(GPIOE_PIN7, STM32F4xx_AF_system))
919
#define VAL_GPIOE_AFRH                  (PIN_AFIO_AF(GPIOE_PIN8, STM32F4xx_AF_system) |               \
920
                                         PIN_AFIO_AF(GPIOE_PIN9, STM32F4xx_AF_system) |               \
921
                                         PIN_AFIO_AF(GPIOE_PIN10, STM32F4xx_AF_system) |              \
922
                                         PIN_AFIO_AF(GPIOE_PIN11, STM32F4xx_AF_system) |              \
923
                                         PIN_AFIO_AF(GPIOE_PIN12, STM32F4xx_AF_system) |              \
924
                                         PIN_AFIO_AF(GPIOE_PIN13, STM32F4xx_AF_system) |              \
925
                                         PIN_AFIO_AF(GPIOE_PIN14, STM32F4xx_AF_system) |              \
926
                                         PIN_AFIO_AF(GPIOE_PIN15, STM32F4xx_AF_system))
927

    
928
/*
929
 * GPIOF setup:
930
 *
931
 * PF0  - PIN0                          (input floating)
932
 * PF1  - PIN1                          (input floating)
933
 * PF2  - PIN2                          (input floating)
934
 * PF3  - PIN3                          (input floating)
935
 * PF4  - PIN4                          (input floating)
936
 * PF5  - PIN5                          (input floating)
937
 * PF6  - PIN6                          (input floating)
938
 * PF7  - PIN7                          (input floating)
939
 * PF8  - PIN8                          (input floating)
940
 * PF9  - PIN9                          (input floating)
941
 * PF10 - PIN10                         (input floating)
942
 * PF11 - PIN11                         (input floating)
943
 * PF12 - PIN12                         (input floating)
944
 * PF13 - PIN13                         (input floating)
945
 * PF14 - PIN14                         (input floating)
946
 * PF15 - PIN15                         (input floating)
947
 */
948
#define VAL_GPIOF_IGNORE                0
949
#define VAL_GPIOF_MODER                 (PIN_MODE_INPUT(GPIOF_PIN0) |                                 \
950
                                         PIN_MODE_INPUT(GPIOF_PIN1) |                                 \
951
                                         PIN_MODE_INPUT(GPIOF_PIN2) |                                 \
952
                                         PIN_MODE_INPUT(GPIOF_PIN3) |                                 \
953
                                         PIN_MODE_INPUT(GPIOF_PIN4) |                                 \
954
                                         PIN_MODE_INPUT(GPIOF_PIN5) |                                 \
955
                                         PIN_MODE_INPUT(GPIOF_PIN6) |                                 \
956
                                         PIN_MODE_INPUT(GPIOF_PIN7) |                                 \
957
                                         PIN_MODE_INPUT(GPIOF_PIN8) |                                 \
958
                                         PIN_MODE_INPUT(GPIOF_PIN9) |                                 \
959
                                         PIN_MODE_INPUT(GPIOF_PIN10) |                                \
960
                                         PIN_MODE_INPUT(GPIOF_PIN11) |                                \
961
                                         PIN_MODE_INPUT(GPIOF_PIN12) |                                \
962
                                         PIN_MODE_INPUT(GPIOF_PIN13) |                                \
963
                                         PIN_MODE_INPUT(GPIOF_PIN14) |                                \
964
                                         PIN_MODE_INPUT(GPIOF_PIN15))
965
#define VAL_GPIOF_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) |                             \
966
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN1) |                             \
967
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN2) |                             \
968
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN3) |                             \
969
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN4) |                             \
970
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN5) |                             \
971
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN6) |                             \
972
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN7) |                             \
973
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN8) |                             \
974
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN9) |                             \
975
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN10) |                            \
976
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN11) |                            \
977
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN12) |                            \
978
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN13) |                            \
979
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN14) |                            \
980
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
981
#define VAL_GPIOF_OSPEEDR               (PIN_OSPEED_LOW(GPIOF_PIN0) |                                 \
982
                                         PIN_OSPEED_LOW(GPIOF_PIN1) |                                 \
983
                                         PIN_OSPEED_LOW(GPIOF_PIN2) |                                 \
984
                                         PIN_OSPEED_LOW(GPIOF_PIN3) |                                 \
985
                                         PIN_OSPEED_LOW(GPIOF_PIN4) |                                 \
986
                                         PIN_OSPEED_LOW(GPIOF_PIN5) |                                 \
987
                                         PIN_OSPEED_LOW(GPIOF_PIN6) |                                 \
988
                                         PIN_OSPEED_LOW(GPIOF_PIN7) |                                 \
989
                                         PIN_OSPEED_LOW(GPIOF_PIN8) |                                 \
990
                                         PIN_OSPEED_LOW(GPIOF_PIN9) |                                 \
991
                                         PIN_OSPEED_LOW(GPIOF_PIN10) |                                \
992
                                         PIN_OSPEED_LOW(GPIOF_PIN11) |                                \
993
                                         PIN_OSPEED_LOW(GPIOF_PIN12) |                                \
994
                                         PIN_OSPEED_LOW(GPIOF_PIN13) |                                \
995
                                         PIN_OSPEED_LOW(GPIOF_PIN14) |                                \
996
                                         PIN_OSPEED_LOW(GPIOF_PIN15))
997
#define VAL_GPIOF_PUPDR                 (PIN_PUPDR_FLOATING(GPIOF_PIN0) |                             \
998
                                         PIN_PUPDR_FLOATING(GPIOF_PIN1) |                             \
999
                                         PIN_PUPDR_FLOATING(GPIOF_PIN2) |                             \
1000
                                         PIN_PUPDR_FLOATING(GPIOF_PIN3) |                             \
1001
                                         PIN_PUPDR_FLOATING(GPIOF_PIN4) |                             \
1002
                                         PIN_PUPDR_FLOATING(GPIOF_PIN5) |                             \
1003
                                         PIN_PUPDR_FLOATING(GPIOF_PIN6) |                             \
1004
                                         PIN_PUPDR_FLOATING(GPIOF_PIN7) |                             \
1005
                                         PIN_PUPDR_FLOATING(GPIOF_PIN8) |                             \
1006
                                         PIN_PUPDR_FLOATING(GPIOF_PIN9) |                             \
1007
                                         PIN_PUPDR_FLOATING(GPIOF_PIN10) |                            \
1008
                                         PIN_PUPDR_FLOATING(GPIOF_PIN11) |                            \
1009
                                         PIN_PUPDR_FLOATING(GPIOF_PIN12) |                            \
1010
                                         PIN_PUPDR_FLOATING(GPIOF_PIN13) |                            \
1011
                                         PIN_PUPDR_FLOATING(GPIOF_PIN14) |                            \
1012
                                         PIN_PUPDR_FLOATING(GPIOF_PIN15))
1013
#define VAL_GPIOF_ODR                   (PIN_ODR_LOW(GPIOF_PIN0) |                                    \
1014
                                         PIN_ODR_LOW(GPIOF_PIN1) |                                    \
1015
                                         PIN_ODR_LOW(GPIOF_PIN2) |                                    \
1016
                                         PIN_ODR_LOW(GPIOF_PIN3) |                                    \
1017
                                         PIN_ODR_LOW(GPIOF_PIN4) |                                    \
1018
                                         PIN_ODR_LOW(GPIOF_PIN5) |                                    \
1019
                                         PIN_ODR_LOW(GPIOF_PIN6) |                                    \
1020
                                         PIN_ODR_LOW(GPIOF_PIN7) |                                    \
1021
                                         PIN_ODR_LOW(GPIOF_PIN8) |                                    \
1022
                                         PIN_ODR_LOW(GPIOF_PIN9) |                                    \
1023
                                         PIN_ODR_LOW(GPIOF_PIN10) |                                   \
1024
                                         PIN_ODR_LOW(GPIOF_PIN11) |                                   \
1025
                                         PIN_ODR_LOW(GPIOF_PIN12) |                                   \
1026
                                         PIN_ODR_LOW(GPIOF_PIN13) |                                   \
1027
                                         PIN_ODR_LOW(GPIOF_PIN14) |                                   \
1028
                                         PIN_ODR_LOW(GPIOF_PIN15))
1029
#define VAL_GPIOF_AFRL                  (PIN_AFIO_AF(GPIOF_PIN0, STM32F4xx_AF_system) |               \
1030
                                         PIN_AFIO_AF(GPIOF_PIN1, STM32F4xx_AF_system) |               \
1031
                                         PIN_AFIO_AF(GPIOF_PIN2, STM32F4xx_AF_system) |               \
1032
                                         PIN_AFIO_AF(GPIOF_PIN3, STM32F4xx_AF_system) |               \
1033
                                         PIN_AFIO_AF(GPIOF_PIN4, STM32F4xx_AF_system) |               \
1034
                                         PIN_AFIO_AF(GPIOF_PIN5, STM32F4xx_AF_system) |               \
1035
                                         PIN_AFIO_AF(GPIOF_PIN6, STM32F4xx_AF_system) |               \
1036
                                         PIN_AFIO_AF(GPIOF_PIN7, STM32F4xx_AF_system))
1037
#define VAL_GPIOF_AFRH                  (PIN_AFIO_AF(GPIOF_PIN8, STM32F4xx_AF_system) |               \
1038
                                         PIN_AFIO_AF(GPIOF_PIN9, STM32F4xx_AF_system) |               \
1039
                                         PIN_AFIO_AF(GPIOF_PIN10, STM32F4xx_AF_system) |              \
1040
                                         PIN_AFIO_AF(GPIOF_PIN11, STM32F4xx_AF_system) |              \
1041
                                         PIN_AFIO_AF(GPIOF_PIN12, STM32F4xx_AF_system) |              \
1042
                                         PIN_AFIO_AF(GPIOF_PIN13, STM32F4xx_AF_system) |              \
1043
                                         PIN_AFIO_AF(GPIOF_PIN14, STM32F4xx_AF_system) |              \
1044
                                         PIN_AFIO_AF(GPIOF_PIN15, STM32F4xx_AF_system))
1045

    
1046
/*
1047
 * GPIOG setup:
1048
 *
1049
 * PG0  - PIN0                          (input floating)
1050
 * PG1  - PIN1                          (input floating)
1051
 * PG2  - PIN2                          (input floating)
1052
 * PG3  - PIN3                          (input floating)
1053
 * PG4  - PIN4                          (input floating)
1054
 * PG5  - PIN5                          (input floating)
1055
 * PG6  - PIN6                          (input floating)
1056
 * PG7  - PIN7                          (input floating)
1057
 * PG8  - PIN8                          (input floating)
1058
 * PG9  - PIN9                          (input floating)
1059
 * PG10 - PIN10                         (input floating)
1060
 * PG11 - PIN11                         (input floating)
1061
 * PG12 - PIN12                         (input floating)
1062
 * PG13 - PIN13                         (input floating)
1063
 * PG14 - PIN14                         (input floating)
1064
 * PG15 - PIN15                         (input floating)
1065
 */
1066
#define VAL_GPIOG_IGNORE                0
1067
#define VAL_GPIOG_MODER                 (PIN_MODE_INPUT(GPIOG_PIN0) |                                 \
1068
                                         PIN_MODE_INPUT(GPIOG_PIN1) |                                 \
1069
                                         PIN_MODE_INPUT(GPIOG_PIN2) |                                 \
1070
                                         PIN_MODE_INPUT(GPIOG_PIN3) |                                 \
1071
                                         PIN_MODE_INPUT(GPIOG_PIN4) |                                 \
1072
                                         PIN_MODE_INPUT(GPIOG_PIN5) |                                 \
1073
                                         PIN_MODE_INPUT(GPIOG_PIN6) |                                 \
1074
                                         PIN_MODE_INPUT(GPIOG_PIN7) |                                 \
1075
                                         PIN_MODE_INPUT(GPIOG_PIN8) |                                 \
1076
                                         PIN_MODE_INPUT(GPIOG_PIN9) |                                 \
1077
                                         PIN_MODE_INPUT(GPIOG_PIN10) |                                \
1078
                                         PIN_MODE_INPUT(GPIOG_PIN11) |                                \
1079
                                         PIN_MODE_INPUT(GPIOG_PIN12) |                                \
1080
                                         PIN_MODE_INPUT(GPIOG_PIN13) |                                \
1081
                                         PIN_MODE_INPUT(GPIOG_PIN14) |                                \
1082
                                         PIN_MODE_INPUT(GPIOG_PIN15))
1083
#define VAL_GPIOG_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) |                             \
1084
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN1) |                             \
1085
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN2) |                             \
1086
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN3) |                             \
1087
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN4) |                             \
1088
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN5) |                             \
1089
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN6) |                             \
1090
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN7) |                             \
1091
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN8) |                             \
1092
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN9) |                             \
1093
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN10) |                            \
1094
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN11) |                            \
1095
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN12) |                            \
1096
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN13) |                            \
1097
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN14) |                            \
1098
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN15))
1099
#define VAL_GPIOG_OSPEEDR               (PIN_OSPEED_LOW(GPIOG_PIN0) |                                 \
1100
                                         PIN_OSPEED_LOW(GPIOG_PIN1) |                                 \
1101
                                         PIN_OSPEED_LOW(GPIOG_PIN2) |                                 \
1102
                                         PIN_OSPEED_LOW(GPIOG_PIN3) |                                 \
1103
                                         PIN_OSPEED_LOW(GPIOG_PIN4) |                                 \
1104
                                         PIN_OSPEED_LOW(GPIOG_PIN5) |                                 \
1105
                                         PIN_OSPEED_LOW(GPIOG_PIN6) |                                 \
1106
                                         PIN_OSPEED_LOW(GPIOG_PIN7) |                                 \
1107
                                         PIN_OSPEED_LOW(GPIOG_PIN8) |                                 \
1108
                                         PIN_OSPEED_LOW(GPIOG_PIN9) |                                 \
1109
                                         PIN_OSPEED_LOW(GPIOG_PIN10) |                                \
1110
                                         PIN_OSPEED_LOW(GPIOG_PIN11) |                                \
1111
                                         PIN_OSPEED_LOW(GPIOG_PIN12) |                                \
1112
                                         PIN_OSPEED_LOW(GPIOG_PIN13) |                                \
1113
                                         PIN_OSPEED_LOW(GPIOG_PIN14) |                                \
1114
                                         PIN_OSPEED_LOW(GPIOG_PIN15))
1115
#define VAL_GPIOG_PUPDR                 (PIN_PUPDR_FLOATING(GPIOG_PIN0) |                             \
1116
                                         PIN_PUPDR_FLOATING(GPIOG_PIN1) |                             \
1117
                                         PIN_PUPDR_FLOATING(GPIOG_PIN2) |                             \
1118
                                         PIN_PUPDR_FLOATING(GPIOG_PIN3) |                             \
1119
                                         PIN_PUPDR_FLOATING(GPIOG_PIN4) |                             \
1120
                                         PIN_PUPDR_FLOATING(GPIOG_PIN5) |                             \
1121
                                         PIN_PUPDR_FLOATING(GPIOG_PIN6) |                             \
1122
                                         PIN_PUPDR_FLOATING(GPIOG_PIN7) |                             \
1123
                                         PIN_PUPDR_FLOATING(GPIOG_PIN8) |                             \
1124
                                         PIN_PUPDR_FLOATING(GPIOG_PIN9) |                             \
1125
                                         PIN_PUPDR_FLOATING(GPIOG_PIN10) |                            \
1126
                                         PIN_PUPDR_FLOATING(GPIOG_PIN11) |                            \
1127
                                         PIN_PUPDR_FLOATING(GPIOG_PIN12) |                            \
1128
                                         PIN_PUPDR_FLOATING(GPIOG_PIN13) |                            \
1129
                                         PIN_PUPDR_FLOATING(GPIOG_PIN14) |                            \
1130
                                         PIN_PUPDR_FLOATING(GPIOG_PIN15))
1131
#define VAL_GPIOG_ODR                   (PIN_ODR_LOW(GPIOG_PIN0) |                                    \
1132
                                         PIN_ODR_LOW(GPIOG_PIN1) |                                    \
1133
                                         PIN_ODR_LOW(GPIOG_PIN2) |                                    \
1134
                                         PIN_ODR_LOW(GPIOG_PIN3) |                                    \
1135
                                         PIN_ODR_LOW(GPIOG_PIN4) |                                    \
1136
                                         PIN_ODR_LOW(GPIOG_PIN5) |                                    \
1137
                                         PIN_ODR_LOW(GPIOG_PIN6) |                                    \
1138
                                         PIN_ODR_LOW(GPIOG_PIN7) |                                    \
1139
                                         PIN_ODR_LOW(GPIOG_PIN8) |                                    \
1140
                                         PIN_ODR_LOW(GPIOG_PIN9) |                                    \
1141
                                         PIN_ODR_LOW(GPIOG_PIN10) |                                   \
1142
                                         PIN_ODR_LOW(GPIOG_PIN11) |                                   \
1143
                                         PIN_ODR_LOW(GPIOG_PIN12) |                                   \
1144
                                         PIN_ODR_LOW(GPIOG_PIN13) |                                   \
1145
                                         PIN_ODR_LOW(GPIOG_PIN14) |                                   \
1146
                                         PIN_ODR_LOW(GPIOG_PIN15))
1147
#define VAL_GPIOG_AFRL                  (PIN_AFIO_AF(GPIOG_PIN0, STM32F4xx_AF_system) |               \
1148
                                         PIN_AFIO_AF(GPIOG_PIN1, STM32F4xx_AF_system) |               \
1149
                                         PIN_AFIO_AF(GPIOG_PIN2, STM32F4xx_AF_system) |               \
1150
                                         PIN_AFIO_AF(GPIOG_PIN3, STM32F4xx_AF_system) |               \
1151
                                         PIN_AFIO_AF(GPIOG_PIN4, STM32F4xx_AF_system) |               \
1152
                                         PIN_AFIO_AF(GPIOG_PIN5, STM32F4xx_AF_system) |               \
1153
                                         PIN_AFIO_AF(GPIOG_PIN6, STM32F4xx_AF_system) |               \
1154
                                         PIN_AFIO_AF(GPIOG_PIN7, STM32F4xx_AF_system))
1155
#define VAL_GPIOG_AFRH                  (PIN_AFIO_AF(GPIOG_PIN8, STM32F4xx_AF_system) |               \
1156
                                         PIN_AFIO_AF(GPIOG_PIN9, STM32F4xx_AF_system) |               \
1157
                                         PIN_AFIO_AF(GPIOG_PIN10, STM32F4xx_AF_system) |              \
1158
                                         PIN_AFIO_AF(GPIOG_PIN11, STM32F4xx_AF_system) |              \
1159
                                         PIN_AFIO_AF(GPIOG_PIN12, STM32F4xx_AF_system) |              \
1160
                                         PIN_AFIO_AF(GPIOG_PIN13, STM32F4xx_AF_system) |              \
1161
                                         PIN_AFIO_AF(GPIOG_PIN14, STM32F4xx_AF_system) |              \
1162
                                         PIN_AFIO_AF(GPIOG_PIN15, STM32F4xx_AF_system))
1163

    
1164
/*
1165
 * GPIOH setup:
1166
 *
1167
 * PH0  - OSC_IN                        (input floating)
1168
 * PH1  - OSC_OUT                       (input floating)
1169
 * PH2  - PIN2                          (input floating)
1170
 * PH3  - PIN3                          (input floating)
1171
 * PH4  - PIN4                          (input floating)
1172
 * PH5  - PIN5                          (input floating)
1173
 * PH6  - PIN6                          (input floating)
1174
 * PH7  - PIN7                          (input floating)
1175
 * PH8  - PIN8                          (input floating)
1176
 * PH9  - PIN9                          (input floating)
1177
 * PH10 - PIN10                         (input floating)
1178
 * PH11 - PIN11                         (input floating)
1179
 * PH12 - PIN12                         (input floating)
1180
 * PH13 - PIN13                         (input floating)
1181
 * PH14 - PIN14                         (input floating)
1182
 * PH15 - PIN15                         (input floating)
1183
 */
1184
#define VAL_GPIOH_IGNORE                0
1185
#define VAL_GPIOH_MODER                 (PIN_MODE_INPUT(GPIOH_OSC_IN) |                               \
1186
                                         PIN_MODE_INPUT(GPIOH_OSC_OUT) |                              \
1187
                                         PIN_MODE_INPUT(GPIOH_PIN2) |                                 \
1188
                                         PIN_MODE_INPUT(GPIOH_PIN3) |                                 \
1189
                                         PIN_MODE_INPUT(GPIOH_PIN4) |                                 \
1190
                                         PIN_MODE_INPUT(GPIOH_PIN5) |                                 \
1191
                                         PIN_MODE_INPUT(GPIOH_PIN6) |                                 \
1192
                                         PIN_MODE_INPUT(GPIOH_PIN7) |                                 \
1193
                                         PIN_MODE_INPUT(GPIOH_PIN8) |                                 \
1194
                                         PIN_MODE_INPUT(GPIOH_PIN9) |                                 \
1195
                                         PIN_MODE_INPUT(GPIOH_PIN10) |                                \
1196
                                         PIN_MODE_INPUT(GPIOH_PIN11) |                                \
1197
                                         PIN_MODE_INPUT(GPIOH_PIN12) |                                \
1198
                                         PIN_MODE_INPUT(GPIOH_PIN13) |                                \
1199
                                         PIN_MODE_INPUT(GPIOH_PIN14) |                                \
1200
                                         PIN_MODE_INPUT(GPIOH_PIN15))
1201
#define VAL_GPIOH_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) |                           \
1202
                                         PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) |                          \
1203
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN2) |                             \
1204
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN3) |                             \
1205
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN4) |                             \
1206
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN5) |                             \
1207
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN6) |                             \
1208
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN7) |                             \
1209
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN8) |                             \
1210
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN9) |                             \
1211
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN10) |                            \
1212
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN11) |                            \
1213
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN12) |                            \
1214
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN13) |                            \
1215
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN14) |                            \
1216
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN15))
1217
#define VAL_GPIOH_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOH_OSC_IN) |                          \
1218
                                         PIN_OSPEED_VERYHIGH(GPIOH_OSC_OUT) |                         \
1219
                                         PIN_OSPEED_LOW(GPIOH_PIN2) |                                 \
1220
                                         PIN_OSPEED_LOW(GPIOH_PIN3) |                                 \
1221
                                         PIN_OSPEED_LOW(GPIOH_PIN4) |                                 \
1222
                                         PIN_OSPEED_LOW(GPIOH_PIN5) |                                 \
1223
                                         PIN_OSPEED_LOW(GPIOH_PIN6) |                                 \
1224
                                         PIN_OSPEED_LOW(GPIOH_PIN7) |                                 \
1225
                                         PIN_OSPEED_LOW(GPIOH_PIN8) |                                 \
1226
                                         PIN_OSPEED_LOW(GPIOH_PIN9) |                                 \
1227
                                         PIN_OSPEED_LOW(GPIOH_PIN10) |                                \
1228
                                         PIN_OSPEED_LOW(GPIOH_PIN11) |                                \
1229
                                         PIN_OSPEED_LOW(GPIOH_PIN12) |                                \
1230
                                         PIN_OSPEED_LOW(GPIOH_PIN13) |                                \
1231
                                         PIN_OSPEED_LOW(GPIOH_PIN14) |                                \
1232
                                         PIN_OSPEED_LOW(GPIOH_PIN15))
1233
#define VAL_GPIOH_PUPDR                 (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) |                           \
1234
                                         PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) |                          \
1235
                                         PIN_PUPDR_FLOATING(GPIOH_PIN2) |                             \
1236
                                         PIN_PUPDR_FLOATING(GPIOH_PIN3) |                             \
1237
                                         PIN_PUPDR_FLOATING(GPIOH_PIN4) |                             \
1238
                                         PIN_PUPDR_FLOATING(GPIOH_PIN5) |                             \
1239
                                         PIN_PUPDR_FLOATING(GPIOH_PIN6) |                             \
1240
                                         PIN_PUPDR_FLOATING(GPIOH_PIN7) |                             \
1241
                                         PIN_PUPDR_FLOATING(GPIOH_PIN8) |                             \
1242
                                         PIN_PUPDR_FLOATING(GPIOH_PIN9) |                             \
1243
                                         PIN_PUPDR_FLOATING(GPIOH_PIN10) |                            \
1244
                                         PIN_PUPDR_FLOATING(GPIOH_PIN11) |                            \
1245
                                         PIN_PUPDR_FLOATING(GPIOH_PIN12) |                            \
1246
                                         PIN_PUPDR_FLOATING(GPIOH_PIN13) |                            \
1247
                                         PIN_PUPDR_FLOATING(GPIOH_PIN14) |                            \
1248
                                         PIN_PUPDR_FLOATING(GPIOH_PIN15))
1249
#define VAL_GPIOH_ODR                   (PIN_ODR_HIGH(GPIOH_OSC_IN) |                                 \
1250
                                         PIN_ODR_HIGH(GPIOH_OSC_OUT) |                                \
1251
                                         PIN_ODR_HIGH(GPIOH_PIN2) |                                   \
1252
                                         PIN_ODR_HIGH(GPIOH_PIN3) |                                   \
1253
                                         PIN_ODR_HIGH(GPIOH_PIN4) |                                   \
1254
                                         PIN_ODR_HIGH(GPIOH_PIN5) |                                   \
1255
                                         PIN_ODR_HIGH(GPIOH_PIN6) |                                   \
1256
                                         PIN_ODR_HIGH(GPIOH_PIN7) |                                   \
1257
                                         PIN_ODR_HIGH(GPIOH_PIN8) |                                   \
1258
                                         PIN_ODR_HIGH(GPIOH_PIN9) |                                   \
1259
                                         PIN_ODR_HIGH(GPIOH_PIN10) |                                  \
1260
                                         PIN_ODR_HIGH(GPIOH_PIN11) |                                  \
1261
                                         PIN_ODR_HIGH(GPIOH_PIN12) |                                  \
1262
                                         PIN_ODR_HIGH(GPIOH_PIN13) |                                  \
1263
                                         PIN_ODR_HIGH(GPIOH_PIN14) |                                  \
1264
                                         PIN_ODR_HIGH(GPIOH_PIN15))
1265
#define VAL_GPIOH_AFRL                  (PIN_AFIO_AF(GPIOH_OSC_IN, STM32F4xx_AF_system) |             \
1266
                                         PIN_AFIO_AF(GPIOH_OSC_OUT, STM32F4xx_AF_system) |            \
1267
                                         PIN_AFIO_AF(GPIOH_PIN2, STM32F4xx_AF_system) |               \
1268
                                         PIN_AFIO_AF(GPIOH_PIN3, STM32F4xx_AF_system) |               \
1269
                                         PIN_AFIO_AF(GPIOH_PIN4, STM32F4xx_AF_system) |               \
1270
                                         PIN_AFIO_AF(GPIOH_PIN5, STM32F4xx_AF_system) |               \
1271
                                         PIN_AFIO_AF(GPIOH_PIN6, STM32F4xx_AF_system) |               \
1272
                                         PIN_AFIO_AF(GPIOH_PIN7, STM32F4xx_AF_system))
1273
#define VAL_GPIOH_AFRH                  (PIN_AFIO_AF(GPIOH_PIN8, STM32F4xx_AF_system) |               \
1274
                                         PIN_AFIO_AF(GPIOH_PIN9, STM32F4xx_AF_system) |               \
1275
                                         PIN_AFIO_AF(GPIOH_PIN10, STM32F4xx_AF_system) |              \
1276
                                         PIN_AFIO_AF(GPIOH_PIN11, STM32F4xx_AF_system) |              \
1277
                                         PIN_AFIO_AF(GPIOH_PIN12, STM32F4xx_AF_system) |              \
1278
                                         PIN_AFIO_AF(GPIOH_PIN13, STM32F4xx_AF_system) |              \
1279
                                         PIN_AFIO_AF(GPIOH_PIN14, STM32F4xx_AF_system) |              \
1280
                                         PIN_AFIO_AF(GPIOH_PIN15, STM32F4xx_AF_system))
1281

    
1282
/*
1283
 * GPIOI setup:
1284
 *
1285
 * PI0  - PIN0                          (input floating)
1286
 * PI1  - PIN1                          (input floating)
1287
 * PI2  - PIN2                          (input floating)
1288
 * PI3  - PIN3                          (input floating)
1289
 * PI4  - PIN4                          (input floating)
1290
 * PI5  - PIN5                          (input floating)
1291
 * PI6  - PIN6                          (input floating)
1292
 * PI7  - PIN7                          (input floating)
1293
 * PI8  - PIN8                          (input floating)
1294
 * PI9  - PIN9                          (input floating)
1295
 * PI10 - PIN10                         (input floating)
1296
 * PI11 - PIN11                         (input floating)
1297
 * PI12 - PIN12                         (input floating)
1298
 * PI13 - PIN13                         (input floating)
1299
 * PI14 - PIN14                         (input floating)
1300
 * PI15 - PIN15                         (input floating)
1301
 */
1302
#define VAL_GPIOI_IGNORE                0
1303
#define VAL_GPIOI_MODER                 (PIN_MODE_INPUT(GPIOI_PIN0) |                                 \
1304
                                         PIN_MODE_INPUT(GPIOI_PIN1) |                                 \
1305
                                         PIN_MODE_INPUT(GPIOI_PIN2) |                                 \
1306
                                         PIN_MODE_INPUT(GPIOI_PIN3) |                                 \
1307
                                         PIN_MODE_INPUT(GPIOI_PIN4) |                                 \
1308
                                         PIN_MODE_INPUT(GPIOI_PIN5) |                                 \
1309
                                         PIN_MODE_INPUT(GPIOI_PIN6) |                                 \
1310
                                         PIN_MODE_INPUT(GPIOI_PIN7) |                                 \
1311
                                         PIN_MODE_INPUT(GPIOI_PIN8) |                                 \
1312
                                         PIN_MODE_INPUT(GPIOI_PIN9) |                                 \
1313
                                         PIN_MODE_INPUT(GPIOI_PIN10) |                                \
1314
                                         PIN_MODE_INPUT(GPIOI_PIN11) |                                \
1315
                                         PIN_MODE_INPUT(GPIOI_PIN12) |                                \
1316
                                         PIN_MODE_INPUT(GPIOI_PIN13) |                                \
1317
                                         PIN_MODE_INPUT(GPIOI_PIN14) |                                \
1318
                                         PIN_MODE_INPUT(GPIOI_PIN15))
1319
#define VAL_GPIOI_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) |                             \
1320
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN1) |                             \
1321
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN2) |                             \
1322
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN3) |                             \
1323
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN4) |                             \
1324
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN5) |                             \
1325
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN6) |                             \
1326
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN7) |                             \
1327
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN8) |                             \
1328
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN9) |                             \
1329
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN10) |                            \
1330
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN11) |                            \
1331
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN12) |                            \
1332
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN13) |                            \
1333
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN14) |                            \
1334
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN15))
1335
#define VAL_GPIOI_OSPEEDR               (PIN_OSPEED_LOW(GPIOI_PIN0) |                                 \
1336
                                         PIN_OSPEED_LOW(GPIOI_PIN1) |                                 \
1337
                                         PIN_OSPEED_LOW(GPIOI_PIN2) |                                 \
1338
                                         PIN_OSPEED_LOW(GPIOI_PIN3) |                                 \
1339
                                         PIN_OSPEED_LOW(GPIOI_PIN4) |                                 \
1340
                                         PIN_OSPEED_LOW(GPIOI_PIN5) |                                 \
1341
                                         PIN_OSPEED_LOW(GPIOI_PIN6) |                                 \
1342
                                         PIN_OSPEED_LOW(GPIOI_PIN7) |                                 \
1343
                                         PIN_OSPEED_LOW(GPIOI_PIN8) |                                 \
1344
                                         PIN_OSPEED_LOW(GPIOI_PIN9) |                                 \
1345
                                         PIN_OSPEED_LOW(GPIOI_PIN10) |                                \
1346
                                         PIN_OSPEED_LOW(GPIOI_PIN11) |                                \
1347
                                         PIN_OSPEED_LOW(GPIOI_PIN12) |                                \
1348
                                         PIN_OSPEED_LOW(GPIOI_PIN13) |                                \
1349
                                         PIN_OSPEED_LOW(GPIOI_PIN14) |                                \
1350
                                         PIN_OSPEED_LOW(GPIOI_PIN15))
1351
#define VAL_GPIOI_PUPDR                 (PIN_PUPDR_FLOATING(GPIOI_PIN0) |                             \
1352
                                         PIN_PUPDR_FLOATING(GPIOI_PIN1) |                             \
1353
                                         PIN_PUPDR_FLOATING(GPIOI_PIN2) |                             \
1354
                                         PIN_PUPDR_FLOATING(GPIOI_PIN3) |                             \
1355
                                         PIN_PUPDR_FLOATING(GPIOI_PIN4) |                             \
1356
                                         PIN_PUPDR_FLOATING(GPIOI_PIN5) |                             \
1357
                                         PIN_PUPDR_FLOATING(GPIOI_PIN6) |                             \
1358
                                         PIN_PUPDR_FLOATING(GPIOI_PIN7) |                             \
1359
                                         PIN_PUPDR_FLOATING(GPIOI_PIN8) |                             \
1360
                                         PIN_PUPDR_FLOATING(GPIOI_PIN9) |                             \
1361
                                         PIN_PUPDR_FLOATING(GPIOI_PIN10) |                            \
1362
                                         PIN_PUPDR_FLOATING(GPIOI_PIN11) |                            \
1363
                                         PIN_PUPDR_FLOATING(GPIOI_PIN12) |                            \
1364
                                         PIN_PUPDR_FLOATING(GPIOI_PIN13) |                            \
1365
                                         PIN_PUPDR_FLOATING(GPIOI_PIN14) |                            \
1366
                                         PIN_PUPDR_FLOATING(GPIOI_PIN15))
1367
#define VAL_GPIOI_ODR                   (PIN_ODR_LOW(GPIOI_PIN0) |                                    \
1368
                                         PIN_ODR_LOW(GPIOI_PIN1) |                                    \
1369
                                         PIN_ODR_LOW(GPIOI_PIN2) |                                    \
1370
                                         PIN_ODR_LOW(GPIOI_PIN3) |                                    \
1371
                                         PIN_ODR_LOW(GPIOI_PIN4) |                                    \
1372
                                         PIN_ODR_LOW(GPIOI_PIN5) |                                    \
1373
                                         PIN_ODR_LOW(GPIOI_PIN6) |                                    \
1374
                                         PIN_ODR_LOW(GPIOI_PIN7) |                                    \
1375
                                         PIN_ODR_LOW(GPIOI_PIN8) |                                    \
1376
                                         PIN_ODR_LOW(GPIOI_PIN9) |                                    \
1377
                                         PIN_ODR_LOW(GPIOI_PIN10) |                                   \
1378
                                         PIN_ODR_LOW(GPIOI_PIN11) |                                   \
1379
                                         PIN_ODR_LOW(GPIOI_PIN12) |                                   \
1380
                                         PIN_ODR_LOW(GPIOI_PIN13) |                                   \
1381
                                         PIN_ODR_LOW(GPIOI_PIN14) |                                   \
1382
                                         PIN_ODR_LOW(GPIOI_PIN15))
1383
#define VAL_GPIOI_AFRL                  (PIN_AFIO_AF(GPIOI_PIN0, STM32F4xx_AF_system) |               \
1384
                                         PIN_AFIO_AF(GPIOI_PIN1, STM32F4xx_AF_system) |               \
1385
                                         PIN_AFIO_AF(GPIOI_PIN2, STM32F4xx_AF_system) |               \
1386
                                         PIN_AFIO_AF(GPIOI_PIN3, STM32F4xx_AF_system) |               \
1387
                                         PIN_AFIO_AF(GPIOI_PIN4, STM32F4xx_AF_system) |               \
1388
                                         PIN_AFIO_AF(GPIOI_PIN5, STM32F4xx_AF_system) |               \
1389
                                         PIN_AFIO_AF(GPIOI_PIN6, STM32F4xx_AF_system) |               \
1390
                                         PIN_AFIO_AF(GPIOI_PIN7, STM32F4xx_AF_system))
1391
#define VAL_GPIOI_AFRH                  (PIN_AFIO_AF(GPIOI_PIN8, STM32F4xx_AF_system) |               \
1392
                                         PIN_AFIO_AF(GPIOI_PIN9, STM32F4xx_AF_system) |               \
1393
                                         PIN_AFIO_AF(GPIOI_PIN10, STM32F4xx_AF_system) |              \
1394
                                         PIN_AFIO_AF(GPIOI_PIN11, STM32F4xx_AF_system) |              \
1395
                                         PIN_AFIO_AF(GPIOI_PIN12, STM32F4xx_AF_system) |              \
1396
                                         PIN_AFIO_AF(GPIOI_PIN13, STM32F4xx_AF_system) |              \
1397
                                         PIN_AFIO_AF(GPIOI_PIN14, STM32F4xx_AF_system) |              \
1398
                                         PIN_AFIO_AF(GPIOI_PIN15, STM32F4xx_AF_system))
1399

    
1400
#if !defined(_FROM_ASM_)
1401
#ifdef __cplusplus
1402
extern "C" {
1403
#endif
1404
  void boardInit(void);
1405
#ifdef __cplusplus
1406
}
1407
#endif
1408
#endif /* _FROM_ASM_ */
1409

    
1410
#endif /* BOARD_H */
1411

    
1412
/** @} */