uart_config.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-10-30 SummerGift first version
  9. * 2019-01-03 zylx modify dma support
  10. * 2026-04-13 wdfk-prog Unify DMA config descriptors
  11. */
  12. #ifndef __UART_CONFIG_H__
  13. #define __UART_CONFIG_H__
  14. #include <rtthread.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #if defined(BSP_USING_UART1)
  19. #ifndef UART1_CONFIG
  20. #define UART1_CONFIG \
  21. { \
  22. .name = "uart1", \
  23. .Instance = USART1, \
  24. .irq_type = USART1_IRQn, \
  25. }
  26. #endif /* UART1_CONFIG */
  27. #if defined(BSP_UART1_RX_USING_DMA)
  28. #ifndef UART1_RX_DMA_PRIORITY
  29. #define UART1_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  30. #endif /* UART1_RX_DMA_PRIORITY */
  31. #ifndef UART1_RX_DMA_PREEMPT_PRIORITY
  32. #define UART1_RX_DMA_PREEMPT_PRIORITY 0
  33. #endif /* UART1_RX_DMA_PREEMPT_PRIORITY */
  34. #ifndef UART1_RX_DMA_SUB_PRIORITY
  35. #define UART1_RX_DMA_SUB_PRIORITY 0
  36. #endif /* UART1_RX_DMA_SUB_PRIORITY */
  37. #ifndef UART1_DMA_RX_CONFIG
  38. #define UART1_DMA_RX_CONFIG \
  39. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  40. UART1_RX_DMA_INSTANCE, \
  41. UART1_RX_DMA_RCC, \
  42. UART1_RX_DMA_IRQ, \
  43. 0U, \
  44. UART1_RX_DMA_CHANNEL, \
  45. UART1_RX_DMA_PRIORITY, \
  46. UART1_RX_DMA_PREEMPT_PRIORITY, \
  47. UART1_RX_DMA_SUB_PRIORITY)
  48. #endif /* UART1_DMA_RX_CONFIG */
  49. #endif /* BSP_UART1_RX_USING_DMA */
  50. #if defined(BSP_UART1_TX_USING_DMA)
  51. #ifndef UART1_TX_DMA_PRIORITY
  52. #define UART1_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  53. #endif /* UART1_TX_DMA_PRIORITY */
  54. #ifndef UART1_TX_DMA_PREEMPT_PRIORITY
  55. #define UART1_TX_DMA_PREEMPT_PRIORITY 0
  56. #endif /* UART1_TX_DMA_PREEMPT_PRIORITY */
  57. #ifndef UART1_TX_DMA_SUB_PRIORITY
  58. #define UART1_TX_DMA_SUB_PRIORITY 0
  59. #endif /* UART1_TX_DMA_SUB_PRIORITY */
  60. #ifndef UART1_DMA_TX_CONFIG
  61. #define UART1_DMA_TX_CONFIG \
  62. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  63. UART1_TX_DMA_INSTANCE, \
  64. UART1_TX_DMA_RCC, \
  65. UART1_TX_DMA_IRQ, \
  66. 0U, \
  67. UART1_TX_DMA_CHANNEL, \
  68. UART1_TX_DMA_PRIORITY, \
  69. UART1_TX_DMA_PREEMPT_PRIORITY, \
  70. UART1_TX_DMA_SUB_PRIORITY)
  71. #endif /* UART1_DMA_TX_CONFIG */
  72. #endif /* BSP_UART1_TX_USING_DMA */
  73. #endif /* BSP_USING_UART1 */
  74. #if defined(BSP_USING_UART2)
  75. #ifndef UART2_CONFIG
  76. #define UART2_CONFIG \
  77. { \
  78. .name = "uart2", \
  79. .Instance = USART2, \
  80. .irq_type = USART2_IRQn, \
  81. }
  82. #endif /* UART2_CONFIG */
  83. #if defined(BSP_UART2_RX_USING_DMA)
  84. #ifndef UART2_RX_DMA_PRIORITY
  85. #define UART2_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  86. #endif /* UART2_RX_DMA_PRIORITY */
  87. #ifndef UART2_RX_DMA_PREEMPT_PRIORITY
  88. #define UART2_RX_DMA_PREEMPT_PRIORITY 0
  89. #endif /* UART2_RX_DMA_PREEMPT_PRIORITY */
  90. #ifndef UART2_RX_DMA_SUB_PRIORITY
  91. #define UART2_RX_DMA_SUB_PRIORITY 0
  92. #endif /* UART2_RX_DMA_SUB_PRIORITY */
  93. #ifndef UART2_DMA_RX_CONFIG
  94. #define UART2_DMA_RX_CONFIG \
  95. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  96. UART2_RX_DMA_INSTANCE, \
  97. UART2_RX_DMA_RCC, \
  98. UART2_RX_DMA_IRQ, \
  99. 0U, \
  100. UART2_RX_DMA_CHANNEL, \
  101. UART2_RX_DMA_PRIORITY, \
  102. UART2_RX_DMA_PREEMPT_PRIORITY, \
  103. UART2_RX_DMA_SUB_PRIORITY)
  104. #endif /* UART2_DMA_RX_CONFIG */
  105. #endif /* BSP_UART2_RX_USING_DMA */
  106. #if defined(BSP_UART2_TX_USING_DMA)
  107. #ifndef UART2_TX_DMA_PRIORITY
  108. #define UART2_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  109. #endif /* UART2_TX_DMA_PRIORITY */
  110. #ifndef UART2_TX_DMA_PREEMPT_PRIORITY
  111. #define UART2_TX_DMA_PREEMPT_PRIORITY 0
  112. #endif /* UART2_TX_DMA_PREEMPT_PRIORITY */
  113. #ifndef UART2_TX_DMA_SUB_PRIORITY
  114. #define UART2_TX_DMA_SUB_PRIORITY 0
  115. #endif /* UART2_TX_DMA_SUB_PRIORITY */
  116. #ifndef UART2_DMA_TX_CONFIG
  117. #define UART2_DMA_TX_CONFIG \
  118. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  119. UART2_TX_DMA_INSTANCE, \
  120. UART2_TX_DMA_RCC, \
  121. UART2_TX_DMA_IRQ, \
  122. 0U, \
  123. UART2_TX_DMA_CHANNEL, \
  124. UART2_TX_DMA_PRIORITY, \
  125. UART2_TX_DMA_PREEMPT_PRIORITY, \
  126. UART2_TX_DMA_SUB_PRIORITY)
  127. #endif /* UART2_DMA_TX_CONFIG */
  128. #endif /* BSP_UART2_TX_USING_DMA */
  129. #endif /* BSP_USING_UART2 */
  130. #if defined(BSP_USING_UART3)
  131. #ifndef UART3_CONFIG
  132. #define UART3_CONFIG \
  133. { \
  134. .name = "uart3", \
  135. .Instance = USART3, \
  136. .irq_type = USART3_IRQn, \
  137. }
  138. #endif /* UART3_CONFIG */
  139. #if defined(BSP_UART3_RX_USING_DMA)
  140. #ifndef UART3_RX_DMA_PRIORITY
  141. #define UART3_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  142. #endif /* UART3_RX_DMA_PRIORITY */
  143. #ifndef UART3_RX_DMA_PREEMPT_PRIORITY
  144. #define UART3_RX_DMA_PREEMPT_PRIORITY 0
  145. #endif /* UART3_RX_DMA_PREEMPT_PRIORITY */
  146. #ifndef UART3_RX_DMA_SUB_PRIORITY
  147. #define UART3_RX_DMA_SUB_PRIORITY 0
  148. #endif /* UART3_RX_DMA_SUB_PRIORITY */
  149. #ifndef UART3_DMA_RX_CONFIG
  150. #define UART3_DMA_RX_CONFIG \
  151. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  152. UART3_RX_DMA_INSTANCE, \
  153. UART3_RX_DMA_RCC, \
  154. UART3_RX_DMA_IRQ, \
  155. 0U, \
  156. UART3_RX_DMA_CHANNEL, \
  157. UART3_RX_DMA_PRIORITY, \
  158. UART3_RX_DMA_PREEMPT_PRIORITY, \
  159. UART3_RX_DMA_SUB_PRIORITY)
  160. #endif /* UART3_DMA_RX_CONFIG */
  161. #endif /* BSP_UART3_RX_USING_DMA */
  162. #if defined(BSP_UART3_TX_USING_DMA)
  163. #ifndef UART3_TX_DMA_PRIORITY
  164. #define UART3_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  165. #endif /* UART3_TX_DMA_PRIORITY */
  166. #ifndef UART3_TX_DMA_PREEMPT_PRIORITY
  167. #define UART3_TX_DMA_PREEMPT_PRIORITY 0
  168. #endif /* UART3_TX_DMA_PREEMPT_PRIORITY */
  169. #ifndef UART3_TX_DMA_SUB_PRIORITY
  170. #define UART3_TX_DMA_SUB_PRIORITY 0
  171. #endif /* UART3_TX_DMA_SUB_PRIORITY */
  172. #ifndef UART3_DMA_TX_CONFIG
  173. #define UART3_DMA_TX_CONFIG \
  174. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  175. UART3_TX_DMA_INSTANCE, \
  176. UART3_TX_DMA_RCC, \
  177. UART3_TX_DMA_IRQ, \
  178. 0U, \
  179. UART3_TX_DMA_CHANNEL, \
  180. UART3_TX_DMA_PRIORITY, \
  181. UART3_TX_DMA_PREEMPT_PRIORITY, \
  182. UART3_TX_DMA_SUB_PRIORITY)
  183. #endif /* UART3_DMA_TX_CONFIG */
  184. #endif /* BSP_UART3_TX_USING_DMA */
  185. #endif /* BSP_USING_UART3 */
  186. #if defined(BSP_USING_UART4)
  187. #ifndef UART4_CONFIG
  188. #define UART4_CONFIG \
  189. { \
  190. .name = "uart4", \
  191. .Instance = UART4, \
  192. .irq_type = UART4_IRQn, \
  193. }
  194. #endif /* UART4_CONFIG */
  195. #if defined(BSP_UART4_RX_USING_DMA)
  196. #ifndef UART4_RX_DMA_PRIORITY
  197. #define UART4_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  198. #endif /* UART4_RX_DMA_PRIORITY */
  199. #ifndef UART4_RX_DMA_PREEMPT_PRIORITY
  200. #define UART4_RX_DMA_PREEMPT_PRIORITY 0
  201. #endif /* UART4_RX_DMA_PREEMPT_PRIORITY */
  202. #ifndef UART4_RX_DMA_SUB_PRIORITY
  203. #define UART4_RX_DMA_SUB_PRIORITY 0
  204. #endif /* UART4_RX_DMA_SUB_PRIORITY */
  205. #ifndef UART4_DMA_RX_CONFIG
  206. #define UART4_DMA_RX_CONFIG \
  207. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  208. UART4_RX_DMA_INSTANCE, \
  209. UART4_RX_DMA_RCC, \
  210. UART4_RX_DMA_IRQ, \
  211. 0U, \
  212. UART4_RX_DMA_CHANNEL, \
  213. UART4_RX_DMA_PRIORITY, \
  214. UART4_RX_DMA_PREEMPT_PRIORITY, \
  215. UART4_RX_DMA_SUB_PRIORITY)
  216. #endif /* UART4_DMA_RX_CONFIG */
  217. #endif /* BSP_UART4_RX_USING_DMA */
  218. #if defined(BSP_UART4_TX_USING_DMA)
  219. #ifndef UART4_TX_DMA_PRIORITY
  220. #define UART4_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  221. #endif /* UART4_TX_DMA_PRIORITY */
  222. #ifndef UART4_TX_DMA_PREEMPT_PRIORITY
  223. #define UART4_TX_DMA_PREEMPT_PRIORITY 0
  224. #endif /* UART4_TX_DMA_PREEMPT_PRIORITY */
  225. #ifndef UART4_TX_DMA_SUB_PRIORITY
  226. #define UART4_TX_DMA_SUB_PRIORITY 0
  227. #endif /* UART4_TX_DMA_SUB_PRIORITY */
  228. #ifndef UART4_DMA_TX_CONFIG
  229. #define UART4_DMA_TX_CONFIG \
  230. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  231. UART4_TX_DMA_INSTANCE, \
  232. UART4_TX_DMA_RCC, \
  233. UART4_TX_DMA_IRQ, \
  234. 0U, \
  235. UART4_TX_DMA_CHANNEL, \
  236. UART4_TX_DMA_PRIORITY, \
  237. UART4_TX_DMA_PREEMPT_PRIORITY, \
  238. UART4_TX_DMA_SUB_PRIORITY)
  239. #endif /* UART4_DMA_TX_CONFIG */
  240. #endif /* BSP_UART4_TX_USING_DMA */
  241. #endif /* BSP_USING_UART4 */
  242. #if defined(BSP_USING_UART5)
  243. #ifndef UART5_CONFIG
  244. #define UART5_CONFIG \
  245. { \
  246. .name = "uart5", \
  247. .Instance = UART5, \
  248. .irq_type = UART5_IRQn, \
  249. }
  250. #endif /* UART5_CONFIG */
  251. #if defined(BSP_UART5_RX_USING_DMA)
  252. #ifndef UART5_RX_DMA_PRIORITY
  253. #define UART5_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  254. #endif /* UART5_RX_DMA_PRIORITY */
  255. #ifndef UART5_RX_DMA_PREEMPT_PRIORITY
  256. #define UART5_RX_DMA_PREEMPT_PRIORITY 0
  257. #endif /* UART5_RX_DMA_PREEMPT_PRIORITY */
  258. #ifndef UART5_RX_DMA_SUB_PRIORITY
  259. #define UART5_RX_DMA_SUB_PRIORITY 0
  260. #endif /* UART5_RX_DMA_SUB_PRIORITY */
  261. #ifndef UART5_DMA_RX_CONFIG
  262. #define UART5_DMA_RX_CONFIG \
  263. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  264. UART5_RX_DMA_INSTANCE, \
  265. UART5_RX_DMA_RCC, \
  266. UART5_RX_DMA_IRQ, \
  267. 0U, \
  268. UART5_RX_DMA_CHANNEL, \
  269. UART5_RX_DMA_PRIORITY, \
  270. UART5_RX_DMA_PREEMPT_PRIORITY, \
  271. UART5_RX_DMA_SUB_PRIORITY)
  272. #endif /* UART5_DMA_RX_CONFIG */
  273. #endif /* BSP_UART5_RX_USING_DMA */
  274. #if defined(BSP_UART5_TX_USING_DMA)
  275. #ifndef UART5_TX_DMA_PRIORITY
  276. #define UART5_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  277. #endif /* UART5_TX_DMA_PRIORITY */
  278. #ifndef UART5_TX_DMA_PREEMPT_PRIORITY
  279. #define UART5_TX_DMA_PREEMPT_PRIORITY 0
  280. #endif /* UART5_TX_DMA_PREEMPT_PRIORITY */
  281. #ifndef UART5_TX_DMA_SUB_PRIORITY
  282. #define UART5_TX_DMA_SUB_PRIORITY 0
  283. #endif /* UART5_TX_DMA_SUB_PRIORITY */
  284. #ifndef UART5_DMA_TX_CONFIG
  285. #define UART5_DMA_TX_CONFIG \
  286. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  287. UART5_TX_DMA_INSTANCE, \
  288. UART5_TX_DMA_RCC, \
  289. UART5_TX_DMA_IRQ, \
  290. 0U, \
  291. UART5_TX_DMA_CHANNEL, \
  292. UART5_TX_DMA_PRIORITY, \
  293. UART5_TX_DMA_PREEMPT_PRIORITY, \
  294. UART5_TX_DMA_SUB_PRIORITY)
  295. #endif /* UART5_DMA_TX_CONFIG */
  296. #endif /* BSP_UART5_TX_USING_DMA */
  297. #endif /* BSP_USING_UART5 */
  298. #if defined(BSP_USING_UART6)
  299. #ifndef UART6_CONFIG
  300. #define UART6_CONFIG \
  301. { \
  302. .name = "uart6", \
  303. .Instance = USART6, \
  304. .irq_type = USART6_IRQn, \
  305. }
  306. #endif /* UART6_CONFIG */
  307. #if defined(BSP_UART6_RX_USING_DMA)
  308. #ifndef UART6_RX_DMA_PRIORITY
  309. #define UART6_RX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  310. #endif /* UART6_RX_DMA_PRIORITY */
  311. #ifndef UART6_RX_DMA_PREEMPT_PRIORITY
  312. #define UART6_RX_DMA_PREEMPT_PRIORITY 0
  313. #endif /* UART6_RX_DMA_PREEMPT_PRIORITY */
  314. #ifndef UART6_RX_DMA_SUB_PRIORITY
  315. #define UART6_RX_DMA_SUB_PRIORITY 0
  316. #endif /* UART6_RX_DMA_SUB_PRIORITY */
  317. #ifndef UART6_DMA_RX_CONFIG
  318. #define UART6_DMA_RX_CONFIG \
  319. STM32_DMA_RX_BYTE_CIRCULAR_CONFIG_INIT_EX( \
  320. UART6_RX_DMA_INSTANCE, \
  321. UART6_RX_DMA_RCC, \
  322. UART6_RX_DMA_IRQ, \
  323. 0U, \
  324. UART6_RX_DMA_CHANNEL, \
  325. UART6_RX_DMA_PRIORITY, \
  326. UART6_RX_DMA_PREEMPT_PRIORITY, \
  327. UART6_RX_DMA_SUB_PRIORITY)
  328. #endif /* UART6_DMA_RX_CONFIG */
  329. #endif /* BSP_UART6_RX_USING_DMA */
  330. #if defined(BSP_UART6_TX_USING_DMA)
  331. #ifndef UART6_TX_DMA_PRIORITY
  332. #define UART6_TX_DMA_PRIORITY DMA_PRIORITY_MEDIUM
  333. #endif /* UART6_TX_DMA_PRIORITY */
  334. #ifndef UART6_TX_DMA_PREEMPT_PRIORITY
  335. #define UART6_TX_DMA_PREEMPT_PRIORITY 0
  336. #endif /* UART6_TX_DMA_PREEMPT_PRIORITY */
  337. #ifndef UART6_TX_DMA_SUB_PRIORITY
  338. #define UART6_TX_DMA_SUB_PRIORITY 0
  339. #endif /* UART6_TX_DMA_SUB_PRIORITY */
  340. #ifndef UART6_DMA_TX_CONFIG
  341. #define UART6_DMA_TX_CONFIG \
  342. STM32_DMA_TX_BYTE_CONFIG_INIT_EX( \
  343. UART6_TX_DMA_INSTANCE, \
  344. UART6_TX_DMA_RCC, \
  345. UART6_TX_DMA_IRQ, \
  346. 0U, \
  347. UART6_TX_DMA_CHANNEL, \
  348. UART6_TX_DMA_PRIORITY, \
  349. UART6_TX_DMA_PREEMPT_PRIORITY, \
  350. UART6_TX_DMA_SUB_PRIORITY)
  351. #endif /* UART6_DMA_TX_CONFIG */
  352. #endif /* BSP_UART6_TX_USING_DMA */
  353. #endif /* BSP_USING_UART6 */
  354. #ifdef __cplusplus
  355. }
  356. #endif
  357. #endif