Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (110.047 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.1 Board specific macros.
22
 *
23
 * @addtogroup powermanagement_board
24
 * @{
25
 */
26

    
27
#ifndef BOARD_H
28
#define BOARD_H
29

    
30
/*===========================================================================*/
31
/* Driver constants.                                                         */
32
/*===========================================================================*/
33

    
34
/*
35
 * Setup for AMiRo PowerManagement v1.1 board.
36
 */
37

    
38
/*
39
 * Board identifier.
40
 */
41
#define BOARD_POWERMANAGEMENT_1_1
42
#define BOARD_NAME                      "AMiRo PowerManagement v1.1"
43

    
44
/*
45
 * Board oscillators-related settings.
46
 * NOTE: LSE not fitted.
47
 */
48
#if !defined(STM32_LSECLK)
49
#define STM32_LSECLK                    0U
50
#endif
51

    
52
#if !defined(STM32_HSECLK)
53
#define STM32_HSECLK                    8000000U
54
#endif
55

    
56
/*
57
 * Board voltages.
58
 * Required for performance limits calculation.
59
 */
60
#define STM32_VDD                       330U
61

    
62
/*
63
 * MCU type as defined in the ST header.
64
 */
65
#define STM32F405xx
66

    
67
/*
68
 * STM32F4 alternate function definitions
69
 */
70
#define STM32F4xx_AF_system             0U
71
#define STM32F4xx_AF_TIM1to2            1U
72
#define STM32F4xx_AF_TIM3to5            2U
73
#define STM32F4xx_AF_TIM8to11           3U
74
#define STM32F4xx_AF_I2C1to3            4U
75
#define STM32F4xx_AF_SPI1to2            5U
76
#define STM32F4xx_AF_SPI3               6U
77
#define STM32F4xx_AF_USART1to3          7U
78
#define STM32F4xx_AF_USART4to6          8U
79
#define STM32F4xx_AF_CAN1to2_TIM12to14  9U
80
#define STM32F4xx_AF_OTG_HSFS           10U
81
#define STM32F4xx_AF_ETH                11U
82
#define STM32F4xx_AF_FSMC_SDIO_OTGHS    12U
83
#define STM32F4xx_AF_DCMI               13U
84
#define STM32F4xx_AF_EVENTOUT           15U
85

    
86
/*
87
 * Identifiers for the several sensor rings, which can be attached to the PowerManagement v1.1 module.
88
 */
89
#define BOARD_NOSENSORRING              -1
90
#define BOARD_PROXIMITYSENSOR           1
91
#define BOARD_DISTANCESENSOR_VL53L0X    2
92
#define BOARD_DISTANCESENSOR_VL53L1X    3
93

    
94
/*
95
 * Configuration macro to define which type of sensor ring is attached.
96
 */
97
#if !defined(BOARD_SENSORRING) || defined(__DOXYGEN__)
98
  #define BOARD_SENSORRING              BOARD_PROXIMITYSENSOR
99
#elif ((BOARD_SENSORRING != BOARD_NOSENSORRING) && \
100
       (BOARD_SENSORRING != BOARD_PROXIMITYSENSOR) && \
101
       (BOARD_SENSORRING != BOARD_DISTANCESENSOR_VL53L0X) && \
102
       (BOARD_SENSORRING != BOARD_DISTANCESENSOR_VL53L1X))
103
  #error "BOARD_SENSORRING set to invalid value"
104
#endif
105

    
106
/*
107
 * IO pins assignments.
108
 */
109
#define GPIOA_WKUP                      0U
110
#define GPIOA_PIN1                      1U
111
#define GPIOA_SYS_UART_TX               2U
112
#define GPIOA_SYS_UART_RX               3U
113
#define GPIOA_SYS_SPI_SS0_N             4U
114
#define GPIOA_SYS_SPI_SCLK              5U
115
#define GPIOA_SYS_SPI_MISO              6U
116
#define GPIOA_SYS_SPI_MOSI              7U
117
#define GPIOA_SYS_REG_EN                8U
118
#define GPIOA_PROG_RX                   9U
119
#define GPIOA_PROG_TX                   10U
120
#define GPIOA_CAN_RX                    11U
121
#define GPIOA_CAN_TX                    12U
122
#define GPIOA_SWDIO                     13U
123
#define GPIOA_SWCLK                     14U
124
#define GPIOA_SYS_SPI_SS1_N             15U
125

    
126
#define GPIOB_IR_INT1_N                 0U
127
#define GPIOB_VSYS_SENSE                1U
128
#define GPIOB_POWER_EN                  2U
129
#define GPIOB_SYS_UART_DN               3U
130
#define GPIOB_CHARGE_STAT2A             4U
131
#define GPIOB_BUZZER                    5U
132
#define GPIOB_GAUGE_BATLOW2             6U
133
#define GPIOB_GAUGE_BATGD2_N            7U
134
#define GPIOB_GAUGE_SCL2                8U
135
#define GPIOB_GAUGE_SDA2                9U
136
#define GPIOB_GAUGE_SCL1                10U
137
#define GPIOB_GAUGE_SDA1                11U
138
#define GPIOB_LED                       12U
139
#define GPIOB_BT_RTS                    13U
140
#define GPIOB_BT_CTS                    14U
141
#define GPIOB_SYS_UART_UP               15U
142

    
143
#define GPIOC_CHARGE_STAT1A             0U
144
#define GPIOC_GAUGE_BATLOW1             1U
145
#define GPIOC_GAUGE_BATGD1_N            2U
146
#define GPIOC_CHARGE_EN1_N              3U
147
#define GPIOC_IR_INT2_N                 4U
148
#define GPIOC_TOUCH_INT_N               5U
149
#define GPIOC_SYS_DONE                  6U
150
#define GPIOC_SYS_PROG_N                7U
151
#define GPIOC_PATH_DC                   8U
152
#define GPIOC_SYS_SPI_DIR               9U
153
#define GPIOC_BT_RX                     10U
154
#define GPIOC_BT_TX                     11U
155
#define GPIOC_SYS_INT_N                 12U
156
#define GPIOC_SYS_PD_N                  13U
157
#define GPIOC_SYS_WARMRST_N             14U
158
#define GPIOC_BT_RST                    15U
159

    
160
#define GPIOD_PIN0                      0U
161
#define GPIOD_PIN1                      1U
162
#define GPIOD_CHARGE_EN2_N              2U
163
#define GPIOD_PIN3                      3U
164
#define GPIOD_PIN4                      4U
165
#define GPIOD_PIN5                      5U
166
#define GPIOD_PIN6                      6U
167
#define GPIOD_PIN7                      7U
168
#define GPIOD_PIN8                      8U
169
#define GPIOD_PIN9                      9U
170
#define GPIOD_PIN10                     10U
171
#define GPIOD_PIN11                     11U
172
#define GPIOD_PIN12                     12U
173
#define GPIOD_PIN13                     13U
174
#define GPIOD_PIN14                     14U
175
#define GPIOD_PIN15                     15U
176

    
177
#define GPIOE_PIN0                      0U
178
#define GPIOE_PIN1                      1U
179
#define GPIOE_PIN2                      2U
180
#define GPIOE_PIN3                      3U
181
#define GPIOE_PIN4                      4U
182
#define GPIOE_PIN5                      5U
183
#define GPIOE_PIN6                      6U
184
#define GPIOE_PIN7                      7U
185
#define GPIOE_PIN8                      8U
186
#define GPIOE_PIN9                      9U
187
#define GPIOE_PIN10                     10U
188
#define GPIOE_PIN11                     11U
189
#define GPIOE_PIN12                     12U
190
#define GPIOE_PIN13                     13U
191
#define GPIOE_PIN14                     14U
192
#define GPIOE_PIN15                     15U
193

    
194
#define GPIOF_PIN0                      0U
195
#define GPIOF_PIN1                      1U
196
#define GPIOF_PIN2                      2U
197
#define GPIOF_PIN3                      3U
198
#define GPIOF_PIN4                      4U
199
#define GPIOF_PIN5                      5U
200
#define GPIOF_PIN6                      6U
201
#define GPIOF_PIN7                      7U
202
#define GPIOF_PIN8                      8U
203
#define GPIOF_PIN9                      9U
204
#define GPIOF_PIN10                     10U
205
#define GPIOF_PIN11                     11U
206
#define GPIOF_PIN12                     12U
207
#define GPIOF_PIN13                     13U
208
#define GPIOF_PIN14                     14U
209
#define GPIOF_PIN15                     15U
210

    
211
#define GPIOG_PIN0                      0U
212
#define GPIOG_PIN1                      1U
213
#define GPIOG_PIN2                      2U
214
#define GPIOG_PIN3                      3U
215
#define GPIOG_PIN4                      4U
216
#define GPIOG_PIN5                      5U
217
#define GPIOG_PIN6                      6U
218
#define GPIOG_PIN7                      7U
219
#define GPIOG_PIN8                      8U
220
#define GPIOG_PIN9                      9U
221
#define GPIOG_PIN10                     10U
222
#define GPIOG_PIN11                     11U
223
#define GPIOG_PIN12                     12U
224
#define GPIOG_PIN13                     13U
225
#define GPIOG_PIN14                     14U
226
#define GPIOG_PIN15                     15U
227

    
228
#define GPIOH_OSC_IN                    0U
229
#define GPIOH_OSC_OUT                   1U
230
#define GPIOH_PIN2                      2U
231
#define GPIOH_PIN3                      3U
232
#define GPIOH_PIN4                      4U
233
#define GPIOH_PIN5                      5U
234
#define GPIOH_PIN6                      6U
235
#define GPIOH_PIN7                      7U
236
#define GPIOH_PIN8                      8U
237
#define GPIOH_PIN9                      9U
238
#define GPIOH_PIN10                     10U
239
#define GPIOH_PIN11                     11U
240
#define GPIOH_PIN12                     12U
241
#define GPIOH_PIN13                     13U
242
#define GPIOH_PIN14                     14U
243
#define GPIOH_PIN15                     15U
244

    
245
#define GPIOI_PIN0                      0U
246
#define GPIOI_PIN1                      1U
247
#define GPIOI_PIN2                      2U
248
#define GPIOI_PIN3                      3U
249
#define GPIOI_PIN4                      4U
250
#define GPIOI_PIN5                      5U
251
#define GPIOI_PIN6                      6U
252
#define GPIOI_PIN7                      7U
253
#define GPIOI_PIN8                      8U
254
#define GPIOI_PIN9                      9U
255
#define GPIOI_PIN10                     10U
256
#define GPIOI_PIN11                     11U
257
#define GPIOI_PIN12                     12U
258
#define GPIOI_PIN13                     13U
259
#define GPIOI_PIN14                     14U
260
#define GPIOI_PIN15                     15U
261

    
262
/*
263
 * IO lines assignments.
264
 */
265
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
266
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
267
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
268
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
269
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
270
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
271
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
272
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
273
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
274
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
275
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
276
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
277
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
278
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
279
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
280

    
281
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
282
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
283
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
284
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
285
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
286
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
287
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
288
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
289
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
290
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
291
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
292
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
293
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
294
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
295
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
296
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
297

    
298
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
299
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
300
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
301
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
302
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
303
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
304
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
305
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
306
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
307
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
308
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
309
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
310
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
311
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
312
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
313
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
314

    
315
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
316

    
317
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
318
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
319

    
320
/*===========================================================================*/
321
/* Driver pre-compile time settings.                                         */
322
/*===========================================================================*/
323

    
324
/*===========================================================================*/
325
/* Derived constants and error checks.                                       */
326
/*===========================================================================*/
327

    
328
/*===========================================================================*/
329
/* Driver data structures and types.                                         */
330
/*===========================================================================*/
331

    
332
/*===========================================================================*/
333
/* Driver macros.                                                            */
334
/*===========================================================================*/
335

    
336
/*
337
 * I/O ports initial setup, this configuration is established soon after reset
338
 * in the initialization code.
339
 * Please refer to the STM32 Reference Manual for details.
340
 */
341
#define PIN_MODE_INPUT(n)               (0U << ((n) * 2U))
342
#define PIN_MODE_OUTPUT(n)              (1U << ((n) * 2U))
343
#define PIN_MODE_ALTERNATE(n)           (2U << ((n) * 2U))
344
#define PIN_MODE_ANALOG(n)              (3U << ((n) * 2U))
345
#define PIN_ODR_LOW(n)                  (0U << (n))
346
#define PIN_ODR_HIGH(n)                 (1U << (n))
347
#define PIN_OTYPE_PUSHPULL(n)           (0U << (n))
348
#define PIN_OTYPE_OPENDRAIN(n)          (1U << (n))
349
#define PIN_OSPEED_LOW(n)               (0U << ((n) * 2U))
350
#define PIN_OSPEED_MEDIUM(n)            (1U << ((n) * 2U))
351
#define PIN_OSPEED_HIGH(n)              (2U << ((n) * 2U))
352
#define PIN_OSPEED_VERYHIGH(n)          (3U << ((n) * 2U))
353
#define PIN_PUPDR_FLOATING(n)           (0U << ((n) * 2U))
354
#define PIN_PUPDR_PULLUP(n)             (1U << ((n) * 2U))
355
#define PIN_PUPDR_PULLDOWN(n)           (2U << ((n) * 2U))
356
#define PIN_AFIO_AF(n, v)               ((v) << (((n) % 8U) * 4U))
357

    
358
/*
359
 * GPIOA setup:
360
 *
361
 * PA0  - WKUP                          (input floating)
362
 * PA1  - PIN1                          (input pullup)
363
 * PA2  - SYS_UART_TX                   (input floating)
364
 * PA3  - SYS_UART_RX                   (alternate 7 pushpull floating)
365
 * PA4  - SYS_SPI_SS0_N                 (input floating)
366
 * PA5  - SYS_SPI_SCLK                  (alternate 5 pushpull floating)
367
 * PA6  - SYS_SPI_MISO                  (alternate 5 pushpull floating)
368
 * PA7  - SYS_SPI_MOSI                  (alternate 5 pushpull floating)
369
 * PA8  - SYS_REG_EN                    (output pushpull high)
370
 * PA9  - PROG_RX                       (alternate 7 pushpull floating)
371
 * PA10 - PROG_TX                       (alternate 7 pushpull pullup)
372
 * PA11 - CAN_RX                        (alternate 9 pushpull floating)
373
 * PA12 - CAN_TX                        (alternate 9 pushpull floating)
374
 * PA13 - SWDIO                         (alternate 0 pushpull floating)
375
 * PA14 - SWCLK                         (alternate 0 pushpull floating)
376
 * PA15 - SYS_SPI_SS1_N                 (input floating)
377
 */
378
#define VAL_GPIOA_MODER                 (PIN_MODE_INPUT(GPIOA_WKUP) |                                 \
379
                                         PIN_MODE_INPUT(GPIOA_PIN1) |                                 \
380
                                         PIN_MODE_INPUT(GPIOA_SYS_UART_TX) |                          \
381
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_UART_RX) |                      \
382
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS0_N) |                        \
383
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_SCLK) |                     \
384
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MISO) |                     \
385
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MOSI) |                     \
386
                                         PIN_MODE_OUTPUT(GPIOA_SYS_REG_EN) |                          \
