Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / LightRing_1-2 / board.h @ 4684a9d9

History | View | Annotate | Download (41.043 KB)

1 9ae7c4f3 Thomas Schöpping
/*
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 034cb15a Thomas Schöpping
 * @brief   LightRing v1.2 Board specific macros.
22 9ae7c4f3 Thomas Schöpping
 *
23
 * @addtogroup lightring_board
24
 * @{
25
 */
26
27
#ifndef BOARD_H
28
#define BOARD_H
29
30
/*
31 034cb15a Thomas Schöpping
 * Setup for AMiRo LightRing v1.2 board.
32 9ae7c4f3 Thomas Schöpping
 */
33
34
/*
35
 * Board identifier.
36
 */
37
#define BOARD_LIGHTRING_1_2
38
#define BOARD_NAME              "AMiRo LightRing v1.2"
39
40
/*
41
 * Board oscillators-related settings.
42
 * NOTE: LSE not fitted.
43
 */
44
#if !defined(STM32_LSECLK)
45
#define STM32_LSECLK                0U
46
#endif
47
48
#if !defined(STM32_HSECLK)
49
#define STM32_HSECLK                8000000U
50
#endif
51
52
/*
53
 * Board voltages.
54
 * Required for performance limits calculation.
55
 */
56
#define STM32_VDD                   330U
57
58
/*
59
 * MCU type as defined in the ST header.
60
 */
61
#define STM32F103xE
62
63
/*
64
 * IO pins assignments.
65
 */
66
#define GPIOA_USART_CTS             0U
67
#define GPIOA_USART_RTS             1U
68
#define GPIOA_USART_RX              2U
69
#define GPIOA_USART_TX              3U
70
#define GPIOA_LIGHT_BLANK           4U
71
#define GPIOA_LIGHT_SCLK            5U
72
#define GPIOA_LIGHT_MISO            6U
73
#define GPIOA_LIGHT_MOSI            7U
74
#define GPIOA_PIN8                  8U
75
#define GPIOA_PROG_RX               9U
76
#define GPIOA_PROG_TX               10U
77
#define GPIOA_CAN_RX                11U
78
#define GPIOA_CAN_TX                12U
79
#define GPIOA_SWDIO                 13U
80
#define GPIOA_SWCLK                 14U
81
#define GPIOA_RS232_R_EN_N          15U
82
83
#define GPIOB_SW_V33_EN             0U
84
#define GPIOB_SW_V42_EN             1U
85
#define GPIOB_SW_V50_EN             2U
86
#define GPIOB_IO_3                  3U
87
#define GPIOB_IO_5                  4U
88
#define GPIOB_IO_6                  5U
89
#define GPIOB_SYS_UART_DN           6U
90
#define GPIOB_PIN7                  7U
91
#define GPIOB_IO_7                  8U
92
#define GPIOB_IO_8                  9U
93
#define GPIOB_I2C_SCL               10U
94
#define GPIOB_I2C_SDA               11U
95
#define GPIOB_SPI_SS_N              12U
96
#define GPIOB_SPI_SCLK              13U
97
#define GPIOB_SPI_MISO              14U
98
#define GPIOB_SPI_MOSI              15U
99
100
#define GPIOC_IO_4                  0U
101
#define GPIOC_IO_1                  1U
102
#define GPIOC_IO_2                  2U
103
#define GPIOC_LED                   3U
104
#define GPIOC_LIGHT_XLAT            4U
105
#define GPIOC_SW_V18_EN             5U
106
#define GPIOC_SW_VSYS_EN            6U
107
#define GPIOC_SYS_UART_UP           7U
108
#define GPIOC_PIN8                  8U
109
#define GPIOC_PIN9                  9U
110
#define GPIOC_SYS_UART_RX           10U
111
#define GPIOC_SYS_UART_TX           11U
112
#define GPIOC_RS232_D_OFF_N         12U
113
#define GPIOC_PIN13                 13U
114
#define GPIOC_SYS_PD_N              14U
115
#define GPIOC_PIN15                 15U
116
117
#define GPIOD_OSC_IN                0U
118
#define GPIOD_OSC_OUT               1U
119
#define GPIOD_SYS_INT_N             2U
120
#define GPIOD_PIN3                  3U
121
#define GPIOD_PIN4                  4U
122
#define GPIOD_PIN5                  5U
123
#define GPIOD_PIN6                  6U
124
#define GPIOD_PIN7                  7U
125
#define GPIOD_PIN8                  8U
126
#define GPIOD_PIN9                  9U
127
#define GPIOD_PIN10                 10U
128
#define GPIOD_PIN11                 11U
129
#define GPIOD_PIN12                 12U
130
#define GPIOD_PIN13                 13U
131
#define GPIOD_PIN14                 14U
132
#define GPIOD_PIN15                 15U
133
134
#define GPIOE_PIN0                  0U
135
#define GPIOE_PIN1                  1U
136
#define GPIOE_PIN2                  2U
137
#define GPIOE_PIN3                  3U
138
#define GPIOE_PIN4                  4U
139
#define GPIOE_PIN5                  5U
140
#define GPIOE_PIN6                  6U
141
#define GPIOE_PIN7                  7U
142
#define GPIOE_PIN8                  8U
143
#define GPIOE_PIN9                  9U
144
#define GPIOE_PIN10                 10U
145
#define GPIOE_PIN11                 11U
146
#define GPIOE_PIN12                 12U
147
#define GPIOE_PIN13                 13U
148
#define GPIOE_PIN14                 14U
149
#define GPIOE_PIN15                 15U
150
151
#define GPIOF_PIN0                  0U
152
#define GPIOF_PIN1                  1U
153
#define GPIOF_PIN2                  2U
154
#define GPIOF_PIN3                  3U
155
#define GPIOF_PIN4                  4U
156
#define GPIOF_PIN5                  5U
157
#define GPIOF_PIN6                  6U
158
#define GPIOF_PIN7                  7U
159
#define GPIOF_PIN8                  8U
160
#define GPIOF_PIN9                  9U
161
#define GPIOF_PIN10                 10U
162
#define GPIOF_PIN11                 11U
163
#define GPIOF_PIN12                 12U
164
#define GPIOF_PIN13                 13U
165
#define GPIOF_PIN14                 14U
166
#define GPIOF_PIN15                 15U
167
168
#define GPIOG_PIN0                  0U
169
#define GPIOG_PIN1                  1U
170
#define GPIOG_PIN2                  2U
171
#define GPIOG_PIN3                  3U
172
#define GPIOG_PIN4                  4U
173
#define GPIOG_PIN5                  5U
174
#define GPIOG_PIN6                  6U
175
#define GPIOG_PIN7                  7U
176
#define GPIOG_PIN8                  8U
177
#define GPIOG_PIN9                  9U
178
#define GPIOG_PIN10                 10U
179
#define GPIOG_PIN11                 11U
180
#define GPIOG_PIN12                 12U
181
#define GPIOG_PIN13                 13U
182
#define GPIOG_PIN14                 14U
183
#define GPIOG_PIN15                 15U
184
185
/*
186
 * IO lines assignments.
187
 */
