1 // Copyright 2021 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 17 /* Clock setup */ 18 #define HSI_VALUE 16000000U 19 #define LSI_VALUE 32000U 20 21 // The F429-disc has an 8Mhz external crystal 22 #define HSE_VALUE 8000000U 23 #define HSE_STARTUP_TIMEOUT 100U 24 25 // The F429-disc has no LSE 26 #define LSE_VALUE 0U 27 #define LSE_STARTUP_TIMEOUT 5000U 28 29 #define EXTERNAL_CLOCK_VALUE 0U 30 31 /* HAL Config */ 32 #define TICK_INT_PRIORITY 0x0FU 33 #define USE_RTOS 0U 34 #define PREFETCH_ENABLE 1U 35 #define INSTRUCTION_CACHE_ENABLE 1U 36 #define DATA_CACHE_ENABLE 1U 37 38 #define assert_param(expr) ((void)0U) 39 40 /* Ethernet driver buffers size + count 41 * (also used by FreeRTOS_Plus_TCP's stm32 driver) */ 42 #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE 43 #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE 44 #define ETH_RXBUFNB 4U 45 #define ETH_TXBUFNB 4U 46 47 /* Ethernet PHY Defines (unused by FreeRTOS_Plus_TCP's driver) */ 48 #define PHY_RESET_DELAY 0x000000FFU 49 #define PHY_CONFIG_DELAY 0x00000FFFU 50 51 #define PHY_READ_TO 0x0000FFFFU 52 #define PHY_WRITE_TO 0x0000FFFFU 53 54 /* Common PHY Registers */ 55 #define PHY_BCR ((uint16_t)0x0000) 56 #define PHY_BSR ((uint16_t)0x0001) 57 58 #define PHY_RESET ((uint16_t)0x8000) 59 #define PHY_LOOPBACK ((uint16_t)0x4000) 60 #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) 61 #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) 62 #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) 63 #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) 64 #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) 65 #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) 66 #define PHY_POWERDOWN ((uint16_t)0x0800) 67 #define PHY_ISOLATE ((uint16_t)0x0400) 68 69 #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) 70 #define PHY_LINKED_STATUS ((uint16_t)0x0004) 71 #define PHY_JABBER_DETECTION ((uint16_t)0x0002) 72 73 /* Extended PHY Registers */ 74 #define PHY_SR ((uint16_t)0x0010) 75 #define PHY_MICR ((uint16_t)0x0011) 76 #define PHY_MISR ((uint16_t)0x0012) 77 78 #define PHY_LINK_STATUS ((uint16_t)0x0001) 79 #define PHY_SPEED_STATUS ((uint16_t)0x0002) 80 #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) 81 82 #define PHY_MICR_INT_EN ((uint16_t)0x0002) 83 #define PHY_MICR_INT_OE ((uint16_t)0x0001) 84 85 #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) 86 #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) 87 88 // SPI config 89 #define USE_SPI_CRC 1U 90 91 /** HAL Headers: comment out defines + include to remove **/ 92 /* primary HAL headers */ 93 #define HAL_CORTEX_MODULE_ENABLED 94 #include "stm32f4xx_hal_cortex.h" 95 96 #define HAL_DMA_MODULE_ENABLED 97 #include "stm32f4xx_hal_dma.h" 98 99 #define HAL_EXTI_MODULE_ENABLED 100 #include "stm32f4xx_hal_exti.h" 101 102 #define HAL_GPIO_MODULE_ENABLED 103 #include "stm32f4xx_hal_gpio.h" 104 105 #define HAL_RCC_MODULE_ENABLED 106 #include "stm32f4xx_hal_rcc.h" 107 108 /* remaining headers (can be commented out if desired) */ 109 #define HAL_ADC_MODULE_ENABLED 110 #define USE_HAL_ADC_REGISTER_CALLBACKS 0U 111 #include "stm32f4xx_hal_adc.h" 112 113 #define HAL_CAN_MODULE_ENABLED 114 #define USE_HAL_CAN_REGISTER_CALLBACKS 0U 115 #include "stm32f4xx_hal_can.h" 116 117 // #define HAL_CAN_LEGACY_MODULE_ENABLED 118 // #include "stm32f4xx_hal_can_legacy.h" 119 120 #define HAL_CEC_MODULE_ENABLED 121 #define USE_HAL_CEC_REGISTER_CALLBACKS 0U 122 #include "stm32f4xx_hal_cec.h" 123 124 #define HAL_CRC_MODULE_ENABLED 125 #include "stm32f4xx_hal_crc.h" 126 127 #define HAL_CRYP_MODULE_ENABLED 128 #define USE_HAL_CRYP_REGISTER_CALLBACKS 0U 129 #include "stm32f4xx_hal_cryp.h" 130 131 #define HAL_DAC_MODULE_ENABLED 132 #define USE_HAL_DAC_REGISTER_CALLBACKS 0U 133 #include "stm32f4xx_hal_dac.h" 134 135 #define HAL_DCMI_MODULE_ENABLED 136 #define USE_HAL_DCMI_REGISTER_CALLBACKS 0U 137 #include "stm32f4xx_hal_dcmi.h" 138 139 #define HAL_DMA2D_MODULE_ENABLED 140 #define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U 141 #include "stm32f4xx_hal_dma2d.h" 142 143 #define HAL_DFSDM_MODULE_ENABLED 144 #define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U 145 #include "stm32f4xx_hal_dfsdm.h" 146 147 #define HAL_DSI_MODULE_ENABLED 148 #define USE_HAL_DSI_REGISTER_CALLBACKS 0U 149 #include "stm32f4xx_hal_dsi.h" 150 151 #define HAL_ETH_MODULE_ENABLED 152 #define USE_HAL_ETH_REGISTER_CALLBACKS 0U 153 #include "stm32f4xx_hal_eth.h" 154 155 #define HAL_FLASH_MODULE_ENABLED 156 #include "stm32f4xx_hal_flash.h" 157 158 #define HAL_FMPI2C_MODULE_ENABLED 159 #define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U 160 #include "stm32f4xx_hal_fmpi2c.h" 161 162 #define HAL_FMPSMBUS_MODULE_ENABLED 163 #define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U 164 #include "stm32f4xx_hal_fmpsmbus.h" 165 166 #define HAL_HASH_MODULE_ENABLED 167 #define USE_HAL_HASH_REGISTER_CALLBACKS 0U 168 #include "stm32f4xx_hal_hash.h" 169 170 #define HAL_HCD_MODULE_ENABLED 171 #define USE_HAL_HCD_REGISTER_CALLBACKS 0U 172 #include "stm32f4xx_hal_hcd.h" 173 174 #define HAL_I2C_MODULE_ENABLED 175 #define USE_HAL_I2C_REGISTER_CALLBACKS 0U 176 #include "stm32f4xx_hal_i2c.h" 177 178 #define HAL_I2S_MODULE_ENABLED 179 #define USE_HAL_I2S_REGISTER_CALLBACKS 0U 180 #include "stm32f4xx_hal_i2s.h" 181 182 #define HAL_IRDA_MODULE_ENABLED 183 #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U 184 #include "stm32f4xx_hal_irda.h" 185 186 #define HAL_IWDG_MODULE_ENABLED 187 #include "stm32f4xx_hal_iwdg.h" 188 189 #define HAL_LPTIM_MODULE_ENABLED 190 #define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U 191 #include "stm32f4xx_hal_lptim.h" 192 193 #define HAL_LTDC_MODULE_ENABLED 194 #define USE_HAL_LTDC_REGISTER_CALLBACKS 0U 195 #include "stm32f4xx_hal_ltdc.h" 196 197 #define HAL_MMC_MODULE_ENABLED 198 #define USE_HAL_MMC_REGISTER_CALLBACKS 0U 199 #include "stm32f4xx_hal_mmc.h" 200 201 #define HAL_NAND_MODULE_ENABLED 202 #define USE_HAL_NAND_REGISTER_CALLBACKS 0U 203 #include "stm32f4xx_hal_nand.h" 204 205 #define HAL_NOR_MODULE_ENABLED 206 #define USE_HAL_NOR_REGISTER_CALLBACKS 0U 207 #include "stm32f4xx_hal_nor.h" 208 209 #define HAL_PCCARD_MODULE_ENABLED 210 #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U 211 #include "stm32f4xx_hal_pccard.h" 212 213 #define HAL_PCD_MODULE_ENABLED 214 #define USE_HAL_PCD_REGISTER_CALLBACKS 0U 215 #include "stm32f4xx_hal_pcd.h" 216 217 #define HAL_PWR_MODULE_ENABLED 218 #include "stm32f4xx_hal_pwr.h" 219 220 #define HAL_QSPI_MODULE_ENABLED 221 #define USE_HAL_QSPI_REGISTER_CALLBACKS 0U 222 #include "stm32f4xx_hal_qspi.h" 223 224 #define HAL_RNG_MODULE_ENABLED 225 #define USE_HAL_RNG_REGISTER_CALLBACKS 0U 226 #include "stm32f4xx_hal_rng.h" 227 228 #define HAL_RTC_MODULE_ENABLED 229 #define USE_HAL_RTC_REGISTER_CALLBACKS 0U 230 #include "stm32f4xx_hal_rtc.h" 231 232 #define HAL_SAI_MODULE_ENABLED 233 #define USE_HAL_SAI_REGISTER_CALLBACKS 0U 234 #include "stm32f4xx_hal_sai.h" 235 236 #define HAL_SD_MODULE_ENABLED 237 #define USE_HAL_SD_REGISTER_CALLBACKS 0U 238 #include "stm32f4xx_hal_sd.h" 239 240 #define HAL_SDRAM_MODULE_ENABLED 241 #define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U 242 #include "stm32f4xx_hal_sdram.h" 243 244 #define HAL_SMARTCARD_MODULE_ENABLED 245 #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U 246 #include "stm32f4xx_hal_smartcard.h" 247 248 #define HAL_SMBUS_MODULE_ENABLED 249 #define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U 250 #include "stm32f4xx_hal_smbus.h" 251 252 #define HAL_SPDIFRX_MODULE_ENABLED 253 #define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U 254 #include "stm32f4xx_hal_spdifrx.h" 255 256 #define HAL_SPI_MODULE_ENABLED 257 #define USE_HAL_SPI_REGISTER_CALLBACKS 0U 258 #include "stm32f4xx_hal_spi.h" 259 260 #define HAL_SRAM_MODULE_ENABLED 261 #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U 262 #include "stm32f4xx_hal_sram.h" 263 264 #define HAL_TIM_MODULE_ENABLED 265 #define USE_HAL_TIM_REGISTER_CALLBACKS 0U 266 #include "stm32f4xx_hal_tim.h" 267 268 #define HAL_UART_MODULE_ENABLED 269 #define USE_HAL_UART_REGISTER_CALLBACKS 0U 270 #include "stm32f4xx_hal_uart.h" 271 272 #define HAL_USART_MODULE_ENABLED 273 #define USE_HAL_USART_REGISTER_CALLBACKS 0U 274 #include "stm32f4xx_hal_usart.h" 275 276 #define HAL_WWDG_MODULE_ENABLED 277 #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U 278 #include "stm32f4xx_hal_wwdg.h" 279