387
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_RX) |                          \
388
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_TX) |                          \
389
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_RX) |                           \
390
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_TX) |                           \
391
                                         PIN_MODE_ALTERNATE(GPIOA_SWDIO) |                            \
392
                                         PIN_MODE_ALTERNATE(GPIOA_SWCLK) |                            \
393
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS1_N))
394
#define VAL_GPIOA_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOA_WKUP) |                             \
395
                                         PIN_OTYPE_PUSHPULL(GPIOA_PIN1) |                             \
396
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_TX) |                      \
397
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_RX) |                      \
398
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS0_N) |                    \
399
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SCLK) |                     \
400
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MISO) |                     \
401
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MOSI) |                     \
402
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_REG_EN) |                       \
403
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_RX) |                          \
404
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_TX) |                          \
405
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_RX) |                           \
406
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_TX) |                           \
407
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) |                            \
408
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) |                            \
409
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS1_N))
410
#define VAL_GPIOA_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOA_WKUP) |                            \
411
                                         PIN_OSPEED_VERYHIGH(GPIOA_PIN1) |                            \
412
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_TX) |                     \
413
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_RX) |                     \
414
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS0_N) |                   \
415
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SCLK) |                    \
416
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MISO) |                    \
417
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MOSI) |                    \
418
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_REG_EN) |                      \
419
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_RX) |                         \
420
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_TX) |                         \
421
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_RX) |                          \
422
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_TX) |                          \
423
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWDIO) |                           \
424
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWCLK) |                           \
425
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS1_N))
426
#define VAL_GPIOA_PUPDR                 (PIN_PUPDR_FLOATING(GPIOA_WKUP) |                             \
427
                                         PIN_PUPDR_PULLUP(GPIOA_PIN1) |                               \