188
#define LINE_USART_CTS              PAL_LINE(GPIOA, GPIOA_USART_CTS)
189
#define LINE_USART_RTS              PAL_LINE(GPIOA, GPIOA_USART_RTS)
190
#define LINE_USART_RX               PAL_LINE(GPIOA, GPIOA_USART_RX)
191
#define LINE_USART_TX               PAL_LINE(GPIOA, GPIOA_USART_TX)
192
#define LINE_LIGHT_BLANK            PAL_LINE(GPIOA, GPIOA_LIGHT_BLANK)
193
#define LINE_LIGHT_SCLK             PAL_LINE(GPIOA, GPIOA_LIGHT_SCLK)
194
#define LINE_LIGHT_MISO             PAL_LINE(GPIOA, GPIOA_LIGHT_MISO)
195
#define LINE_LIGHT_MOSI             PAL_LINE(GPIOA, GPIOA_LIGHT_MOSI)
196
#define LINE_PROG_RX                PAL_LINE(GPIOA, GPIOA_PROG_RX)
197
#define LINE_PROG_TX                PAL_LINE(GPIOA, GPIOA_PROG_TX)
198
#define LINE_CAN_RX                 PAL_LINE(GPIOA, GPIOA_CAN_RX)
199
#define LINE_CAN_TX                 PAL_LINE(GPIOA, GPIOA_CAN_TX)
200
#define LINE_SWDIO                  PAL_LINE(GPIOA, GPIOA_SWDIO)
201
#define LINE_SWCLK                  PAL_LINE(GPIOA, GPIOA_SWCLK)
202
#define LINE_RS232_R_EN_N           PAL_LINE(GPIOA, GPIOA_RS232_R_EN_N)
203
204
#define LINE_SW_V33_EN              PAL_LINE(GPIOB, GPIOB_SW_V33_EN)
205
#define LINE_SW_V42_EN              PAL_LINE(GPIOB, GPIOB_SW_V42_EN)
206
#define LINE_SW_V50_EN              PAL_LINE(GPIOB, GPIOB_SW_V50_EN)
207
#define LINE_IO_3                   PAL_LINE(GPIOB, GPIOB_IO_3)
208
#define LINE_IO_5                   PAL_LINE(GPIOB, GPIOB_IO_5)
209
#define LINE_IO_6                   PAL_LINE(GPIOB, GPIOB_IO_6)
210
#define LINE_SYS_UART_DN            PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
211
#define LINE_IO_7                   PAL_LINE(GPIOB, GPIOB_IO_7)
212
#define LINE_IO_8                   PAL_LINE(GPIOB, GPIOB_IO_8)
213
#define LINE_I2C_SCL                PAL_LINE(GPIOB, GPIOB_I2C_SCL)
214
#define LINE_I2C_SDA                PAL_LINE(GPIOB, GPIOB_I2C_SDA)
215
#define LINE_SPI_SS_N               PAL_LINE(GPIOB, GPIOB_SPI_SS_N)
216
#define LINE_SPI_SCLK               PAL_LINE(GPIOB, GPIOB_SPI_SCLK)
217
#define LINE_SPI_MISO               PAL_LINE(GPIOB, GPIOB_SPI_MISO)
218
#define LINE_SPI_MOSI               PAL_LINE(GPIOB, GPIOB_SPI_MOSI)
219
220
#define LINE_IO_4                   PAL_LINE(GPIOC, GPIOC_IO_4)
221
#define LINE_IO_1                   PAL_LINE(GPIOC, GPIOC_IO_1)
222
#define LINE_IO_2                   PAL_LINE(GPIOC, GPIOC_IO_2)
223
#define LINE_LED                    PAL_LINE(GPIOC, GPIOC_LED)
224
#define LINE_LIGHT_XLAT             PAL_LINE(GPIOC, GPIOC_LIGHT_XLAT)
225
#define LINE_SW_V18_EN              PAL_LINE(GPIOC, GPIOC_SW_V18_EN)
226
#define LINE_SW_VSYS_EN             PAL_LINE(GPIOC, GPIOC_SW_VSYS_EN)
227
#define LINE_SYS_UART_UP            PAL_LINE(GPIOC, GPIOC_SYS_UART_UP)
228
#define LINE_SYS_UART_RX            PAL_LINE(GPIOC, GPIOC_SYS_UART_RX)
229
#define LINE_SYS_UART_TX            PAL_LINE(GPIOC, GPIOC_SYS_UART_TX)
230
#define LINE_RS232_D_OFF_N          PAL_LINE(GPIOC, GPIOC_RS232_D_OFF_N)
231
#define LINE_SYS_PD_N               PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
232
233
#define LINE_SYS_INT_N              PAL_LINE(GPIOD, GPIOD_SYS_INT_N)
234
235
/*
236
 * I/O ports initial setup, this configuration is established soon after reset
237
 * in the initialization code.
238
 * Please refer to the STM32 Reference Manual for details.
239
 */
