Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (107.803 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2018  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
 * Setup for AMiRo PowerManagement v1.1 board.
24
 */
25

    
26
/*
27
 * Board identifier.
28
 */
29
#define BOARD_POWERMANAGEMENT
30
#define BOARD_NAME                      "AMiRo PowerManagement"
31
#define BOARD_VERSION                   "1.1"
32

    
33
/*
34
 * Board oscillators-related settings.
35
 * NOTE: LSE not fitted.
36
 */
37
#if !defined(STM32_LSECLK)
38
#define STM32_LSECLK                    0U
39
#endif
40

    
41
#if !defined(STM32_HSECLK)
42
#define STM32_HSECLK                    8000000U
43
#endif
44

    
45
/*
46
 * Board voltages.
47
 * Required for performance limits calculation.
48
 */
49
#define STM32_VDD                       330U
50

    
51
/*
52
 * MCU type as defined in the ST header.
53
 */
54
#define STM32F405xx
55

    
56
/*
57
 * STM32F4 alternate function definitions
58
 */
59
#define STM32F4xx_AF_system             0U
60
#define STM32F4xx_AF_TIM1to2            1U
61
#define STM32F4xx_AF_TIM3to5            2U
62
#define STM32F4xx_AF_TIM8to11           3U
63
#define STM32F4xx_AF_I2C1to3            4U
64
#define STM32F4xx_AF_SPI1to2            5U
65
#define STM32F4xx_AF_SPI3               6U
66
#define STM32F4xx_AF_USART1to3          7U
67
#define STM32F4xx_AF_USART4to6          8U
68
#define STM32F4xx_AF_CAN1to2_TIM12to14  9U
69
#define STM32F4xx_AF_OTG_HSFS           10U
70
#define STM32F4xx_AF_ETH                11U
71
#define STM32F4xx_AF_FSMC_SDIO_OTGHS    12U
72
#define STM32F4xx_AF_DCMI               13U
73
#define STM32F4xx_AF_EVENTOUT           15U
74

    
75
/*
76
 * IO pins assignments.
77
 */
78
#define GPIOA_WKUP                      0U
79
#define GPIOA_PIN1                      1U
80
#define GPIOA_SYS_UART_TX               2U
81
#define GPIOA_SYS_UART_RX               3U
82
#define GPIOA_SYS_SPI_SS0_N             4U
83
#define GPIOA_SYS_SPI_SCLK              5U
84
#define GPIOA_SYS_SPI_MISO              6U
85
#define GPIOA_SYS_SPI_MOSI              7U
86
#define GPIOA_SYS_REG_EN                8U
87
#define GPIOA_PROG_RX                   9U
88
#define GPIOA_PROG_TX                   10U
89
#define GPIOA_CAN_RX                    11U
90
#define GPIOA_CAN_TX                    12U
91
#define GPIOA_SWDIO                     13U
92
#define GPIOA_SWCLK                     14U
93
#define GPIOA_SYS_SPI_SS1_N             15U
94

    
95
#define GPIOB_IR_INT1_N                 0U
96
#define GPIOB_VSYS_SENSE                1U
97
#define GPIOB_POWER_EN                  2U
98
#define GPIOB_SYS_UART_DN               3U
99
#define GPIOB_CHARGE_STAT2A             4U
100
#define GPIOB_BUZZER                    5U
101
#define GPIOB_GAUGE_BATLOW2             6U
102
#define GPIOB_GAUGE_BATGD2_N            7U
103
#define GPIOB_GAUGE_SCL2                8U
104
#define GPIOB_GAUGE_SDA2                9U
105
#define GPIOB_GAUGE_SCL1                10U
106
#define GPIOB_GAUGE_SDA1                11U
107
#define GPIOB_LED                       12U
108
#define GPIOB_BT_RTS                    13U
109
#define GPIOB_BT_CTS                    14U
110
#define GPIOB_SYS_UART_UP               15U
111

    
112
#define GPIOC_CHARGE_STAT1A             0U
113
#define GPIOC_GAUGE_BATLOW1             1U
114
#define GPIOC_GAUGE_BATGD1_N            2U
115
#define GPIOC_CHARGE_EN1_N              3U
116
#define GPIOC_IR_INT2_N                 4U
117
#define GPIOC_TOUCH_INT_N               5U
118
#define GPIOC_SYS_DONE                  6U
119
#define GPIOC_SYS_PROG_N                7U
120
#define GPIOC_PATH_DC                   8U
121
#define GPIOC_SYS_SPI_DIR               9U
122
#define GPIOC_BT_RX                     10U
123
#define GPIOC_BT_TX                     11U
124
#define GPIOC_SYS_INT_N                 12U
125
#define GPIOC_SYS_PD_N                  13U
126
#define GPIOC_SYS_WARMRST_N             14U
127
#define GPIOC_BT_RST                    15U
128

    
129
#define GPIOD_PIN0                      0U
130
#define GPIOD_PIN1                      1U
131
#define GPIOD_CHARGE_EN2_N              2U
132
#define GPIOD_PIN3                      3U
133
#define GPIOD_PIN4                      4U
134
#define GPIOD_PIN5                      5U
135
#define GPIOD_PIN6                      6U
136
#define GPIOD_PIN7                      7U
137
#define GPIOD_PIN8                      8U
138
#define GPIOD_PIN9                      9U
139
#define GPIOD_PIN10                     10U
140
#define GPIOD_PIN11                     11U
141
#define GPIOD_PIN12                     12U
142
#define GPIOD_PIN13                     13U
143
#define GPIOD_PIN14                     14U
144
#define GPIOD_PIN15                     15U
145

    
146
#define GPIOE_PIN0                      0U
147
#define GPIOE_PIN1                      1U
148
#define GPIOE_PIN2                      2U
149
#define GPIOE_PIN3                      3U
150
#define GPIOE_PIN4                      4U
151
#define GPIOE_PIN5                      5U
152
#define GPIOE_PIN6                      6U
153
#define GPIOE_PIN7                      7U
154
#define GPIOE_PIN8                      8U
155
#define GPIOE_PIN9                      9U
156
#define GPIOE_PIN10                     10U
157
#define GPIOE_PIN11                     11U
158
#define GPIOE_PIN12                     12U
159
#define GPIOE_PIN13                     13U
160
#define GPIOE_PIN14                     14U
161
#define GPIOE_PIN15                     15U
162

    
163
#define GPIOF_PIN0                      0U
164
#define GPIOF_PIN1                      1U
165
#define GPIOF_PIN2                      2U
166
#define GPIOF_PIN3                      3U
167
#define GPIOF_PIN4                      4U
168
#define GPIOF_PIN5                      5U
169
#define GPIOF_PIN6                      6U
170
#define GPIOF_PIN7                      7U
171
#define GPIOF_PIN8                      8U
172
#define GPIOF_PIN9                      9U
173
#define GPIOF_PIN10                     10U
174
#define GPIOF_PIN11                     11U
175
#define GPIOF_PIN12                     12U
176
#define GPIOF_PIN13                     13U
177
#define GPIOF_PIN14                     14U
178
#define GPIOF_PIN15                     15U
179

    
180
#define GPIOG_PIN0                      0U
181
#define GPIOG_PIN1                      1U
182
#define GPIOG_PIN2                      2U
183
#define GPIOG_PIN3                      3U
184
#define GPIOG_PIN4                      4U
185
#define GPIOG_PIN5                      5U
186
#define GPIOG_PIN6                      6U
187
#define GPIOG_PIN7                      7U
188
#define GPIOG_PIN8                      8U
189
#define GPIOG_PIN9                      9U
190
#define GPIOG_PIN10                     10U
191
#define GPIOG_PIN11                     11U
192
#define GPIOG_PIN12                     12U
193
#define GPIOG_PIN13                     13U
194
#define GPIOG_PIN14                     14U
195
#define GPIOG_PIN15                     15U
196

    
197
#define GPIOH_OSC_IN                    0U
198
#define GPIOH_OSC_OUT                   1U
199
#define GPIOH_PIN2                      2U
200
#define GPIOH_PIN3                      3U
201
#define GPIOH_PIN4                      4U
202
#define GPIOH_PIN5                      5U
203
#define GPIOH_PIN6                      6U
204
#define GPIOH_PIN7                      7U
205
#define GPIOH_PIN8                      8U
206
#define GPIOH_PIN9                      9U
207
#define GPIOH_PIN10                     10U
208
#define GPIOH_PIN11                     11U
209
#define GPIOH_PIN12                     12U
210
#define GPIOH_PIN13                     13U
211
#define GPIOH_PIN14                     14U
212
#define GPIOH_PIN15                     15U
213

    
214
#define GPIOI_PIN0                      0U
215
#define GPIOI_PIN1                      1U
216
#define GPIOI_PIN2                      2U
217
#define GPIOI_PIN3                      3U
218
#define GPIOI_PIN4                      4U
219
#define GPIOI_PIN5                      5U
220
#define GPIOI_PIN6                      6U
221
#define GPIOI_PIN7                      7U
222
#define GPIOI_PIN8                      8U
223
#define GPIOI_PIN9                      9U
224
#define GPIOI_PIN10                     10U
225
#define GPIOI_PIN11                     11U
226
#define GPIOI_PIN12                     12U
227
#define GPIOI_PIN13                     13U
228
#define GPIOI_PIN14                     14U
229
#define GPIOI_PIN15                     15U
230

    
231
/*
232
 * IO lines assignments.
233
 */
234
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
235
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
236
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
237
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
238
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
239
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
240
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
241
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
242
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
243
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
244
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
245
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
246
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
247
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
248
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
249

    
250
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
251
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
252
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
253
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
254
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
255
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
256
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
257
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
258
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
259
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
260
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
261
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
262
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
263
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
264
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
265
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
266

    
267
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
268
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
269
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
270
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
271
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
272
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
273
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
274
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
275
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
276
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
277
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
278
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
279
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
280
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
281
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
282
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
283

    
284
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
285

    
286
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
287
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
288

    
289
/*
290
 * I/O ports initial setup, this configuration is established soon after reset
291
 * in the initialization code.
292
 * Please refer to the STM32 Reference Manual for details.
293
 */
294
#define PIN_MODE_INPUT(n)               (0U << ((n) * 2U))
295
#define PIN_MODE_OUTPUT(n)              (1U << ((n) * 2U))
296
#define PIN_MODE_ALTERNATE(n)           (2U << ((n) * 2U))
297
#define PIN_MODE_ANALOG(n)              (3U << ((n) * 2U))
298
#define PIN_ODR_LOW(n)                  (0U << (n))
299
#define PIN_ODR_HIGH(n)                 (1U << (n))
300
#define PIN_OTYPE_PUSHPULL(n)           (0U << (n))
301
#define PIN_OTYPE_OPENDRAIN(n)          (1U << (n))
302
#define PIN_OSPEED_LOW(n)               (0U << ((n) * 2U))
303
#define PIN_OSPEED_MEDIUM(n)            (1U << ((n) * 2U))
304
#define PIN_OSPEED_HIGH(n)              (2U << ((n) * 2U))
305
#define PIN_OSPEED_VERYHIGH(n)          (3U << ((n) * 2U))
306
#define PIN_PUPDR_FLOATING(n)           (0U << ((n) * 2U))
307
#define PIN_PUPDR_PULLUP(n)             (1U << ((n) * 2U))
308
#define PIN_PUPDR_PULLDOWN(n)           (2U << ((n) * 2U))
309
#define PIN_AFIO_AF(n, v)               ((v) << (((n) % 8U) * 4U))
310

    
311
/*
312
 * GPIOA setup:
313
 *
314
 * PA0  - WKUP                          (input floating)
315
 * PA1  - PIN1                          (input pullup)
316
 * PA2  - SYS_UART_TX                   (input float