board.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-10-26 ChenYong first version
  9. */
  10. #ifndef __BOARD_H__
  11. #define __BOARD_H__
  12. #include <rtthread.h>
  13. #include <stm32f1xx.h>
  14. #include "drv_common.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define RT_APP_PART_ADDR 0x8032000
  19. /*-------------------------- UART CONFIG BEGIN --------------------------*/
  20. /** After configuring corresponding UART or UART DMA, you can use it.
  21. *
  22. * STEP 1, define macro define related to the serial port opening based on the serial port number
  23. * such as #define BSP_USING_UATR1
  24. *
  25. * STEP 2, according to the corresponding pin of serial port, modify the related serial port information
  26. * such as #define UART1_TX_PORT GPIOX -> GPIOA
  27. * #define UART1_RX_PORT GPIOX -> GPIOA
  28. * #define UART1_TX_PIN GPIO_PIN_X -> GPIO_PIN_9
  29. * #define UART1_RX_PIN GPIO_PIN_X -> GPIO_PIN_10
  30. *
  31. * STEP 3, if you want using SERIAL DMA, you must open it in the RT-Thread Settings.
  32. * RT-Thread Setting -> Components -> Device Drivers -> Serial Device Drivers -> Enable Serial DMA Mode
  33. *
  34. * STEP 4, according to serial port number to define serial port tx/rx DMA function in the board.h file
  35. * such as #define BSP_UART1_RX_USING_DMA
  36. *
  37. */
  38. #define BSP_UART3_RX_USING_DMA //喇叭
  39. #define BSP_UART2_RX_USING_DMA //DTU
  40. #define BSP_UART4_RX_USING_DMA //屏幕
  41. #define BSP_USING_UART1
  42. #define BSP_USING_UART2
  43. #define BSP_USING_UART3
  44. #define BSP_USING_I2C1
  45. #define BSP_USING_UART4
  46. #define BSP_USING_UART5
  47. #if defined(BSP_USING_UART1)
  48. #define UART1_TX_PORT GPIOA
  49. #define UART1_RX_PORT GPIOA
  50. #define UART1_TX_PIN GPIO_PIN_9
  51. #define UART1_RX_PIN GPIO_PIN_10
  52. #endif
  53. #if defined(BSP_USING_UART2)
  54. #define UART2_TX_PORT GPIOA
  55. #define UART2_RX_PORT GPIOA
  56. #define UART2_TX_PIN GPIO_PIN_2
  57. #define UART2_RX_PIN GPIO_PIN_3
  58. #endif
  59. #if defined(BSP_USING_UART3)
  60. #define UART3_TX_PORT GPIOB
  61. #define UART3_RX_PORT GPIOB
  62. #define UART3_TX_PIN GPIO_PIN_10
  63. #define UART3_RX_PIN GPIO_PIN_11
  64. #endif
  65. #if defined(BSP_USING_UART4)
  66. #define UART4_TX_PORT GPIOC
  67. #define UART4_RX_PORT GPIOC
  68. #define UART4_TX_PIN GPIO_PIN_10
  69. #define UART4_RX_PIN GPIO_PIN_11
  70. #endif
  71. #if defined(BSP_USING_UART5)
  72. #define UART5_TX_PORT GPIOC
  73. #define UART5_RX_PORT GPIOD
  74. #define UART5_TX_PIN GPIO_PIN_12
  75. #define UART5_RX_PIN GPIO_PIN_2
  76. #endif
  77. #if defined(BSP_USING_UART6)
  78. #define UART6_TX_PORT GPIOX
  79. #define UART6_RX_PORT GPIOX
  80. #define UART6_TX_PIN GPIO_PIN_X
  81. #define UART6_RX_PIN GPIO_PIN_X
  82. #endif
  83. #if defined(BSP_USING_UART7)
  84. #define UART7_TX_PORT GPIOX
  85. #define UART7_RX_PORT GPIOX
  86. #define UART7_TX_PIN GPIO_PIN_X
  87. #define UART7_RX_PIN GPIO_PIN_X
  88. #endif
  89. #if defined(BSP_USING_UART8)
  90. #define UART8_TX_PORT GPIOX
  91. #define UART8_RX_PORT GPIOX
  92. #define UART8_TX_PIN GPIO_PIN_X
  93. #define UART8_RX_PIN GPIO_PIN_X
  94. #endif
  95. #if defined(BSP_USING_LPUART1)
  96. #define LPUART1_TX_PORT GPIOX
  97. #define LPUART1_RX_PORT GPIOX
  98. #define LPUART1_TX_PIN GPIO_PIN_X
  99. #define LPUART1_RX_PIN GPIO_PIN_X
  100. #endif
  101. /*-------------------------- UART CONFIG END --------------------------*/
  102. /*-------------------------- I2C CONFIG BEGIN --------------------------*/
  103. /** if you want to use i2c bus(soft simulate) you can use the following instructions.
  104. *
  105. * STEP 1, open i2c driver framework(soft simulate) support in the RT-Thread Settings file
  106. *
  107. * STEP 2, define macro related to the i2c bus
  108. * such as #define BSP_USING_I2C1
  109. *
  110. * STEP 3, according to the corresponding pin of i2c port, modify the related i2c port and pin information
  111. * such as #define BSP_I2C1_SCL_PIN GET_PIN(port, pin) -> GET_PIN(C, 11)
  112. * #define BSP_I2C1_SDA_PIN GET_PIN(port, pin) -> GET_PIN(C, 12)
  113. */
  114. /*#define BSP_USING_I2C1*/
  115. #ifdef BSP_USING_I2C1
  116. #define BSP_I2C1_SCL_PIN GET_PIN(B, 6)
  117. #define BSP_I2C1_SDA_PIN GET_PIN(B, 7)
  118. #endif
  119. /*#define BSP_USING_I2C2*/
  120. #ifdef BSP_USING_I2C2
  121. #define BSP_I2C2_SCL_PIN GET_PIN(port, pin)
  122. #define BSP_I2C2_SDA_PIN GET_PIN(port, pin)
  123. #endif
  124. /*-------------------------- I2C CONFIG END --------------------------*/
  125. /*-------------------------- SPI CONFIG BEGIN --------------------------*/
  126. /** if you want to use spi bus you can use the following instructions.
  127. *
  128. * STEP 1, open spi driver framework support in the RT-Thread Settings file
  129. *
  130. * STEP 2, define macro related to the spi bus
  131. * such as #define BSP_USING_SPI1
  132. *
  133. * STEP 3, copy your spi init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  134. * such as void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  135. *
  136. * STEP 4, modify your stm32xxxx_hal_config.h file to support spi peripherals. define macro related to the peripherals
  137. * such as #define HAL_SPI_MODULE_ENABLED
  138. */
  139. #define BSP_USING_SPI1
  140. /*#define BSP_USING_SPI2*/
  141. /*#define BSP_USING_SPI3*/
  142. /*-------------------------- SPI CONFIG END --------------------------*/
  143. /*-------------------------- QSPI CONFIG BEGIN --------------------------*/
  144. /** if you want to use qspi you can use the following instructions.
  145. *
  146. * STEP 1, open qspi driver framework support in the RT-Thread Settings file
  147. *
  148. * STEP 2, define macro related to the qspi
  149. * such as #define BSP_USING_QSPI
  150. *
  151. * STEP 3, copy your qspi init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  152. * such as void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
  153. *
  154. * STEP 4, modify your stm32xxxx_hal_config.h file to support qspi peripherals. define macro related to the peripherals
  155. * such as #define HAL_QSPI_MODULE_ENABLED
  156. *
  157. */
  158. /*#define BSP_USING_QSPI*/
  159. /*-------------------------- QSPI CONFIG END --------------------------*/
  160. /*-------------------------- PWM CONFIG BEGIN --------------------------*/
  161. /** if you want to use pwm you can use the following instructions.
  162. *
  163. * STEP 1, open pwm driver framework support in the RT-Thread Settings file
  164. *
  165. * STEP 2, define macro related to the pwm
  166. * such as #define BSP_USING_PWM1
  167. *
  168. * STEP 3, copy your pwm timer init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end if board.c file
  169. * such as void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) and
  170. * void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
  171. *
  172. * STEP 4, modify your stm32xxxx_hal_config.h file to support pwm peripherals. define macro related to the peripherals
  173. * such as #define HAL_TIM_MODULE_ENABLED
  174. *
  175. */
  176. /*#define BSP_USING_PWM1*/
  177. /*#define BSP_USING_PWM2*/
  178. #define BSP_USING_PWM3
  179. #define BSP_USING_PWM3_CH1
  180. /*-------------------------- PWM CONFIG END --------------------------*/
  181. /*-------------------------- ADC CONFIG BEGIN --------------------------*/
  182. /** if you want to use adc you can use the following instructions.
  183. *
  184. * STEP 1, open adc driver framework support in the RT-Thread Settings file
  185. *
  186. * STEP 2, define macro related to the adc
  187. * such as #define BSP_USING_ADC1
  188. *
  189. * STEP 3, copy your adc init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  190. * such as void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  191. *
  192. * STEP 4, modify your stm32xxxx_hal_config.h file to support adc peripherals. define macro related to the peripherals
  193. * such as #define HAL_ADC_MODULE_ENABLED
  194. *
  195. */
  196. #define BSP_USING_ADC1
  197. /*#define BSP_USING_ADC2*/
  198. /*#define BSP_USING_ADC3*/
  199. /*-------------------------- ADC CONFIG END --------------------------*/
  200. /*-------------------------- WDT CONFIG BEGIN --------------------------*/
  201. /** if you want to use wdt you can use the following instructions.
  202. *
  203. * STEP 1, open wdt driver framework support in the RT-Thread Settings file
  204. *
  205. * STEP 2, modify your stm32xxxx_hal_config.h file to support wdt peripherals. define macro related to the peripherals
  206. * such as #define HAL_IWDG_MODULE_ENABLED
  207. *
  208. */
  209. /*-------------------------- WDT CONFIG END --------------------------*/
  210. /*-------------------------- HARDWARE TIMER CONFIG BEGIN --------------------------*/
  211. /** if you want to use hardware timer you can use the following instructions.
  212. *
  213. * STEP 1, open hwtimer driver framework support in the RT-Thread Settings file
  214. *
  215. * STEP 2, define macro related to the hwtimer
  216. * such as #define BSP_USING_TIM and
  217. * #define BSP_USING_TIM1
  218. *
  219. * STEP 3, copy your hardwire timer init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  220. * such as void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  221. *
  222. * STEP 4, modify your stm32xxxx_hal_config.h file to support hardwere timer peripherals. define macro related to the peripherals
  223. * such as #define HAL_TIM_MODULE_ENABLED
  224. *
  225. */
  226. /*#define BSP_USING_TIM*/
  227. #ifdef BSP_USING_TIM
  228. #define BSP_USING_TIM3
  229. /*#define BSP_USING_TIM15*/
  230. /*#define BSP_USING_TIM16*/
  231. /*#define BSP_USING_TIM17*/
  232. #endif
  233. /*-------------------------- HAREWARE TIMER CONFIG END --------------------------*/
  234. /*-------------------------- RTC CONFIG BEGIN --------------------------*/
  235. /** if you want to use rtc(hardware) you can use the following instructions.
  236. *
  237. * STEP 1, open rtc driver framework(hardware) support in the RT-Thread Settings file
  238. *
  239. * STEP 2, define macro related to the rtc
  240. * such as BSP_USING_ONCHIP_RTC
  241. *
  242. * STEP 3, modify your stm32xxxx_hal_config.h file to support rtc peripherals. define macro related to the peripherals
  243. * such as #define HAL_RTC_MODULE_ENABLED
  244. *
  245. */
  246. #define BSP_USING_ONCHIP_RTC
  247. /*-------------------------- RTC CONFIG END --------------------------*/
  248. /*-------------------------- SDIO CONFIG BEGIN --------------------------*/
  249. /** if you want to use sdio you can use the following instructions.
  250. *
  251. * STEP 1, open sdio driver framework support in the RT-Thread Settings file
  252. *
  253. * STEP 2, define macro related to the sdio
  254. * such as BSP_USING_SDIO
  255. *
  256. * STEP 3, copy your sdio init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  257. * such as void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
  258. *
  259. * STEP 4, modify your stm32xxxx_hal_config.h file to support sdio peripherals. define macro related to the peripherals
  260. * such as #define HAL_SD_MODULE_ENABLED
  261. *
  262. * STEP 5, config your device file system or another applications
  263. *
  264. */
  265. /*#define BSP_USING_SDIO*/
  266. /*-------------------------- SDIO CONFIG END --------------------------*/
  267. /*-------------------------- ETH CONFIG BEGIN --------------------------*/
  268. /** if you want to use eth you can use the following instructions.
  269. *
  270. * STEP 1, define macro related to the eth
  271. * such as BSP_USING_ETH
  272. *
  273. * STEP 2, copy your eth init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end if board.c file
  274. * such as void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
  275. *
  276. * STEP 3, modify your stm32xxxx_hal_config.h file to support eth peripherals. define macro related to the peripherals
  277. * such as #define HAL_ETH_MODULE_ENABLED
  278. *
  279. * STEP 4, config your phy type
  280. * such as #define PHY_USING_LAN8720A
  281. * #define PHY_USING_DM9161CEP
  282. * #define PHY_USING_DP83848C
  283. * STEP 5, implement your phy reset function in the end of board.c file
  284. * void phy_reset(void)
  285. *
  286. * STEP 6, config your lwip or other network stack
  287. *
  288. */
  289. /*#define BSP_USING_ETH*/
  290. #ifdef BSP_USING_ETH
  291. /*#define PHY_USING_LAN8720A*/
  292. /*#define PHY_USING_DM9161CEP*/
  293. /*#define PHY_USING_DP83848C*/
  294. #endif
  295. /*-------------------------- ETH CONFIG END --------------------------*/
  296. /*-------------------------- USB HOST CONFIG BEGIN --------------------------*/
  297. /** if you want to use usb host you can use the following instructions.
  298. *
  299. * STEP 1, open usb host driver framework support in the RT-Thread Settings file
  300. *
  301. * STEP 2, define macro related to the usb host
  302. * such as BSP_USING_USBHOST
  303. *
  304. * STEP 3, copy your usb host init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  305. * such as void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd)
  306. *
  307. * STEP 4, config your usb peripheral clock in SystemClock_Config() generated by STM32CubeMX and replace this function in board.c
  308. *
  309. * STEP 5, modify your stm32xxxx_hal_config.h file to support usb host peripherals. define macro related to the peripherals
  310. * such as #define HAL_HCD_MODULE_ENABLED
  311. *
  312. */
  313. /*#define BSP_USING_USBHOST*/
  314. /*-------------------------- USB HOST CONFIG END --------------------------*/
  315. /*-------------------------- USB DEVICE CONFIG BEGIN --------------------------*/
  316. /** if you want to use usb device you can use the following instructions.
  317. *
  318. * STEP 1, open usb device driver framework support in the RT-Thread Settings file
  319. *
  320. * STEP 2 define macro related to the usb device
  321. * such as BSP_USING_USBDEVICE
  322. *
  323. * STEP 3, copy your usb device init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end of board.c file
  324. * such as void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
  325. *
  326. * STEP 4, config your usb peripheral clock in SystemClock_Config() generated by STM32CubeMX and replace this function in board.c
  327. *
  328. * STEP 5, modify your stm32xxxx_hal_config.h file to support usb device peripherals. define macro related to the peripherals
  329. * such as #define HAL_PCD_MODULE_ENABLED
  330. *
  331. */
  332. /*#define BSP_USING_USBDEVICE*/
  333. /*-------------------------- USB DEVICE CONFIG END --------------------------*/
  334. /*-------------------------- ON_CHIP_FLASH CONFIG BEGIN --------------------------*/
  335. /** if you want to use on chip flash you can use the following instructions.
  336. *
  337. * STEP 1 define macro related to the on chip flash
  338. * such as BSP_USING_ON_CHIP_FLASH
  339. *
  340. * STEP 2, modify your stm32xxxx_hal_config.h file to support on chip flash peripherals. define macro related to the peripherals
  341. * such as #define HAL_FLASH_MODULE_ENABLED
  342. *
  343. */
  344. #define BSP_USING_ON_CHIP_FLASH
  345. /*-------------------------- ON_CHIP_FLASH CONFIG END --------------------------*/
  346. /*-------------------------- ROM/RAM CONFIG BEGIN --------------------------*/
  347. #define STM32_FLASH_START_ADRESS ((uint32_t)0x8020000)
  348. #define STM32_FLASH_SIZE (512)
  349. #define STM32_FLASH_END_ADDRESS ((uint32_t)(STM32_FLASH_START_ADRESS + STM32_FLASH_SIZE * 1024))
  350. #define STM32_SRAM1_SIZE (64)
  351. #define STM32_SRAM1_START (0x20000000)
  352. #define STM32_SRAM1_END (STM32_SRAM1_START + STM32_SRAM1_SIZE * 1024)
  353. #if defined(__CC_ARM) || defined(__CLANG_ARM)
  354. extern int Image$RW_IRAM1$ZI$Limit;
  355. #define HEAP_BEGIN ((void *)&Image$RW_IRAM1$ZI$Limit)
  356. #elif __ICCARM__
  357. #pragma section="CSTACK"
  358. #define HEAP_BEGIN (__segment_end("CSTACK"))
  359. #else
  360. extern int __bss_end;
  361. #define HEAP_BEGIN ((void *)&__bss_end)
  362. #endif
  363. #define HEAP_END STM32_SRAM1_END
  364. /*-------------------------- ROM/RAM CONFIG END --------------------------*/
  365. void SystemClock_Config(void);
  366. #ifdef __cplusplus
  367. }
  368. #endif
  369. #endif /* __BOARD_H__ */