240
#define PIN_MODE_INPUT              0U
241
#define PIN_MODE_OUTPUT_2M          2U
242
#define PIN_MODE_OUTPUT_10M         1U
243
#define PIN_MODE_OUTPUT_50M         3U
244
#define PIN_CNF_INPUT_ANALOG        0U
245
#define PIN_CNF_INPUT_FLOATING      1U
246
#define PIN_CNF_INPUT_PULLX         2U
247
#define PIN_CNF_OUTPUT_PUSHPULL     0U
248
#define PIN_CNF_OUTPUT_OPENDRAIN    1U
249
#define PIN_CNF_ALTERNATE_PUSHPULL  2U
250
#define PIN_CNF_ALTERNATE_OPENDRAIN 3U
251
#define PIN_CR(pin, mode, cnf)      (((mode) | ((cnf) << 2U)) << (((pin) % 8U) * 4U))
252
#define PIN_ODR_LOW(n)              (0U << (n))
253
#define PIN_ODR_HIGH(n)             (1U << (n))
254
#define PIN_IGNORE(n)               (1U << (n))
255
256
/*
257
 * GPIOA setup:
258
 *
259
 * PA0  - USART_CTS                 (alternate pushpull 50MHz)
260
 * PA1  - USART_RTS                 (alternate pushpull 50MHz)
261
 * PA2  - USART_RX                  (alternate pushpull 50MHz)
262
 * PA3  - USART_TX                  (input pullup)
263
 * PA4  - LIGHT_BLANK               (output pushpull high 50MHz)
264
 * PA5  - LIGHT_SCLK                (alternate pushpull 50MHz)
265
 * PA6  - LIGHT_MISO                (input pullup)
266
 * PA7  - LIGHT_MOSI                (alternate pushpull 50MHz)
267
 * PA8  - PIN8                      (input floating)
268
 * PA9  - PROG_RX                   (alternate pushpull 50MHz)
269
 * PA10 - PROG_TX                   (input pullup)
270
 * PA11 - CAN_RX                    (input floating)
271
 * PA12 - CAN_TX                    (alternate pushpull 50MHz)
272
 * PA13 - SWDIO                     (input pullup)
273
 * PA14 - SWCLK                     (input pullup)
274
 * PA15 - RS232_R_EN_N              (output opendrain low 50MHz)
275
 */
