Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (110 KB)

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

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

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

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
/**
20
 * @file
21
 * @brief   PowerManagement v1.2 Board specific macros.
22
 *
23
 * @addtogroup powermanagement_board
24
 * @{
25
 */
26

    
27
#ifndef BOARD_H
28
#define BOARD_H
29

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

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

    
38
/*
39
 * Board identifier.
40
 */
41
#define BOARD_POWERMANAGEMENT_1_2
42
#define BOARD_NAME                      "AMiRo PowerManagement v1.2"
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.2 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_NOSENSORRING
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_SWITCH_STATUS_N           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_SWITCH_STATUS_N            PAL_LINE(GPIOA, GPIOA_SWITCH_STATUS_N)
267
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
268
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
269
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
270
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
271
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
272
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
273
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
274
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
275
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
276
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
277
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
278
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
279
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
280
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
281

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

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

    
316
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
317

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1426
#endif /* BOARD_H */
1427

    
1428
/** @} */