428
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_TX) |                      \
429
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_RX) |                      \
430
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS0_N) |                    \
431
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SCLK) |                     \
432
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MISO) |                     \
433
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MOSI) |                     \
434
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_REG_EN) |                       \
435
                                         PIN_PUPDR_FLOATING(GPIOA_PROG_RX) |                          \
436
                                         PIN_PUPDR_PULLUP(GPIOA_PROG_TX) |                            \
437
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_RX) |                           \
438
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_TX) |                           \
439
                                         PIN_PUPDR_FLOATING(GPIOA_SWDIO) |                            \
440
                                         PIN_PUPDR_FLOATING(GPIOA_SWCLK) |                            \
441
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS1_N))
442
#define VAL_GPIOA_ODR                   (PIN_ODR_HIGH(GPIOA_WKUP) |                                   \
443
                                         PIN_ODR_HIGH(GPIOA_PIN1) |                                   \
444
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_TX) |                            \
445
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_RX) |                            \
446
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS0_N) |                          \
447
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SCLK) |                           \
448
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MISO) |                           \
449
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MOSI) |                           \
450
                                         PIN_ODR_HIGH(GPIOA_SYS_REG_EN) |                             \
451
                                         PIN_ODR_HIGH(GPIOA_PROG_RX) |                                \