276
#define VAL_GPIOAIGN                0
277
#define VAL_GPIOACRL                (PIN_CR(GPIOA_USART_CTS, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
278
                                     PIN_CR(GPIOA_USART_RTS, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
279
                                     PIN_CR(GPIOA_USART_RX, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |   \
280
                                     PIN_CR(GPIOA_USART_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |               \
281
                                     PIN_CR(GPIOA_LIGHT_BLANK, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |   \
282
                                     PIN_CR(GPIOA_LIGHT_SCLK, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) | \
283
                                     PIN_CR(GPIOA_LIGHT_MISO, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |             \
284
                                     PIN_CR(GPIOA_LIGHT_MOSI, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL))
285
#define VAL_GPIOACRH                (PIN_CR(GPIOA_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
286
                                     PIN_CR(GPIOA_PROG_RX, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |    \
287
                                     PIN_CR(GPIOA_PROG_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                \
288
                                     PIN_CR(GPIOA_CAN_RX, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |              \
289
                                     PIN_CR(GPIOA_CAN_TX, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |     \
290
                                     PIN_CR(GPIOA_SWDIO, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                  \
291
                                     PIN_CR(GPIOA_SWCLK, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                  \
292
                                     PIN_CR(GPIOA_RS232_R_EN_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN))
293
#define VAL_GPIOAODR                (PIN_ODR_LOW(GPIOA_USART_CTS) |                                              \
294
                                     PIN_ODR_LOW(GPIOA_USART_RTS) |                                              \
295
                                     PIN_ODR_HIGH(GPIOA_USART_RX) |                                              \
296
                                     PIN_ODR_HIGH(GPIOA_USART_TX) |                                              \
297
                                     PIN_ODR_HIGH(GPIOA_LIGHT_BLANK) |                                           \
298
                                     PIN_ODR_HIGH(GPIOA_LIGHT_SCLK) |                                            \
299
                                     PIN_ODR_HIGH(GPIOA_LIGHT_MISO) |                                            \
300
                                     PIN_ODR_HIGH(GPIOA_LIGHT_MOSI) |                                            \
301
                                     PIN_ODR_LOW(GPIOA_PIN8) |                                                   \
302
                                     PIN_ODR_HIGH(GPIOA_PROG_RX) |                                               \
303
                                     PIN_ODR_HIGH(GPIOA_PROG_TX) |                                               \
304
                                     PIN_ODR_HIGH(GPIOA_CAN_RX) |                                                \
305
                                     PIN_ODR_HIGH(GPIOA_CAN_TX) |                                                \
306
                                     PIN_ODR_HIGH(GPIOA_SWDIO) |                                                 \
307
                                     PIN_ODR_HIGH(GPIOA_SWCLK) |                                                 \
308
                                     PIN_ODR_LOW(GPIOA_RS232_R_EN_N))
309
310
/*
311
 * GPIOB setup:
312
 *
313
 * PB0  - SW_V33_EN                 (output pushpull low 50MHz)
314
 * PB1  - SW_V42_EN                 (output pushpull low 50MHz)
315
 * PB2  - SW_V50_EN                 (output pushpull low 50MHz)
316
 * PB3  - IO_3                      (input floating)
317
 * PB4  - IO_5                      (input floating)
318
 * PB5  - IO_6                      (input floating)
319
 * PB6  - SYS_UART_DN               (output opendrain high 50MHz)
320
 * PB7  - PIN7                      (input foating)
321
 * PB8  - IO_7                      (input floating)
322
 * PB9  - IO_8                      (input floating)
323
 * PB10 - I2C_SCL                   (alternate opendrain 50MHz)
324
 * PB11 - I2C_SDA                   (alternate opendrain 50MHz)
325
 * PB12 - SPI_SS_N                  (output pushpull high 50MHz)
326
 * PB13 - SPI_SCLK                  (alternate pushpull 50MHz)
327
 * PB14 - SPI_MISO                  (input pullup)
328
 * PB15 - SPI_MOSI                  (alternate pushpull 50MHz)
329
 */
330
#define VAL_GPIOBIGN                (PIN_IGNORE(GPIOB_SYS_UART_DN)) & 0
331
#define VAL_GPIOBCRL                (PIN_CR(GPIOB_SW_V33_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |     \
332
                                     PIN_CR(GPIOB_SW_V42_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |     \
333
                                     PIN_CR(GPIOB_SW_V50_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |     \
334
                                     PIN_CR(GPIOB_IO_3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
335
                                     PIN_CR(GPIOB_IO_5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
336
                                     PIN_CR(GPIOB_IO_6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
337
                                     PIN_CR(GPIOB_SYS_UART_DN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |  \
338
                                     PIN_CR(GPIOB_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
339
#define VAL_GPIOBCRH                (PIN_CR(GPIOB_IO_7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
340
                                     PIN_CR(GPIOB_IO_8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
341
                                     PIN_CR(GPIOB_I2C_SCL, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) |   \
342
                                     PIN_CR(GPIOB_I2C_SDA, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) |   \
343
                                     PIN_CR(GPIOB_SPI_SS_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |      \
344
                                     PIN_CR(GPIOB_SPI_SCLK, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |   \
345
                                     PIN_CR(GPIOB_SPI_MISO, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |               \
346
                                     PIN_CR(GPIOB_SPI_MOSI, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL))
347
#define VAL_GPIOBODR                (PIN_ODR_LOW(GPIOB_SW_V33_EN) |                                              \
348
                                     PIN_ODR_LOW(GPIOB_SW_V42_EN) |                                              \
349
                                     PIN_ODR_LOW(GPIOB_SW_V50_EN) |                                              \
350
                                     PIN_ODR_LOW(GPIOB_IO_3) |                                                   \
351
                                     PIN_ODR_LOW(GPIOB_IO_5) |                                                   \
352
                                     PIN_ODR_LOW(GPIOB_IO_6) |                                                   \
353
                                     PIN_ODR_HIGH(GPIOB_SYS_UART_DN) |                                           \
354
                                     PIN_ODR_LOW(GPIOB_PIN7) |                                                   \
355
                                     PIN_ODR_LOW(GPIOB_IO_7) |                                                   \
356
                                     PIN_ODR_LOW(GPIOB_IO_8) |                                                   \
357
                                     PIN_ODR_HIGH(GPIOB_I2C_SCL) |                                               \
358
                                     PIN_ODR_HIGH(GPIOB_I2C_SDA) |                                               \
359
                                     PIN_ODR_HIGH(GPIOB_SPI_SS_N) |                                              \
360
                                     PIN_ODR_HIGH(GPIOB_SPI_SCLK) |                                              \
361
                                     PIN_ODR_HIGH(GPIOB_SPI_MISO) |                                              \
362
                                     PIN_ODR_HIGH(GPIOB_SPI_MOSI))
363
364
/*
365
 * GPIOC setup:
366
 *
367
 * PC0  - IO_4                      (input floating)
368
 * PC1  - IO_1                      (input floating)
369
 * PC2  - IO_2                      (input floating)
370
 * PC3  - LED                       (output opendrain high 50MHz)
371
 * PC4  - LIGHT_XLAT                (output pushpull low 50MHz)
372
 * PC5  - SW_V18_EN                 (output pushpull low 50MHz)
373
 * PC6  - SW_VSYS_EN                (output pushpull low 50MHz)
374
 * PC7  - SYS_UART_UP               (output opendrain high 50MHz)
375
 * PC8  - PIN8                      (input floating)
376
 * PC9  - PIN9                      (input floating)
377
 * PC10 - SYS_UART_RX               (input pullup)
378
 * PC11 - SYS_UART_TX               (input pullup)
379
 * PC12 - RS232_D_OFF_N             (output puspull low 50MHz)
380
 * PC13 - PIN13                     (input floating)
381
 * PC14 - SYS_PD_N                  (output opendrain high 50MHz)
382
 * PC15 - PIN15                     (input floating)
383
 */
384
#define VAL_GPIOCIGN                (PIN_IGNORE(GPIOC_SYS_PD_N)) & 0
385
#define VAL_GPIOCCRL                (PIN_CR(GPIOC_IO_4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
386
                                     PIN_CR(GPIOC_IO_1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
387
                                     PIN_CR(GPIOC_IO_2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
388
                                     PIN_CR(GPIOC_LED, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |          \
389
                                     PIN_CR(GPIOC_LIGHT_XLAT, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |    \
390
                                     PIN_CR(GPIOC_SW_V18_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |     \
391
                                     PIN_CR(GPIOC_SW_VSYS_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |    \
392
                                     PIN_CR(GPIOC_SYS_UART_UP, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN))
393
#define VAL_GPIOCCRH                (PIN_CR(GPIOC_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
394
                                     PIN_CR(GPIOC_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
395
                                     PIN_CR(GPIOC_SYS_UART_RX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |            \
396
                                     PIN_CR(GPIOC_SYS_UART_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |            \
397
                                     PIN_CR(GPIOC_RS232_D_OFF_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) | \
398
                                     PIN_CR(GPIOC_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
399
                                     PIN_CR(GPIOC_SYS_PD_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |     \
400
                                     PIN_CR(GPIOC_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
401
#define VAL_GPIOCODR                (PIN_ODR_LOW(GPIOC_IO_4) |                                                   \
402
                                     PIN_ODR_LOW(GPIOC_IO_1) |                                                   \
403
                                     PIN_ODR_LOW(GPIOC_IO_2) |                                                   \
404
                                     PIN_ODR_HIGH(GPIOC_LED) |                                                   \
405
                                     PIN_ODR_LOW(GPIOC_LIGHT_XLAT) |                                             \
406
                                     PIN_ODR_LOW(GPIOC_SW_V18_EN) |                                              \
407
                                     PIN_ODR_LOW(GPIOC_SW_VSYS_EN) |                                             \
408
                                     PIN_ODR_HIGH(GPIOC_SYS_UART_UP) |                                           \
409
                                     PIN_ODR_LOW(GPIOC_PIN8) |                                                   \
410
                                     PIN_ODR_LOW(GPIOC_PIN9) |                                                   \
411
                                     PIN_ODR_HIGH(GPIOC_SYS_UART_RX) |                                           \
412
                                     PIN_ODR_HIGH(GPIOC_SYS_UART_TX) |                                           \
413
                                     PIN_ODR_LOW(GPIOC_RS232_D_OFF_N) |                                          \
414
                                     PIN_ODR_LOW(GPIOC_PIN13) |                                                  \
415
                                     PIN_ODR_HIGH(GPIOC_SYS_PD_N) |                                              \
416
                                     PIN_ODR_LOW(GPIOC_PIN15))
417
418
/*
419
 * GPIOD setup:
420
 *
421
 * PD0  - OSC_IN                    (input floating)
422
 * PD1  - OSC_OUT                   (input floating)
423
 * PD2  - SYS_INT_N                 (output opendrain low 50MHz)
424
 * PD3  - PIN3                      (input floating)
425
 * PD4  - PIN4                      (input floating)
426
 * PD5  - PIN5                      (input floating)
427
 * PD6  - PIN6                      (input floating)
428
 * PD7  - PIN7                      (input floating)
429
 * PD8  - PIN8                      (input floating)
430
 * PD9  - PIN9                      (input floating)
431
 * PD10 - PIN10                     (input floating)
432
 * PD11 - PIN11                     (input floating)
433
 * PD12 - PIN12                     (input floating)
434
 * PD13 - PIN13                     (input floating)
435
 * PD14 - PIN14                     (input floating)
436
 * PD15 - PIN15                     (input floating)
437
 */
438
#define VAL_GPIODIGN                (PIN_IGNORE(GPIOD_SYS_INT_N)) & 0
439
#define VAL_GPIODCRL                (PIN_CR(GPIOD_OSC_IN, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |              \
440
                                     PIN_CR(GPIOD_OSC_OUT, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |             \
441
                                     PIN_CR(GPIOD_SYS_INT_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |    \
442
                                     PIN_CR(GPIOD_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
443
                                     PIN_CR(GPIOD_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
444
                                     PIN_CR(GPIOD_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
445
                                     PIN_CR(GPIOD_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
446
                                     PIN_CR(GPIOD_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
447
#define VAL_GPIODCRH                (PIN_CR(GPIOD_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
448
                                     PIN_CR(GPIOD_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
449
                                     PIN_CR(GPIOD_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
450
                                     PIN_CR(GPIOD_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
451
                                     PIN_CR(GPIOD_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
452
                                     PIN_CR(GPIOD_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
453
                                     PIN_CR(GPIOD_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
454
                                     PIN_CR(GPIOD_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
455
#define VAL_GPIODODR                (PIN_ODR_HIGH(GPIOD_OSC_IN) |                                                \
456
                                     PIN_ODR_HIGH(GPIOD_OSC_OUT) |                                               \
457
                                     PIN_ODR_LOW(GPIOD_SYS_INT_N) |                                             \
458
                                     PIN_ODR_LOW(GPIOD_PIN3) |                                                   \
459
                                     PIN_ODR_LOW(GPIOD_PIN4) |                                                   \
460
                                     PIN_ODR_LOW(GPIOD_PIN5) |                                                   \
461
                                     PIN_ODR_LOW(GPIOD_PIN6) |                                                   \
462
                                     PIN_ODR_LOW(GPIOD_PIN7) |                                                   \
463
                                     PIN_ODR_LOW(GPIOD_PIN8) |                                                   \
464
                                     PIN_ODR_LOW(GPIOD_PIN9) |                                                   \
465
                                     PIN_ODR_LOW(GPIOD_PIN10) |                                                  \
466
                                     PIN_ODR_LOW(GPIOD_PIN11) |                                                  \
467
                                     PIN_ODR_LOW(GPIOD_PIN12) |                                                  \
468
                                     PIN_ODR_LOW(GPIOD_PIN13) |                                                  \
469
                                     PIN_ODR_LOW(GPIOD_PIN14) |                                                  \
470
                                     PIN_ODR_LOW(GPIOD_PIN15))
471
472
/*
473
 * GPIOE setup:
474
 *
475
 * PE0  - PIN0                      (input floating)
476
 * PE1  - PIN1                      (input floating)
477
 * PE2  - PIN2                      (input floating)
478
 * PE3  - PIN3                      (input floating)
479
 * PE4  - PIN4                      (input floating)
480
 * PE5  - PIN5                      (input floating)
481
 * PE6  - PIN6                      (input floating)
482
 * PE7  - PIN7                      (input floating)
483
 * PE8  - PIN8                      (input floating)
484
 * PE9  - PIN9                      (input floating)
485
 * PE10 - PIN10                     (input floating)
486
 * PE11 - PIN11                     (input floating)
487
 * PE12 - PIN12                     (input floating)
488
 * PE13 - PIN13                     (input floating)
489
 * PE14 - PIN14                     (input floating)
490
 * PE15 - PIN15                     (input floating)
491
 */
492
#define VAL_GPIOEIGN                0
493
#define VAL_GPIOECRL                (PIN_CR(GPIOE_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
494
                                     PIN_CR(GPIOE_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
495
                                     PIN_CR(GPIOE_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
496
                                     PIN_CR(GPIOE_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
497
                                     PIN_CR(GPIOE_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
498
                                     PIN_CR(GPIOE_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
499
                                     PIN_CR(GPIOE_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
500
                                     PIN_CR(GPIOE_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
501
#define VAL_GPIOECRH                (PIN_CR(GPIOE_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
502
                                     PIN_CR(GPIOE_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
503
                                     PIN_CR(GPIOE_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
504
                                     PIN_CR(GPIOE_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
505
                                     PIN_CR(GPIOE_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
506
                                     PIN_CR(GPIOE_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
507
                                     PIN_CR(GPIOE_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
508
                                     PIN_CR(GPIOE_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
509
#define VAL_GPIOEODR                (PIN_ODR_LOW(GPIOE_PIN0) |                                                     \
510
                                     PIN_ODR_LOW(GPIOE_PIN1) |                                                     \
511
                                     PIN_ODR_LOW(GPIOE_PIN2) |                                                     \
512
                                     PIN_ODR_LOW(GPIOE_PIN3) |                                                     \
513
                                     PIN_ODR_LOW(GPIOE_PIN4) |                                                     \
514
                                     PIN_ODR_LOW(GPIOE_PIN5) |                                                     \
515
                                     PIN_ODR_LOW(GPIOE_PIN6) |                                                     \
516
                                     PIN_ODR_LOW(GPIOE_PIN7) |                                                     \
517
                                     PIN_ODR_LOW(GPIOE_PIN8) |                                                     \
518
                                     PIN_ODR_LOW(GPIOE_PIN9) |                                                     \
519
                                     PIN_ODR_LOW(GPIOE_PIN10) |                                                    \
520
                                     PIN_ODR_LOW(GPIOE_PIN11) |                                                    \
521
                                     PIN_ODR_LOW(GPIOE_PIN12) |                                                    \
522
                                     PIN_ODR_LOW(GPIOE_PIN13) |                                                    \
523
                                     PIN_ODR_LOW(GPIOE_PIN14) |                                                    \
524
                                     PIN_ODR_LOW(GPIOE_PIN15))
525
526
/*
527
 * GPIOF setup:
528
 *
529
 * PF0  - PIN0                      (input floating)
530
 * PF1  - PIN1                      (input floating)
531
 * PF2  - PIN2                      (input floating)
532
 * PF3  - PIN3                      (input floating)
533
 * PF4  - PIN4                      (input floating)
534
 * PF5  - PIN5                      (input floating)
535
 * PF6  - PIN6                      (input floating)
536
 * PF7  - PIN7                      (input floating)
537
 * PF8  - PIN8                      (input floating)
538
 * PF9  - PIN9                      (input floating)
539
 * PF10 - PIN10                     (input floating)
540
 * PF11 - PIN11                     (input floating)
541
 * PF12 - PIN12                     (input floating)
542
 * PF13 - PIN13                     (input floating)
543
 * PF14 - PIN14                     (input floating)
544
 * PF15 - PIN15                     (input floating)
545
 */
546
#define VAL_GPIOFIGN                0
547
#define VAL_GPIOFCRL                (PIN_CR(GPIOF_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
548
                                     PIN_CR(GPIOF_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
549
                                     PIN_CR(GPIOF_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
550
                                     PIN_CR(GPIOF_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
551
                                     PIN_CR(GPIOF_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
552
                                     PIN_CR(GPIOF_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
553
                                     PIN_CR(GPIOF_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
554
                                     PIN_CR(GPIOF_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
555
#define VAL_GPIOFCRH                (PIN_CR(GPIOF_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
556
                                     PIN_CR(GPIOF_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
557
                                     PIN_CR(GPIOF_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
558
                                     PIN_CR(GPIOF_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
559
                                     PIN_CR(GPIOF_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
560
                                     PIN_CR(GPIOF_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
561
                                     PIN_CR(GPIOF_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
562
                                     PIN_CR(GPIOF_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
563
#define VAL_GPIOFODR                (PIN_ODR_LOW(GPIOF_PIN0) |                                                     \
564
                                     PIN_ODR_LOW(GPIOF_PIN1) |                                                     \
565
                                     PIN_ODR_LOW(GPIOF_PIN2) |                                                     \
566
                                     PIN_ODR_LOW(GPIOF_PIN3) |                                                     \
567
                                     PIN_ODR_LOW(GPIOF_PIN4) |                                                     \
568
                                     PIN_ODR_LOW(GPIOF_PIN5) |                                                     \
569
                                     PIN_ODR_LOW(GPIOF_PIN6) |                                                     \
570
                                     PIN_ODR_LOW(GPIOF_PIN7) |                                                     \
571
                                     PIN_ODR_LOW(GPIOF_PIN8) |                                                     \
572
                                     PIN_ODR_LOW(GPIOF_PIN9) |                                                     \
573
                                     PIN_ODR_LOW(GPIOF_PIN10) |                                                    \
574
                                     PIN_ODR_LOW(GPIOF_PIN11) |                                                    \
575
                                     PIN_ODR_LOW(GPIOF_PIN12) |                                                    \
576
                                     PIN_ODR_LOW(GPIOF_PIN13) |                                                    \
577
                                     PIN_ODR_LOW(GPIOF_PIN14) |                                                    \
578
                                     PIN_ODR_LOW(GPIOF_PIN15))
579
580
/*
581
 * GPIOG setup:
582
 *
583
 * PG0  - PIN0                      (input floating)
584
 * PG1  - PIN1                      (input floating)
585
 * PG2  - PIN2                      (input floating)
586
 * PG3  - PIN3                      (input floating)
587
 * PG4  - PIN4                      (input floating)
588
 * PG5  - PIN5                      (input floating)
589
 * PG6  - PIN6                      (input floating)
590
 * PG7  - PIN7                      (input floating)
591
 * PG8  - PIN8                      (input floating)
592
 * PG9  - PIN9                      (input floating)
593
 * PG10 - PIN10                     (input floating)
594
 * PG11 - PIN11                     (input floating)
595
 * PG12 - PIN12                     (input floating)
596
 * PG13 - PIN13                     (input floating)
597
 * PG14 - PIN14                     (input floating)
598
 * PG15 - PIN15                     (input floating)
599
 */
600
#define VAL_GPIOGIGN                0
601
#define VAL_GPIOGCRL                (PIN_CR(GPIOG_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
602
                                     PIN_CR(GPIOG_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
603
                                     PIN_CR(GPIOG_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
604
                                     PIN_CR(GPIOG_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
605
                                     PIN_CR(GPIOG_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
606
                                     PIN_CR(GPIOG_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
607
                                     PIN_CR(GPIOG_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
608
                                     PIN_CR(GPIOG_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
609
#define VAL_GPIOGCRH                (PIN_CR(GPIOG_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
610
                                     PIN_CR(GPIOG_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
611
                                     PIN_CR(GPIOG_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
612
                                     PIN_CR(GPIOG_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
613
                                     PIN_CR(GPIOG_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
614
                                     PIN_CR(GPIOG_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
615
                                     PIN_CR(GPIOG_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
616
                                     PIN_CR(GPIOG_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
617
#define VAL_GPIOGODR                (PIN_ODR_LOW(GPIOG_PIN0) |                                                     \
618
                                     PIN_ODR_LOW(GPIOG_PIN1) |                                                     \
619
                                     PIN_ODR_LOW(GPIOG_PIN2) |                                                     \
620
                                     PIN_ODR_LOW(GPIOG_PIN3) |                                                     \
621
                                     PIN_ODR_LOW(GPIOG_PIN4) |                                                     \
622
                                     PIN_ODR_LOW(GPIOG_PIN5) |                                                     \
623
                                     PIN_ODR_LOW(GPIOG_PIN6) |                                                     \
624
                                     PIN_ODR_LOW(GPIOG_PIN7) |                                                     \
625
                                     PIN_ODR_LOW(GPIOG_PIN8) |                                                     \
626
                                     PIN_ODR_LOW(GPIOG_PIN9) |                                                     \
627
                                     PIN_ODR_LOW(GPIOG_PIN10) |                                                    \
628
                                     PIN_ODR_LOW(GPIOG_PIN11) |                                                    \
629
                                     PIN_ODR_LOW(GPIOG_PIN12) |                                                    \
630
                                     PIN_ODR_LOW(GPIOG_PIN13) |                                                    \
631
                                     PIN_ODR_LOW(GPIOG_PIN14) |                                                    \
632
                                     PIN_ODR_LOW(GPIOG_PIN15))
633
634
#if !defined(_FROM_ASM_)
635
#ifdef __cplusplus
636
extern "C" {
637
#endif
638
  void boardInit(void);
639
#ifdef __cplusplus
640
}
641
#endif
642
#endif /* _FROM_ASM_ */
643
644
#endif /* BOARD_H */
645
646
/** @} */