amiro-os / modules / STM32F407G-DISC1 / board.h @ 0f60c8ad
History | View | Annotate | Download (85.514 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 |
#ifndef BOARD_H
|
| 20 |
#define BOARD_H
|
| 21 |
|
| 22 |
/*===========================================================================*/
|
| 23 |
/* Driver constants. */
|
| 24 |
/*===========================================================================*/
|
| 25 |
|
| 26 |
/*
|
| 27 |
* Setup for STMicroelectronics STM32F4-Discovery board.
|
| 28 |
*/
|
| 29 |
|
| 30 |
/*
|
| 31 |
* Board identifier.
|
| 32 |
*/
|
| 33 |
#define BOARD_ST_STM32F4_DISCOVERY
|
| 34 |
#define BOARD_NAME "STMicroelectronics STM32F4-Discovery" |
| 35 |
|
| 36 |
/*
|
| 37 |
* Board oscillators-related settings.
|
| 38 |
* NOTE: LSE not fitted.
|
| 39 |
*/
|
| 40 |
#if !defined(STM32_LSECLK)
|
| 41 |
#define STM32_LSECLK 0U |
| 42 |
#endif
|
| 43 |
|
| 44 |
#if !defined(STM32_HSECLK)
|
| 45 |
#define STM32_HSECLK 8000000U |
| 46 |
#endif
|
| 47 |
|
| 48 |
/*
|
| 49 |
* Board voltages.
|
| 50 |
* Required for performance limits calculation.
|
| 51 |
*/
|
| 52 |
#define STM32_VDD 300U |
| 53 |
|
| 54 |
/*
|
| 55 |
* MCU type as defined in the ST header.
|
| 56 |
*/
|
| 57 |
#define STM32F407xx
|
| 58 |
|
| 59 |
/*
|
| 60 |
* IO pins assignments.
|
| 61 |
*/
|
| 62 |
#define GPIOA_BUTTON 0U |
| 63 |
#define GPIOA_PIN1 1U |
| 64 |
#define GPIOA_PIN2 2U |
| 65 |
#define GPIOA_PIN3 3U |
| 66 |
#define GPIOA_LRCK 4U |
| 67 |
#define GPIOA_SPC 5U |
| 68 |
#define GPIOA_SDO 6U |
| 69 |
#define GPIOA_SDI 7U |
| 70 |
#define GPIOA_PIN8 8U |
| 71 |
#define GPIOA_VBUS_FS 9U |
| 72 |
#define GPIOA_OTG_FS_ID 10U |
| 73 |
#define GPIOA_OTG_FS_DM 11U |
| 74 |
#define GPIOA_OTG_FS_DP 12U |
| 75 |
#define GPIOA_SWDIO 13U |
| 76 |
#define GPIOA_SWCLK 14U |
| 77 |
#define GPIOA_PIN15 15U |
| 78 |
|
| 79 |
#define GPIOB_PIN0 0U |
| 80 |
#define GPIOB_PIN1 1U |
| 81 |
#define GPIOB_PIN2 2U |
| 82 |
#define GPIOB_SWO 3U |
| 83 |
#define GPIOB_PIN4 4U |
| 84 |
#define GPIOB_PIN5 5U |
| 85 |
#define GPIOB_SCL 6U |
| 86 |
#define GPIOB_PIN7 7U |
| 87 |
#define GPIOB_PIN8 8U |
| 88 |
#define GPIOB_SDA 9U |
| 89 |
#define GPIOB_CLK_IN 10U |
| 90 |
#define GPIOB_PIN11 11U |
| 91 |
#define GPIOB_PIN12 12U |
| 92 |
#define GPIOB_PIN13 13U |
| 93 |
#define GPIOB_PIN14 14U |
| 94 |
#define GPIOB_PIN15 15U |
| 95 |
|
| 96 |
#define GPIOC_OTG_FS_POWER_ON 0U |
| 97 |
#define GPIOC_PIN1 1U |
| 98 |
#define GPIOC_PIN2 2U |
| 99 |
#define GPIOC_PDM_OUT 3U |
| 100 |
#define GPIOC_PIN4 4U |
| 101 |
#define GPIOC_PIN5 5U |
| 102 |
#define GPIOC_PIN6 6U |
| 103 |
#define GPIOC_MCLK 7U |
| 104 |
#define GPIOC_PIN8 8U |
| 105 |
#define GPIOC_PIN9 9U |
| 106 |
#define GPIOC_SCLK 10U |
| 107 |
#define GPIOC_PIN11 11U |
| 108 |
#define GPIOC_SDIN 12U |
| 109 |
#define GPIOC_PIN13 13U |
| 110 |
#define GPIOC_PIN14 14U |
| 111 |
#define GPIOC_PIN15 15U |
| 112 |
|
| 113 |
#define GPIOD_PIN0 0U |
| 114 |
#define GPIOD_PIN1 1U |
| 115 |
#define GPIOD_PIN2 2U |
| 116 |
#define GPIOD_PIN3 3U |
| 117 |
#define GPIOD_RESET 4U |
| 118 |
#define GPIOD_OVER_CURRENT 5U |
| 119 |
#define GPIOD_PIN6 6U |
| 120 |
#define GPIOD_PIN7 7U |
| 121 |
#define GPIOD_PIN8 8U |
| 122 |
#define GPIOD_PIN9 9U |
| 123 |
#define GPIOD_PIN10 10U |
| 124 |
#define GPIOD_PIN11 11U |
| 125 |
#define GPIOD_LED4 12U |
| 126 |
#define GPIOD_LED3 13U |
| 127 |
#define GPIOD_LED5 14U |
| 128 |
#define GPIOD_LED6 15U |
| 129 |
|
| 130 |
#define GPIOE_INT1 0U |
| 131 |
#define GPIOE_INT2 1U |
| 132 |
#define GPIOE_PIN2 2U |
| 133 |
#define GPIOE_CS_SPI 3U |
| 134 |
#define GPIOE_PIN4 4U |
| 135 |
#define GPIOE_PIN5 5U |
| 136 |
#define GPIOE_PIN6 6U |
| 137 |
#define GPIOE_PIN7 7U |
| 138 |
#define GPIOE_PIN8 8U |
| 139 |
#define GPIOE_PIN9 9U |
| 140 |
#define GPIOE_PIN10 10U |
| 141 |
#define GPIOE_PIN11 11U |
| 142 |
#define GPIOE_PIN12 12U |
| 143 |
#define GPIOE_PIN13 13U |
| 144 |
#define GPIOE_PIN14 14U |
| 145 |
#define GPIOE_PIN15 15U |
| 146 |
|
| 147 |
#define GPIOF_PIN0 0U |
| 148 |
#define GPIOF_PIN1 1U |
| 149 |
#define GPIOF_PIN2 2U |
| 150 |
#define GPIOF_PIN3 3U |
| 151 |
#define GPIOF_PIN4 4U |
| 152 |
#define GPIOF_PIN5 5U |
| 153 |
#define GPIOF_PIN6 6U |
| 154 |
#define GPIOF_PIN7 7U |
| 155 |
#define GPIOF_PIN8 8U |
| 156 |
#define GPIOF_PIN9 9U |
| 157 |
#define GPIOF_PIN10 10U |
| 158 |
#define GPIOF_PIN11 11U |
| 159 |
#define GPIOF_PIN12 12U |
| 160 |
#define GPIOF_PIN13 13U |
| 161 |
#define GPIOF_PIN14 14U |
| 162 |
#define GPIOF_PIN15 15U |
| 163 |
|
| 164 |
#define GPIOG_PIN0 0U |
| 165 |
#define GPIOG_PIN1 1U |
| 166 |
#define GPIOG_PIN2 2U |
| 167 |
#define GPIOG_PIN3 3U |
| 168 |
#define GPIOG_PIN4 4U |
| 169 |
#define GPIOG_PIN5 5U |
| 170 |
#define GPIOG_PIN6 6U |
| 171 |
#define GPIOG_PIN7 7U |
| 172 |
#define GPIOG_PIN8 8U |
| 173 |
#define GPIOG_PIN9 9U |
| 174 |
#define GPIOG_PIN10 10U |
| 175 |
#define GPIOG_PIN11 11U |
| 176 |
#define GPIOG_PIN12 12U |
| 177 |
#define GPIOG_PIN13 13U |
| 178 |
#define GPIOG_PIN14 14U |
| 179 |
#define GPIOG_PIN15 15U |
| 180 |
|
| 181 |
#define GPIOH_OSC_IN 0U |
| 182 |
#define GPIOH_OSC_OUT 1U |
| 183 |
#define GPIOH_PIN2 2U |
| 184 |
#define GPIOH_PIN3 3U |
| 185 |
#define GPIOH_PIN4 4U |
| 186 |
#define GPIOH_PIN5 5U |
| 187 |
#define GPIOH_PIN6 6U |
| 188 |
#define GPIOH_PIN7 7U |
| 189 |
#define GPIOH_PIN8 8U |
| 190 |
#define GPIOH_PIN9 9U |
| 191 |
#define GPIOH_PIN10 10U |
| 192 |
#define GPIOH_PIN11 11U |
| 193 |
#define GPIOH_PIN12 12U |
| 194 |
#define GPIOH_PIN13 13U |
| 195 |
#define GPIOH_PIN14 14U |
| 196 |
#define GPIOH_PIN15 15U |
| 197 |
|
| 198 |
#define GPIOI_PIN0 0U |
| 199 |
#define GPIOI_PIN1 1U |
| 200 |
#define GPIOI_PIN2 2U |
| 201 |
#define GPIOI_PIN3 3U |
| 202 |
#define GPIOI_PIN4 4U |
| 203 |
#define GPIOI_PIN5 5U |
| 204 |
#define GPIOI_PIN6 6U |
| 205 |
#define GPIOI_PIN7 7U |
| 206 |
#define GPIOI_PIN8 8U |
| 207 |
#define GPIOI_PIN9 9U |
| 208 |
#define GPIOI_PIN10 10U |
| 209 |
#define GPIOI_PIN11 11U |
| 210 |
#define GPIOI_PIN12 12U |
| 211 |
#define GPIOI_PIN13 13U |
| 212 |
#define GPIOI_PIN14 14U |
| 213 |
#define GPIOI_PIN15 15U |
| 214 |
|
| 215 |
/*
|
| 216 |
* IO lines assignments.
|
| 217 |
*/
|
| 218 |
#define LINE_BUTTON PAL_LINE(GPIOA, 0U) |
| 219 |
#define LINE_LRCK PAL_LINE(GPIOA, 4U) |
| 220 |
#define LINE_SPC PAL_LINE(GPIOA, 5U) |
| 221 |
#define LINE_SDO PAL_LINE(GPIOA, 6U) |
| 222 |
#define LINE_SDI PAL_LINE(GPIOA, 7U) |
| 223 |
#define LINE_VBUS_FS PAL_LINE(GPIOA, 9U) |
| 224 |
#define LINE_OTG_FS_ID PAL_LINE(GPIOA, 10U) |
| 225 |
#define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U) |
| 226 |
#define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U) |
| 227 |
#define LINE_SWDIO PAL_LINE(GPIOA, 13U) |
| 228 |
#define LINE_SWCLK PAL_LINE(GPIOA, 14U) |
| 229 |
#define LINE_SWO PAL_LINE(GPIOB, 3U) |
| 230 |
#define LINE_SCL PAL_LINE(GPIOB, 6U) |
| 231 |
#define LINE_SDA PAL_LINE(GPIOB, 9U) |
| 232 |
#define LINE_CLK_IN PAL_LINE(GPIOB, 10U) |
| 233 |
#define LINE_OTG_FS_POWER_ON PAL_LINE(GPIOC, 0U) |
| 234 |
#define LINE_PDM_OUT PAL_LINE(GPIOC, 3U) |
| 235 |
#define LINE_MCLK PAL_LINE(GPIOC, 7U) |
| 236 |
#define LINE_SCLK PAL_LINE(GPIOC, 10U) |
| 237 |
#define LINE_SDIN PAL_LINE(GPIOC, 12U) |
| 238 |
#define LINE_RESET PAL_LINE(GPIOD, 4U) |
| 239 |
#define LINE_OVER_CURRENT PAL_LINE(GPIOD, 5U) |
| 240 |
#define LINE_LED4 PAL_LINE(GPIOD, 12U) |
| 241 |
#define LINE_LED3 PAL_LINE(GPIOD, 13U) |
| 242 |
#define LINE_LED5 PAL_LINE(GPIOD, 14U) |
| 243 |
#define LINE_LED6 PAL_LINE(GPIOD, 15U) |
| 244 |
#define LINE_INT1 PAL_LINE(GPIOE, 0U) |
| 245 |
#define LINE_INT2 PAL_LINE(GPIOE, 1U) |
| 246 |
#define LINE_CS_SPI PAL_LINE(GPIOE, 3U) |
| 247 |
#define LINE_OSC_IN PAL_LINE(GPIOH, 0U) |
| 248 |
#define LINE_OSC_OUT PAL_LINE(GPIOH, 1U) |
| 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 |
|
| 288 |
/*
|
| 289 |
* GPIOA setup:
|
| 290 |
*
|
| 291 |
* PA0 - BUTTON (input floating).
|
| 292 |
* PA1 - PIN1 (input pullup).
|
| 293 |
* PA2 - PIN2 (input pullup).
|
| 294 |
* PA3 - PIN3 (input pullup).
|
| 295 |
* PA4 - LRCK (alternate 6).
|
| 296 |
* PA5 - SPC (alternate 5).
|
| 297 |
* PA6 - SDO (alternate 5).
|
| 298 |
* PA7 - SDI (alternate 5).
|
| 299 |
* PA8 - PIN8 (input pullup).
|
| 300 |
* PA9 - VBUS_FS (input floating).
|
| 301 |
* PA10 - OTG_FS_ID (alternate 10).
|
| 302 |
* PA11 - OTG_FS_DM (alternate 10).
|
| 303 |
* PA12 - OTG_FS_DP (alternate 10).
|
| 304 |
* PA13 - SWDIO (alternate 0).
|
| 305 |
* PA14 - SWCLK (alternate 0).
|
| 306 |
* PA15 - PIN15 (input pullup).
|
| 307 |
*/
|
| 308 |
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | \
|
| 309 |
PIN_MODE_INPUT(GPIOA_PIN1) | \ |
| 310 |
PIN_MODE_ALTERNATE(GPIOA_PIN2) | \ |
| 311 |
PIN_MODE_ALTERNATE(GPIOA_PIN3) | \ |
| 312 |
PIN_MODE_ALTERNATE(GPIOA_LRCK) | \ |
| 313 |
PIN_MODE_ALTERNATE(GPIOA_SPC) | \ |
| 314 |
PIN_MODE_ALTERNATE(GPIOA_SDO) | \ |
| 315 |
PIN_MODE_ALTERNATE(GPIOA_SDI) | \ |
| 316 |
PIN_MODE_INPUT(GPIOA_PIN8) | \ |
| 317 |
PIN_MODE_INPUT(GPIOA_VBUS_FS) | \ |
| 318 |
PIN_MODE_ALTERNATE(GPIOA_OTG_FS_ID) | \ |
| 319 |
PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DM) | \ |
| 320 |
|