452
                                         PIN_ODR_HIGH(GPIOA_PROG_TX) |                                \
453
                                         PIN_ODR_HIGH(GPIOA_CAN_RX) |                                 \
454
                                         PIN_ODR_HIGH(GPIOA_CAN_TX) |                                 \
455
                                         PIN_ODR_HIGH(GPIOA_SWDIO) |                                  \
456
                                         PIN_ODR_HIGH(GPIOA_SWCLK) |                                  \
457
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS1_N))
458
#define VAL_GPIOA_AFRL                  (PIN_AFIO_AF(GPIOA_WKUP, STM32F4xx_AF_system) |               \
459
                                         PIN_AFIO_AF(GPIOA_PIN1, STM32F4xx_AF_system) |               \
460
                                         PIN_AFIO_AF(GPIOA_SYS_UART_TX, STM32F4xx_AF_USART1to3) |     \
461
                                         PIN_AFIO_AF(GPIOA_SYS_UART_RX, STM32F4xx_AF_USART1to3) |     \
462
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS0_N, STM32F4xx_AF_system) |      \
463
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SCLK, STM32F4xx_AF_SPI1to2) |      \
464
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MISO, STM32F4xx_AF_SPI1to2) |      \
465
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MOSI, STM32F4xx_AF_SPI1to2))
466
#define VAL_GPIOA_AFRH                  (PIN_AFIO_AF(GPIOA_SYS_REG_EN, STM32F4xx_AF_system) |         \
467
                                         PIN_AFIO_AF(GPIOA_PROG_RX, STM32F4xx_AF_USART1to3) |         \
