board.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-11-07 RealThread first version
  9. */
  10. #ifndef __BOARD_H__
  11. #define __BOARD_H__
  12. #include <stm32f4xx.h>
  13. #include <drv_common.h>
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. /*-------------------------- CHIP CONFIG BEGIN --------------------------*/
  19. #define CHIP_FAMILY_STM32
  20. #define CHIP_SERIES_STM32F4
  21. #define CHIP_NAME_STM32F407VE
  22. /*-------------------------- CHIP CONFIG END --------------------------*/
  23. /*-------------------------- ROM/RAM CONFIG BEGIN --------------------------*/
  24. #define ROM_START ((uint32_t)0x08020000)
  25. #define ROM_SIZE (384 * 1024)
  26. #define ROM_END ((uint32_t)(ROM_START + ROM_SIZE))
  27. #define RAM_START (0x20000000)
  28. #define RAM_SIZE (128 * 1024)
  29. #define RAM_END (RAM_START + RAM_SIZE)
  30. /*-------------------------- ROM/RAM CONFIG END --------------------------*/
  31. /*-------------------------- CLOCK CONFIG BEGIN --------------------------*/
  32. #define BSP_CLOCK_SOURCE ("HSE")
  33. #define BSP_CLOCK_SOURCE_FREQ_MHZ ((int32_t)12)
  34. #define BSP_CLOCK_SYSTEM_FREQ_MHZ ((int32_t)168)
  35. /*-------------------------- CLOCK CONFIG END --------------------------*/
  36. /*-------------------------- UART CONFIG BEGIN --------------------------*/
  37. /** After configuring corresponding UART or UART DMA, you can use it.
  38. *
  39. * STEP 1, define macro define related to the serial port opening based on the serial port number
  40. * such as #define BSP_USING_UART1
  41. *
  42. * STEP 2, according to the corresponding pin of serial port, define the related serial port information macro
  43. * such as #define BSP_UART1_TX_PIN "PA9"
  44. * #define BSP_UART1_RX_PIN "PA10"
  45. *
  46. * STEP 3, if you want using SERIAL DMA, you must open it in the RT-Thread Settings.
  47. * RT-Thread Setting -> Components -> Device Drivers -> Serial Device Drivers -> Enable Serial DMA Mode
  48. *
  49. * STEP 4, according to serial port number to define serial port tx/rx DMA function in the board.h file
  50. * such as #define BSP_UART1_RX_USING_DMA
  51. *
  52. */
  53. #define BSP_USING_UART1
  54. #define BSP_UART1_TX_PIN "PA9"
  55. #define BSP_UART1_RX_PIN "PA10"
  56. #define BSP_USING_UART2
  57. #define BSP_UART2_TX_PIN "PA2"
  58. #define BSP_UART2_RX_PIN "PA3"
  59. #define BSP_USING_UART3
  60. #define BSP_UART3_TX_PIN "PB10"
  61. #define BSP_UART3_RX_PIN "PB11"
  62. #define BSP_USING_UART4
  63. #define BSP_UART4_TX_PIN "PC10"
  64. #define BSP_UART4_RX_PIN "PC11"
  65. #define BSP_USING_UART5
  66. #define BSP_UART5_TX_PIN "PC12"
  67. #define BSP_UART5_RX_PIN "PD2"
  68. #define BSP_USING_UART6
  69. #define BSP_UART6_TX_PIN "PC6"
  70. #define BSP_UART6_RX_PIN "PC7"
  71. /*-------------------------- UART CONFIG END --------------------------*/
  72. /*-------------------------- I2C CONFIG BEGIN --------------------------*/
  73. /** if you want to use i2c bus(soft simulate) you can use the following instructions.
  74. *
  75. * STEP 1, open i2c driver framework(soft simulate) support in the RT-Thread Settings file
  76. *
  77. * STEP 2, define macro related to the i2c bus
  78. * such as #define BSP_USING_I2C1
  79. *
  80. * STEP 3, according to the corresponding pin of i2c port, modify the related i2c port and pin information
  81. * such as #define BSP_I2C1_SCL_PIN GET_PIN(port, pin) -> GET_PIN(C, 11)
  82. * #define BSP_I2C1_SDA_PIN GET_PIN(port, pin) -> GET_PIN(C, 12)
  83. */
  84. /*#define BSP_USING_I2C1*/
  85. #ifdef BSP_USING_I2C1
  86. #define BSP_I2C1_SCL_PIN GET_PIN(port, pin)
  87. #define BSP_I2C1_SDA_PIN GET_PIN(port, pin)
  88. #endif
  89. /*#define BSP_USING_I2C2*/
  90. #ifdef BSP_USING_I2C2
  91. #define BSP_I2C2_SCL_PIN GET_PIN(port, pin)
  92. #define BSP_I2C2_SDA_PIN GET_PIN(port, pin)
  93. #endif
  94. /*-------------------------- I2C CONFIG END --------------------------*/
  95. /*-------------------------- SPI CONFIG BEGIN --------------------------*/
  96. /** if you want to use spi bus you can use the following instructions.
  97. *
  98. * STEP 1, open spi driver framework support in the RT-Thread Settings file
  99. *
  100. * STEP 2, define macro related to the spi bus
  101. * such as #define BSP_USING_SPI1
  102. *
  103. * STEP 3, copy your spi init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  104. * such as void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  105. *
  106. * STEP 4, modify your stm32xxxx_hal_config.h file to support spi peripherals. define macro related to the peripherals
  107. * such as #define HAL_SPI_MODULE_ENABLED
  108. */
  109. #define BSP_USING_SPI1
  110. #define BSP_USING_SPI2
  111. /*#define BSP_USING_SPI3*/
  112. /*-------------------------- SPI CONFIG END --------------------------*/
  113. /*-------------------------- QSPI CONFIG BEGIN --------------------------*/
  114. /** if you want to use qspi you can use the following instructions.
  115. *
  116. * STEP 1, open qspi driver framework support in the RT-Thread Settings file
  117. *
  118. * STEP 2, define macro related to the qspi
  119. * such as #define BSP_USING_QSPI
  120. *
  121. * STEP 3, copy your qspi init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  122. * such as void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
  123. *
  124. * STEP 4, modify your stm32xxxx_hal_config.h file to support qspi peripherals. define macro related to the peripherals
  125. * such as #define HAL_QSPI_MODULE_ENABLED
  126. *
  127. */
  128. /*#define BSP_USING_QSPI*/
  129. /*-------------------------- QSPI CONFIG END --------------------------*/
  130. /*-------------------------- PWM CONFIG BEGIN --------------------------*/
  131. /** if you want to use pwm you can use the following instructions.
  132. *
  133. * STEP 1, open pwm driver framework support in the RT-Thread Settings file
  134. *
  135. * STEP 2, define macro related to the pwm
  136. * such as #define BSP_USING_PWM1
  137. *
  138. * STEP 3, copy your pwm timer init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end if board.c file
  139. * such as void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) and
  140. * void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
  141. *
  142. * STEP 4, modify your stm32xxxx_hal_config.h file to support pwm peripherals. define macro related to the peripherals
  143. * such as #define HAL_TIM_MODULE_ENABLED
  144. *
  145. */
  146. /*#define BSP_USING_PWM1*/
  147. /*#define BSP_USING_PWM2*/
  148. /*#define BSP_USING_PWM3*/
  149. /*-------------------------- PWM CONFIG END --------------------------*/
  150. /*-------------------------- ADC CONFIG BEGIN --------------------------*/
  151. /** if you want to use adc you can use the following instructions.
  152. *
  153. * STEP 1, open adc driver framework support in the RT-Thread Settings file
  154. *
  155. * STEP 2, define macro related to the adc
  156. * such as #define BSP_USING_ADC1
  157. *
  158. * STEP 3, copy your adc init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  159. * such as void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  160. *
  161. * STEP 4, modify your stm32xxxx_hal_config.h file to support adc peripherals. define macro related to the peripherals
  162. * such as #define HAL_ADC_MODULE_ENABLED
  163. *
  164. */
  165. #define BSP_USING_ADC1
  166. /*#define BSP_USING_ADC2*/
  167. /*#define BSP_USING_ADC3*/
  168. /*-------------------------- ADC CONFIG END --------------------------*/
  169. /*-------------------------- WDT CONFIG BEGIN --------------------------*/
  170. /** if you want to use wdt you can use the following instructions.
  171. *
  172. * STEP 1, open wdt driver framework support in the RT-Thread Settings file
  173. *
  174. * STEP 2, modify your stm32xxxx_hal_config.h file to support wdt peripherals. define macro related to the peripherals
  175. * such as #define HAL_IWDG_MODULE_ENABLED
  176. *
  177. */
  178. /*-------------------------- WDT CONFIG END --------------------------*/
  179. /*-------------------------- HARDWARE TIMER CONFIG BEGIN --------------------------*/
  180. /** if you want to use hardware timer you can use the following instructions.
  181. *
  182. * STEP 1, open hwtimer driver framework support in the RT-Thread Settings file
  183. *
  184. * STEP 2, define macro related to the hwtimer
  185. * such as #define BSP_USING_TIM and
  186. * #define BSP_USING_TIM1
  187. *
  188. * STEP 3, copy your hardwire timer init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  189. * such as void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  190. *
  191. * STEP 4, modify your stm32xxxx_hal_config.h file to support hardwere timer peripherals. define macro related to the peripherals
  192. * such as #define HAL_TIM_MODULE_ENABLED
  193. *
  194. */
  195. /*#define BSP_USING_TIM*/
  196. #ifdef BSP_USING_TIM
  197. /*#define BSP_USING_TIM15*/
  198. /*#define BSP_USING_TIM16*/
  199. /*#define BSP_USING_TIM17*/
  200. #endif
  201. /*-------------------------- HAREWARE TIMER CONFIG END --------------------------*/
  202. /*-------------------------- RTC CONFIG BEGIN --------------------------*/
  203. /** if you want to use rtc(hardware) you can use the following instructions.
  204. *
  205. * STEP 1, open rtc driver framework(hardware) support in the RT-Thread Settings file
  206. *
  207. * STEP 2, define macro related to the rtc
  208. * such as BSP_USING_ONCHIP_RTC
  209. *
  210. * STEP 3, modify your stm32xxxx_hal_config.h file to support rtc peripherals. define macro related to the peripherals
  211. * such as #define HAL_RTC_MODULE_ENABLED
  212. *
  213. */
  214. #define BSP_USING_ONCHIP_RTC
  215. /*-------------------------- RTC CONFIG END --------------------------*/
  216. /*-------------------------- SDIO CONFIG BEGIN --------------------------*/
  217. /** if you want to use sdio you can use the following instructions.
  218. *
  219. * STEP 1, open sdio driver framework support in the RT-Thread Settings file
  220. *
  221. * STEP 2, define macro related to the sdio
  222. * such as BSP_USING_SDIO
  223. *
  224. * STEP 3, copy your sdio init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  225. * such as void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
  226. *
  227. * STEP 4, modify your stm32xxxx_hal_config.h file to support sdio peripherals. define macro related to the peripherals
  228. * such as #define HAL_SD_MODULE_ENABLED
  229. *
  230. * STEP 5, config your device file system or another applications
  231. *
  232. */
  233. /*#define BSP_USING_SDIO*/
  234. /*-------------------------- SDIO CONFIG END --------------------------*/
  235. /*-------------------------- ETH CONFIG BEGIN --------------------------*/
  236. /** if you want to use eth you can use the following instructions.
  237. *
  238. * STEP 1, define macro related to the eth
  239. * such as BSP_USING_ETH
  240. *
  241. * STEP 2, copy your eth init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end if board.c file
  242. * such as void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
  243. *
  244. * STEP 3, modify your stm32xxxx_hal_config.h file to support eth peripherals. define macro related to the peripherals
  245. * such as #define HAL_ETH_MODULE_ENABLED
  246. *
  247. * STEP 4, config your phy type
  248. * such as #define PHY_USING_LAN8720A
  249. * #define PHY_USING_DM9161CEP
  250. * #define PHY_USING_DP83848C
  251. * STEP 5, implement your phy reset function in the end of board.c file
  252. * void phy_reset(void)
  253. *
  254. * STEP 6, config your lwip or other network stack
  255. *
  256. */
  257. /*#define BSP_USING_ETH*/
  258. #ifdef BSP_USING_ETH
  259. /*#define PHY_USING_LAN8720A*/
  260. /*#define PHY_USING_DM9161CEP*/
  261. /*#define PHY_USING_DP83848C*/
  262. #endif
  263. /*-------------------------- ETH CONFIG END --------------------------*/
  264. /*-------------------------- USB HOST CONFIG BEGIN --------------------------*/
  265. /** if you want to use usb host you can use the following instructions.
  266. *
  267. * STEP 1, open usb host driver framework support in the RT-Thread Settings file
  268. *
  269. * STEP 2, define macro related to the usb host
  270. * such as BSP_USING_USBHOST
  271. *
  272. * STEP 3, copy your usb host init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  273. * such as void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd)
  274. *
  275. * STEP 4, config your usb peripheral clock in SystemClock_Config() generated by STM32CubeMX and replace this function in board.c
  276. *
  277. * STEP 5, modify your stm32xxxx_hal_config.h file to support usb host peripherals. define macro related to the peripherals
  278. * such as #define HAL_HCD_MODULE_ENABLED
  279. *
  280. */
  281. /*#define BSP_USING_USBHOST*/
  282. /*-------------------------- USB HOST CONFIG END --------------------------*/
  283. /*-------------------------- USB DEVICE CONFIG BEGIN --------------------------*/
  284. /** if you want to use usb device you can use the following instructions.
  285. *
  286. * STEP 1, open usb device driver framework support in the RT-Thread Settings file
  287. *
  288. * STEP 2 define macro related to the usb device
  289. * such as BSP_USING_USBDEVICE
  290. *
  291. * STEP 3, copy your usb device init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  292. * such as void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
  293. *
  294. * STEP 4, config your usb peripheral clock in SystemClock_Config() generated by STM32CubeMX and replace this function in board.c
  295. *
  296. * STEP 5, modify your stm32xxxx_hal_config.h file to support usb device peripherals. define macro related to the peripherals
  297. * such as #define HAL_PCD_MODULE_ENABLED
  298. *
  299. */
  300. /*#define BSP_USING_USBDEVICE*/
  301. /*-------------------------- USB DEVICE CONFIG END --------------------------*/
  302. /*-------------------------- ON_CHIP_FLASH CONFIG BEGIN --------------------------*/
  303. /** if you want to use on chip flash you can use the following instructions.
  304. *
  305. * STEP 1 define macro related to the on chip flash
  306. * such as BSP_USING_ON_CHIP_FLASH
  307. *
  308. * STEP 2, modify your stm32xxxx_hal_config.h file to support on chip flash peripherals. define macro related to the peripherals
  309. * such as #define HAL_FLASH_MODULE_ENABLED
  310. *
  311. */
  312. //#define BSP_USING_ON_CHIP_FLASH
  313. /*-------------------------- ON_CHIP_FLASH CONFIG END --------------------------*/
  314. #ifdef __cplusplus
  315. }
  316. #endif
  317. #endif /* __BOARD_H__ */