Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / BI-Vital_5-1 / board.h @ 10853947

History | View | Annotate | Download (96.567 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2020  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
#ifndef BOARD_H
20
#define BOARD_H
21

    
22
/*===========================================================================*/
23
/* Driver constants.                                                         */
24
/*===========================================================================*/
25

    
26
/*
27
 * Setup for BI-Vital (BGv5.1) board.
28
 */
29

    
30
/*
31
 * Board identifier.
32
 */
33
#define BOARD_BIVITAL_BG51
34
#define BOARD_NAME                  "BI-Vital (BGv5.1)"
35

    
36
/*
37
 * Board oscillators-related settings.
38
 */
39
#if !defined(STM32_LSECLK)
40
#define STM32_LSECLK                32768U
41
#endif
42

    
43
#define STM32_LSEDRV                (3U << 3U)
44

    
45
#if !defined(STM32_HSECLK)
46
#define STM32_HSECLK                16000000U
47
#endif
48

    
49
#define STM32_HSE_BYPASS
50

    
51
/*
52
 * Board voltages.
53
 * Required for performance limits calculation.
54
 */
55
#define STM32_VDD                   180U
56

    
57
/*
58
 * MCU type as defined in the ST header.
59
 */
60
#define STM32L476xx
61

    
62
/*
63
 * IO pins assignments.
64
 */
65
#define GPIOA_RESP_IN               0U
66
#define GPIOA_ECG_IN                1U
67
#define GPIOA_PIN2                  2U
68
#define GPIOA_PIN3                  3U
69
#define GPIOA_RESP_REF              4U
70
#define GPIOA_ECG_REF               5U
71
#define GPIOA_QSPI_IO3              6U
72
#define GPIOA_QSPI_IO2              7U
73
#define GPIOA_PIN8                  8U
74
#define GPIOA_VCC_USB               9U
75
#define GPIOA_PWR_USB_ID            10U
76
#define GPIOA_PWR_USB_DM            11U
77
#define GPIOA_PWR_USB_DP            12U
78
#define GPIOA_SWDIO                 13U
79
#define GPIOA_SWCLK                 14U
80
#define GPIOA_UART_RTS              15U
81

    
82
#define GPIOB_QSPI_IO1              0U
83
#define GPIOB_QSPI_IO0              1U
84
#define GPIOB_MIC_EN                2U
85
#define GPIOB_SWO                   3U
86
#define GPIOB_RESET                 4U
87
#define GPIOB_PIN5                  5U
88
#define GPIOB_PIN6                  6U
89
#define GPIOB_UART_CTS              7U
90
#define GPIOB_MIC_IN                8U
91
#define GPIOB_PIN9                  9U
92
#define GPIOB_QSPI_CLK              10U
93
#define GPIOB_QSPI_NCS              11U
94
#define GPIOB_PWR_CD                12U
95
#define GPIOB_SCL                   13U
96
#define GPIOB_SDA                   14U
97
#define GPIOB_PIN15                 15U
98

    
99
#define GPIOC_PIN0                  0U
100
#define GPIOC_PIN1                  1U
101
#define GPIOC_MIC_CLK               2U
102
#define GPIOC_PIN3                  3U
103
#define GPIOC_QSPI_EN               4U
104
#define GPIOC_MCU_WKUP              5U
105
#define GPIOC_PIN6                  6U
106
#define GPIOC_BUZZ_OUT              7U
107
#define GPIOC_PC8                   8U
108
#define GPIOC_VIB_OUT               9U
109
#define GPIOC_UART_TX               10U
110
#define GPIOC_UART_RX               11U
111
#define GPIOC_PIN12                 12U
112
#define GPIOC_PIN13                 13U
113
#define GPIOC_OSC32_IN              14U
114
#define GPIOC_OSC32_OUT             15U
115

    
116
#define GPIOD_PIN0                  0U
117
#define GPIOD_PIN1                  1U
118
#define GPIOD_BUTTON                2U
119
#define GPIOD_PIN3                  3U
120
#define GPIOD_PIN4                  4U
121
#define GPIOD_PIN5                  5U
122
#define GPIOD_PIN6                  6U
123
#define GPIOD_PIN7                  7U
124
#define GPIOD_PIN8                  8U
125
#define GPIOD_PIN9                  9U
126
#define GPIOD_PIN10                 10U
127
#define GPIOD_PIN11                 11U
128
#define GPIOD_PIN12                 12U
129
#define GPIOD_PIN13                 13U
130
#define GPIOD_PIN14                 14U
131
#define GPIOD_PIN15                 15U
132

    
133
#define GPIOE_PIN0                  0U
134
#define GPIOE_PIN1                  1U
135
#define GPIOE_PIN2                  2U
136
#define GPIOE_PIN3                  3U
137
#define GPIOE_PIN4                  4U
138
#define GPIOE_PIN5                  5U
139
#define GPIOE_PIN6                  6U
140
#define GPIOE_PIN7                  7U
141
#define GPIOE_PIN8                  8U
142
#define GPIOE_PIN9                  9U
143
#define GPIOE_PIN10                 10U
144
#define GPIOE_PIN11                 11U
145
#define GPIOE_PIN12                 12U
146
#define GPIOE_PIN13                 13U
147
#define GPIOE_PIN14                 14U
148
#define GPIOE_PIN15                 15U
149

    
150
#define GPIOF_PIN0                  0U
151
#define GPIOF_PIN1                  1U
152
#define GPIOF_PIN2                  2U
153
#define GPIOF_PIN3                  3U
154
#define GPIOF_PIN4                  4U
155
#define GPIOF_PIN5                  5U
156
#define GPIOF_PIN6                  6U
157
#define GPIOF_PIN7                  7U
158
#define GPIOF_PIN8                  8U
159
#define GPIOF_PIN9                  9U
160
#define GPIOF_PIN10                 10U
161
#define GPIOF_PIN11                 11U
162
#define GPIOF_PIN12                 12U
163
#define GPIOF_PIN13                 13U
164
#define GPIOF_PIN14                 14U
165
#define GPIOF_PIN15                 15U
166

    
167
#define GPIOG_PIN0                  0U
168
#define GPIOG_PIN1                  1U
169
#define GPIOG_PIN2                  2U
170
#define GPIOG_PIN3                  3U
171
#define GPIOG_PIN4                  4U
172
#define GPIOG_PIN5                  5U
173
#define GPIOG_PIN6                  6U
174
#define GPIOG_PIN7                  7U
175
#define GPIOG_PIN8                  8U
176
#define GPIOG_LED_R                 9U
177
#define GPIOG_LED_G                 10U
178
#define GPIOG_PIN11                 11U
179
#define GPIOG_PIN12                 12U
180
#define GPIOG_PIN13                 13U
181
#define GPIOG_LED_B                 14U
182
#define GPIOG_PIN15                 15U
183

    
184
#define GPIOH_OSC_IN                0U
185
#define GPIOH_OSC_OUT               1U
186
#define GPIOH_PIN2                  2U
187
#define GPIOH_PIN3                  3U
188
#define GPIOH_PIN4                  4U
189
#define GPIOH_PIN5                  5U
190
#define GPIOH_PIN6                  6U
191
#define GPIOH_PIN7                  7U
192
#define GPIOH_PIN8                  8U
193
#define GPIOH_PIN9                  9U
194
#define GPIOH_PIN10                 10U
195
#define GPIOH_PIN11                 11U
196
#define GPIOH_PIN12                 12U
197
#define GPIOH_PIN13                 13U
198
#define GPIOH_PIN14                 14U
199
#define GPIOH_PIN15                 15U
200

    
201
/*
202
 * IO lines assignments.
203
 */
204
#define LINE_RESP_IN                PAL_LINE(GPIOA, GPIOA_RESP_IN)
205
#define LINE_ECG_IN                 PAL_LINE(GPIOA, GPIOA_ECG_IN)
206
#define LINE_RESP_REF               PAL_LINE(GPIOA, GPIOA_RESP_REF)
207
#define LINE_ECG_REF                PAL_LINE(GPIOA, GPIOA_ECG_REF)
208
#define LINE_QSPI_IO3               PAL_LINE(GPIOA, GPIOA_QSPI_IO3)
209
#define LINE_QSPI_IO2               PAL_LINE(GPIOA, GPIOA_QSPI_IO2)
210
#define LINE_VCC_USB                PAL_LINE(GPIOA, GPIOA_VCC_USB)
211
#define LINE_PWR_USB_ID             PAL_LINE(GPIOA, GPIOA_PWR_USB_ID)
212
#define LINE_PWR_USB_DM             PAL_LINE(GPIOA, GPIOA_PWR_USB_DM)
213
#define LINE_PWR_USB_DP             PAL_LINE(GPIOA, GPIOA_PWR_USB_DP)
214
#define LINE_SWDIO                  PAL_LINE(GPIOA, GPIOA_SWDIO)
215
#define LINE_SWCLK                  PAL_LINE(GPIOA, GPIOA_SWCLK)
216
#define LINE_UART_RTS               PAL_LINE(GPIOA, GPIOA_UART_RTS)
217

    
218
#define LINE_QSPI_IO1               PAL_LINE(GPIOB, GPIOB_QSPI_IO1)
219
#define LINE_QSPI_IO0               PAL_LINE(GPIOB, GPIOB_QSPI_IO0)
220
#define LINE_MIC_EN                 PAL_LINE(GPIOB, GPIOB_MIC_EN)
221
#define LINE_SWO                    PAL_LINE(GPIOB, GPIOB_SWO)
222
#define LINE_RESET                  PAL_LINE(GPIOB, GPIOB_RESET)
223
#define LINE_UART_CTS               PAL_LINE(GPIOB, GPIOB_UART_CTS)
224
#define LINE_MIC_IN                 PAL_LINE(GPIOB, GPIOB_MIC_IN)
225
#define LINE_QSPI_CLK               PAL_LINE(GPIOB, GPIOB_QSPI_CLK)
226
#define LINE_QSPI_NCS               PAL_LINE(GPIOB, GPIOB_QSPI_NCS)
227
#define LINE_PWR_CD                 PAL_LINE(GPIOB, GPIOB_PWR_CD)
228
#define LINE_SCL                    PAL_LINE(GPIOB, GPIOB_SCL)
229
#define LINE_SDA                    PAL_LINE(GPIOB, GPIOB_SDA)
230

    
231
#define LINE_MIC_CLK                PAL_LINE(GPIOC, GPIOC_MIC_CLK)
232
#define LINE_QSPI_EN                PAL_LINE(GPIOC, GPIOC_QSPI_EN)
233
#define LINE_MCU_WKUP               PAL_LINE(GPIOC, GPIOC_MCU_WKUP)
234
#define LINE_BUZZ_OUT               PAL_LINE(GPIOC, GPIOC_BUZZ_OUT)
235
#define LINE_VIB_OUT                PAL_LINE(GPIOC, GPIOC_VIB_OUT)
236
#define LINE_UART_TX                PAL_LINE(GPIOC, GPIOC_UART_TX)
237
#define LINE_UART_RX                PAL_LINE(GPIOC, GPIOC_UART_RX)
238
#define LINE_OSC32_IN               PAL_LINE(GPIOC, GPIOC_OSC32_IN)
239
#define LINE_OSC32_OUT              PAL_LINE(GPIOC, GPIOC_OSC32_OUT)
240

    
241
#define LINE_BUTTON                 PAL_LINE(GPIOD, GPIOD_BUTTON)
242

    
243
#define LINE_LED_R                  PAL_LINE(GPIOG, GPIOG_LED_R)
244
#define LINE_LED_G                  PAL_LINE(GPIOG, GPIOG_LED_G)
245
#define LINE_LED_B                  PAL_LINE(GPIOG, GPIOG_LED_B)
246

    
247
#define LINE_OSC_IN                 PAL_LINE(GPIOH, GPIOH_OSC_IN)
248
#define LINE_OSC_OUT                PAL_LINE(GPIOH, GPIOH_OSC_OUT)
249

    
250
/*===========================================================================*/
251
/* Driver pre-compile time settings.                                         */
252
/*===========================================================================*/
253

    
254
/*===========================================================================*/
255
/* Derived constants and error checks.                                       */
256
/*===========================================================================*/
257

    
258
/*===========================================================================*/
259
/* Driver data structures and types.                                         */
260
/*===========================================================================*/
261

    
262
/*===========================================================================*/
263
/* Driver macros.                                                            */
264
/*===========================================================================*/
265

    
266
/*
267
 * I/O ports initial setup, this configuration is established soon after reset
268
 * in the initialization code.
269
 * Please refer to the STM32 Reference Manual for details.
270
 */
271
#define PIN_MODE_INPUT(n)           (0U << ((n) * 2U))
272
#define PIN_MODE_OUTPUT(n)          (1U << ((n) * 2U))
273
#define PIN_MODE_ALTERNATE(n)       (2U << ((n) * 2U))
274
#define PIN_MODE_ANALOG(n)          (3U << ((n) * 2U))
275
#define PIN_ODR_LOW(n)              (0U << (n))
276
#define PIN_ODR_HIGH(n)             (1U << (n))
277
#define PIN_OTYPE_PUSHPULL(n)       (0U << (n))
278
#define PIN_OTYPE_OPENDRAIN(n)      (1U << (n))
279
#define PIN_OSPEED_VERYLOW(n)       (0U << ((n) * 2U))
280
#define PIN_OSPEED_LOW(n)           (1U << ((n) * 2U))
281
#define PIN_OSPEED_MEDIUM(n)        (2U << ((n) * 2U))
282
#define PIN_OSPEED_HIGH(n)          (3U << ((n) * 2U))
283
#define PIN_PUPDR_FLOATING(n)       (0U << ((n) * 2U))
284
#define PIN_PUPDR_PULLUP(n)         (1U << ((n) * 2U))
285
#define PIN_PUPDR_PULLDOWN(n)       (2U << ((n) * 2U))
286
#define PIN_AFIO_AF(n, v)           ((v) << (((n) % 8U) * 4U))
287
#define PIN_ASCR_DISABLED(n)        (0U << (n))
288
#define PIN_ASCR_ENABLED(n)         (1U << (n))
289
#define PIN_LOCKR_DISABLED(n)       (0U << (n))
290
#define PIN_LOCKR_ENABLED(n)        (1U << (n))
291

    
292
/*
293
 * GPIOA setup:
294
 *
295
 * PA0  - RESP_IN                   (analog).
296
 * PA1  - ECG_IN                    (analog).
297
 * PA2  - PIN2                      (analog).
298
 * PA3  - PIN3                      (analog).
299
 * PA4  - RESP_REF                  (analog).
300
 * PA5  - ECG_REF                   (analog).
301
 * PA6  - QSPI_IO3                  (analog).
302
 * PA7  - QSPI_IO2                  (analog).
303
 * PA8  - PIN8                      (analog).
304
 * PA9  - VCC_USB                   (analog).
305
 * PA10 - PWR_USB_ID                (analog).
306
 * PA11 - PWR_USB_DM                (analog).
307
 * PA12 - PWR_USB_DP                (analog).
308
 * PA13 - SWDIO                     (analog).
309
 * PA14 - SWCLK                     (analog).
310
 * PA15 - UART_RTS                  (analog).
311
 */
312
#define VAL_GPIOA_MODER             (PIN_MODE_ANALOG(GPIOA_RESP_IN) |       \
313
                                     PIN_MODE_ANALOG(GPIOA_ECG_IN |         \
314
                                     PIN_MODE_ANALOG(GPIOA_PIN2) |          \
315
                                     PIN_MODE_ANALOG(GPIOA_PIN3) |          \
316
                                     PIN_MODE_ANALOG(GPIOA_RESP_REF) |      \
317
                                     PIN_MODE_ANALOG(GPIOA_ECG_REF) |       \
318
                                     PIN_MODE_ANALOG(GPIOA_QSPI_IO3) |      \
319
                                     PIN_MODE_ANALOG(GPIOA_QSPI_IO2) |      \
320
                                     PIN_MODE_ANALOG(GPIOA_PIN8) |          \
321
                                     PIN_MODE_ANALOG(GPIOA_VCC_USB) |       \
322
                                     PIN_MODE_ANALOG(GPIOA_PWR_USB_ID) |    \
323
                                     PIN_MODE_ANALOG(GPIOA_PWR_USB_DM) |    \
324
                                     PIN_MODE_ANALOG(GPIOA_PWR_USB_DP) |    \
325
                                     PIN_MODE_ANALOG(GPIOA_SWDI