468
                                         PIN_AFIO_AF(GPIOA_PROG_TX, STM32F4xx_AF_USART1to3) |         \
469
                                         PIN_AFIO_AF(GPIOA_CAN_RX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
470
                                         PIN_AFIO_AF(GPIOA_CAN_TX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
471
                                         PIN_AFIO_AF(GPIOA_SWDIO, STM32F4xx_AF_system) |              \
472
                                         PIN_AFIO_AF(GPIOA_SWCLK, STM32F4xx_AF_system) |              \
473
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS1_N, STM32F4xx_AF_system))
474

    
475
/*
476
 * GPIOB setup:
477
 *
478
 * PB0  - IR_INT1_N                     (input floating)
479
 * PB1  - VSYS_SENSE                    (analog)
480
 * PB2  - POWER_EN                      (output pushpull high)
481
 * PB3  - SYS_UART_DN                   (output opendrain high)
482
 * PB4  - CHARGE_STAT2A                 (inout floating)
483
 * PB5  - BUZZER                        (alternate 2 pushpull floating)
484
 * PB6  - GAUGE_BATLOW2                 (input floating)
485
 * PB7  - GAUGE_BATGD2_N                (input floating)
486
 * PB8  - GAUGE_SCL2                    (alternate 4 opendrain floating)
487
 * PB9  - GAUGE_SDA2                    (alternate 4 opendrain floating)
488
 * PB10 - GAUGE_SCL1                    (alternate 4 opendrain floating)
489
 * PB11 - GAUGE_SDA1                    (alternate 4 opendrain floating)
490
 * PB12 - LED                           (output opendrain high)
491
 * PB13 - BT_RTS                        (alternate 7 pushpull floating)
492
 * PB14 - BT_CTS                        (inout floating)
493
 * PB15 - SYS_UART_UP                   (output opendrain high)
494
 */
495
#define VAL_GPIOB_MODER                 (PIN_MODE_INPUT(GPIOB_IR_INT1_N) |                            \
496
                                         PIN_MODE_ANALOG(GPIOB_VSYS_SENSE) |                          \
497
                                         PIN_MODE_OUTPUT(GPIOB_POWER_EN) |                            \
498
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_DN) |                         \
499
                                         PIN_MODE_INPUT(GPIOB_CHARGE_STAT2A) |                        \
500
                                         PIN_MODE_ALTERNATE(GPIOB_BUZZER) |                           \
501
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATLOW2) |                        \
502
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATGD2_N) |                       \
503
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL2) |                       \
504
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA2) |                       \
505
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL1) |                       \
506
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA1) |                       \
507
                                         PIN_MODE_OUTPUT(GPIOB_LED) |                                 \
508
                                         PIN_MODE_ALTERNATE(GPIOB_BT_RTS) |                           \
509
                                         PIN_MODE_INPUT(GPIOB_BT_CTS) |                               \
510
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_UP))
511
#define VAL_GPIOB_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOB_IR_INT1_N) |                        \
512
                                         PIN_OTYPE_PUSHPULL(GPIOB_VSYS_SENSE) |                       \
513
                                         PIN_OTYPE_PUSHPULL(GPIOB_POWER_EN) |                         \
514
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_DN) |                     \
515
                                         PIN_OTYPE_PUSHPULL(GPIOB_CHARGE_STAT2A) |                    \
516
                                         PIN_OTYPE_PUSHPULL(GPIOB_BUZZER) |                           \
517
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATLOW2) |                    \
518
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATGD2_N) |                   \
519
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL2) |                      \
520
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA2) |                      \
521
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL1) |                      \
522
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA1) |                      \
523
                                         PIN_OTYPE_OPENDRAIN(GPIOB_LED) |                             \
524
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_RTS) |                           \
525
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_CTS) |                           \
526
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_UP))
527
#define VAL_GPIOB_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOB_IR_INT1_N) |                       \
528
                                         PIN_OSPEED_VERYHIGH(GPIOB_VSYS_SENSE) |                      \
529
                                         PIN_OSPEED_VERYHIGH(GPIOB_POWER_EN) |                        \
530
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_DN) |                     \
531
                                         PIN_OSPEED_VERYHIGH(GPIOB_CHARGE_STAT2A) |                   \
532
                                         PIN_OSPEED_VERYHIGH(GPIOB_BUZZER) |                          \
533
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATLOW2) |                   \
534
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATGD2_N) |                  \
535
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL2) |                      \
536
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA2) |                      \
537
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL1) |                      \
538
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA1) |                      \
539
                                         PIN_OSPEED_VERYHIGH(GPIOB_LED) |                             \
540
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_RTS) |                          \
541
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_CTS) |                          \
542
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_UP))
543
#define VAL_GPIOB_PUPDR                 (PIN_PUPDR_FLOATING(GPIOB_IR_INT1_N) |                        \
544
                                         PIN_PUPDR_FLOATING(GPIOB_VSYS_SENSE) |                       \
545
                                         PIN_PUPDR_FLOATING(GPIOB_POWER_EN) |                         \
546
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_DN) |                      \
547
                                         PIN_PUPDR_FLOATING(GPIOB_CHARGE_STAT2A) |                    \
548
                                         PIN_PUPDR_FLOATING(GPIOB_BUZZER) |                           \
549
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATLOW2) |                    \
550
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATGD2_N) |                   \
551
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL2) |                       \
552
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA2) |                       \
553
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL1) |                       \
554
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA1) |                       \
555
                                         PIN_PUPDR_FLOATING(GPIOB_LED) |                              \
556
                                         PIN_PUPDR_FLOATING(GPIOB_BT_RTS) |                           \
557
                                         PIN_PUPDR_FLOATING(GPIOB_BT_CTS) |                           \
558
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_UP))
559
#define VAL_GPIOB_ODR                   (PIN_ODR_HIGH(GPIOB_IR_INT1_N) |                              \
560
                                         PIN_ODR_HIGH(GPIOB_VSYS_SENSE) |                             \
561
                                         PIN_ODR_HIGH(GPIOB_POWER_EN) |                               \
562
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_DN) |                            \
563
                                         PIN_ODR_HIGH(GPIOB_CHARGE_STAT2A) |                          \
564
                                         PIN_ODR_HIGH(GPIOB_BUZZER) |                                 \
565
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATLOW2) |                          \
566
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATGD2_N) |                         \
567
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL2) |                             \
568
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA2) |                             \
569
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL1) |                             \
570
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA1) |                             \
571
                                         PIN_ODR_HIGH(GPIOB_LED) |                                    \
572
                                         PIN_ODR_HIGH(GPIOB_BT_RTS) |                                 \
573
                                         PIN_ODR_HIGH(GPIOB_BT_CTS) |                                 \
574
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_UP))
575
#define VAL_GPIOB_AFRL                  (PIN_AFIO_AF(GPIOB_IR_INT1_N, STM32F4xx_AF_system) |          \
576
                                         PIN_AFIO_AF(GPIOB_VSYS_SENSE, STM32F4xx_AF_system) |         \
577
                                         PIN_AFIO_AF(GPIOB_POWER_EN, STM32F4xx_AF_system) |           \
578
                                         PIN_AFIO_AF(GPIOB_SYS_UART_DN, STM32F4xx_AF_system) |        \
579
                                         PIN_AFIO_AF(GPIOB_CHARGE_STAT2A, STM32F4xx_AF_system) |      \
580
                                         PIN_AFIO_AF(GPIOB_BUZZER, STM32F4xx_AF_TIM3to5) |            \
581
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATLOW2, STM32F4xx_AF_system) |      \
582
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATGD2_N, STM32F4xx_AF_system))
583
#define VAL_GPIOB_AFRH                  (PIN_AFIO_AF(GPIOB_GAUGE_SCL2, STM32F4xx_AF_I2C1to3) |        \
584
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA2, STM32F4xx_AF_I2C1to3) |        \
585
                                         PIN_AFIO_AF(GPIOB_GAUGE_SCL1, STM32F4xx_AF_I2C1to3) |        \
586
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA1, STM32F4xx_AF_I2C1to3) |        \
587
                                         PIN_AFIO_AF(GPIOB_LED, STM32F4xx_AF_system) |                \
588
                                         PIN_AFIO_AF(GPIOB_BT_RTS, STM32F4xx_AF_USART1to3) |          \
589
                                         PIN_AFIO_AF(GPIOB_BT_CTS, STM32F4xx_AF_USART1to3) |          \
590
                                         PIN_AFIO_AF(GPIOB_SYS_UART_UP, STM32F4xx_AF_system))
591

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

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

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

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

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

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

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

    
1411
/*===========================================================================*/
1412
/* External declarations.                                                    */
1413
/*===========================================================================*/
1414

    
1415
#if !defined(_FROM_ASM_)
1416
#ifdef __cplusplus
1417
extern "C" {
1418
#endif
1419
  void boardInit(void);
1420
#ifdef __cplusplus
1421
}
1422
#endif
1423
#endif /* _FROM_ASM_ */
1424

    
1425
#endif /* BOARD_H */
1426

    
1427
/** @} */