hc32_ll_usart.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_usart.h
  4. * @brief This file contains all the functions prototypes of the USART(Universal
  5. * Synchronous/Asynchronous Receiver Transmitter) driver library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_USART_H__
  22. #define __HC32_LL_USART_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_USART
  40. * @{
  41. */
  42. #if (LL_USART_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup USART_Global_Types USART Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief clock synchronization mode initialization structure definition
  52. * @note The parameter(u32ClockDiv/u32CKOutput/u32Baudrate) is valid when clock source is the internal clock.
  53. */
  54. typedef struct {
  55. uint32_t u32ClockSrc; /*!< Clock Source.
  56. This parameter can be a value of @ref USART_Clock_Source */
  57. uint32_t u32ClockDiv; /*!< Clock division.
  58. This parameter can be a value of @ref USART_Clock_Division. */
  59. uint32_t u32Baudrate; /*!< USART baudrate.
  60. This parameter is valid when clock source is the internal clock. */
  61. uint32_t u32FirstBit; /*!< Significant bit.
  62. This parameter can be a value of @ref USART_First_Bit */
  63. uint32_t u32HWFlowControl; /*!< Hardware flow control.
  64. This parameter can be a value of @ref USART_Hardware_Flow_Control */
  65. } stc_usart_clocksync_init_t;
  66. /**
  67. * @brief UART multiple-processor initialization structure definition
  68. * @note The parameter(u32ClockDiv/u32CKOutput/u32Baudrate) is valid when clock source is the internal clock.
  69. */
  70. typedef struct {
  71. uint32_t u32ClockSrc; /*!< Clock Source.
  72. This parameter can be a value of @ref USART_Clock_Source */
  73. uint32_t u32ClockDiv; /*!< Clock division.
  74. This parameter can be a value of @ref USART_Clock_Division. */
  75. uint32_t u32CKOutput; /*!< USART_CK output selection.
  76. This parameter can be a value of @ref USART_CK_Output_Selection. */
  77. uint32_t u32Baudrate; /*!< USART baudrate.
  78. This parameter is valid when clock source is the internal clock. */
  79. uint32_t u32DataWidth; /*!< Data width.
  80. This parameter can be a value of @ref USART_Data_Width_Bit */
  81. uint32_t u32StopBit; /*!< Stop Bits.
  82. This parameter can be a value of @ref USART_Stop_Bit */
  83. uint32_t u32OverSampleBit; /*!< Oversampling Bits.
  84. This parameter can be a value of @ref USART_Over_Sample_Bit */
  85. uint32_t u32FirstBit; /*!< Significant bit.
  86. This parameter can be a value of @ref USART_First_Bit */
  87. uint32_t u32StartBitPolarity; /*!< Start Bit Detect Polarity.
  88. This parameter can be a value of @ref USART_Start_Bit_Polarity */
  89. uint32_t u32HWFlowControl; /*!< Hardware flow control.
  90. This parameter can be a value of @ref USART_Hardware_Flow_Control */
  91. } stc_usart_multiprocessor_init_t;
  92. /**
  93. * @brief UART mode initialization structure definition
  94. * @note The parameter(u32ClockDiv/u32CKOutput/u32Baudrate) is valid when clock source is the internal clock.
  95. */
  96. typedef struct {
  97. uint32_t u32ClockSrc; /*!< Clock Source.
  98. This parameter can be a value of @ref USART_Clock_Source */
  99. uint32_t u32ClockDiv; /*!< Clock division.
  100. This parameter can be a value of @ref USART_Clock_Division. */
  101. uint32_t u32CKOutput; /*!< USART_CK output selection.
  102. This parameter can be a value of @ref USART_CK_Output_Selection. */
  103. uint32_t u32Baudrate; /*!< USART baudrate.
  104. This parameter is valid when clock source is the internal clock. */
  105. uint32_t u32DataWidth; /*!< Data width.
  106. This parameter can be a value of @ref USART_Data_Width_Bit */
  107. uint32_t u32StopBit; /*!< Stop Bits.
  108. This parameter can be a value of @ref USART_Stop_Bit */
  109. uint32_t u32Parity; /*!< Parity format.
  110. This parameter can be a value of @ref USART_Parity_Control */
  111. uint32_t u32OverSampleBit; /*!< Oversampling Bits.
  112. This parameter can be a value of @ref USART_Over_Sample_Bit */
  113. uint32_t u32FirstBit; /*!< Significant bit.
  114. This parameter can be a value of @ref USART_First_Bit */
  115. uint32_t u32StartBitPolarity; /*!< Start Bit Detect Polarity.
  116. This parameter can be a value of @ref USART_Start_Bit_Polarity */
  117. uint32_t u32HWFlowControl; /*!< Hardware flow control.
  118. This parameter can be a value of @ref USART_Hardware_Flow_Control */
  119. } stc_usart_uart_init_t;
  120. /**
  121. * @brief LIN mode initialization structure definition
  122. * @note The parameter(u32ClockDiv/u32CKOutput/u32Baudrate) is valid when clock source is the internal clock.
  123. */
  124. typedef struct {
  125. uint32_t u32ClockSrc; /*!< Clock Source.
  126. This parameter can be a value of @ref USART_Clock_Source */
  127. uint32_t u32ClockDiv; /*!< Clock division.
  128. This parameter can be a value of @ref USART_Clock_Division. */
  129. uint32_t u32CKOutput; /*!< USART_CK output selection.
  130. This parameter can be a value of @ref USART_CK_Output_Selection. */
  131. uint32_t u32Baudrate; /*!< USART baudrate.
  132. This parameter is valid when clock source is the internal clock. */
  133. uint32_t u32OverSampleBit; /*!< Oversampling Bits.
  134. This parameter can be a value of @ref USART_Over_Sample_Bit */
  135. uint32_t u32BmcClockDiv; /*!< BMC clock division.
  136. This parameter can be a value of @ref USART_LIN_BMC_Clock_Division.
  137. @note The clock division is valid when clock source is the internal clock. */
  138. uint32_t u32DetectBreakLen; /*!< Detect break length.
  139. This parameter can be a value of @ref USART_LIN_Detect_Break_Length */
  140. uint32_t u32SendBreakLen; /*!< Send break length.
  141. This parameter can be a value of @ref USART_LIN_Send_Break_Length */
  142. uint32_t u32SendBreakMode; /*!< Send break mode.
  143. This parameter can be a value of @ref USART_LIN_Send_Break_Mode */
  144. } stc_usart_lin_init_t;
  145. /**
  146. * @brief Smartcard mode initialization structure definition
  147. */
  148. typedef struct {
  149. uint32_t u32ClockDiv; /*!< Clock division. This parameter can be a value of @ref USART_Clock_Division.
  150. @note This parameter is valid when clock source is the internal clock. */
  151. uint32_t u32CKOutput; /*!< USART_CK output selection. This parameter can be a value of @ref USART_CK_Output_Selection.
  152. @note This parameter is valid when clock source is the internal clock. */
  153. uint32_t u32Baudrate; /*!< USART baudrate.
  154. This parameter is calculated according with smartcard default ETU and clock. */
  155. uint32_t u32StopBit; /*!< Stop Bits.
  156. This parameter can be a value of @ref USART_Stop_Bit */
  157. uint32_t u32FirstBit; /*!< Significant bit.
  158. This parameter can be a value of @ref USART_First_Bit */
  159. } stc_usart_smartcard_init_t;
  160. /**
  161. * @}
  162. */
  163. /*******************************************************************************
  164. * Global pre-processor symbols/macros ('#define')
  165. ******************************************************************************/
  166. /**
  167. * @defgroup USART_Global_Macros USART Global Macros
  168. * @{
  169. */
  170. /**
  171. * @defgroup USART_Flag USART Flag
  172. * @{
  173. */
  174. #define USART_FLAG_RX_FULL (USART_SR_RXNE) /*!< Receive data register not empty flag */
  175. #define USART_FLAG_OVERRUN (USART_SR_ORE) /*!< Overrun error flag */
  176. #define USART_FLAG_TX_CPLT (USART_SR_TC) /*!< Transmission complete flag */
  177. #define USART_FLAG_TX_EMPTY (USART_SR_TXE) /*!< Transmit data register empty flag */
  178. #define USART_FLAG_FRAME_ERR (USART_SR_FE) /*!< Framing error flag */
  179. #define USART_FLAG_PARITY_ERR (USART_SR_PE) /*!< Parity error flag */
  180. #define USART_FLAG_MX_PROCESSOR (USART_SR_MPB) /*!< Receive processor ID flag */
  181. #define USART_FLAG_RX_TIMEOUT (USART_SR_RTOF) /*!< Receive timeout flag */
  182. #define USART_FLAG_LIN_ERR (USART_SR_BE) /*!< LIN bus error flag */
  183. #define USART_FLAG_LIN_WKUP (USART_SR_WKUP) /*!< LIN wakeup signal detection flag */
  184. #define USART_FLAG_LIN_BREAK (USART_SR_LBD) /*!< LIN break signal detection flag */
  185. #define USART_FLAG_TX_END (USART_SR_TEND) /*!< Transmission complete flag (can be cleared) */
  186. #define USART_FLAG_ALL (USART_FLAG_RX_FULL | USART_FLAG_FRAME_ERR | USART_FLAG_TX_EMPTY | \
  187. USART_FLAG_OVERRUN | USART_FLAG_PARITY_ERR | USART_FLAG_RX_TIMEOUT | \
  188. USART_FLAG_TX_CPLT | USART_FLAG_LIN_BREAK | USART_FLAG_LIN_WKUP | \
  189. USART_FLAG_LIN_ERR | USART_FLAG_MX_PROCESSOR | USART_FLAG_TX_END)
  190. /**
  191. * @}
  192. */
  193. /**
  194. * @defgroup USART_Transmission_Type USART Transmission Type
  195. * @{
  196. */
  197. #define USART_TRANS_DATA (0UL)
  198. #define USART_TRANS_ID (USART_DR_MPID)
  199. /**
  200. * @}
  201. */
  202. /**
  203. * @defgroup USART_Function USART Function
  204. * @{
  205. */
  206. #define USART_TX (USART_CR1_TE) /*!< USART TX function */
  207. #define USART_RX (USART_CR1_RE) /*!< USART RX function */
  208. #define USART_INT_RX (USART_CR1_RIE) /*!< USART receive data register not empty && receive error interrupt */
  209. #define USART_INT_TX_CPLT (USART_CR1_TCIE) /*!< USART transmission complete interrupt */
  210. #define USART_INT_TX_EMPTY (USART_CR1_TXEIE) /*!< USART transmit data register empty interrupt */
  211. #define USART_RX_TIMEOUT (USART_CR1_RTOE) /*!< USART RX timerout function */
  212. #define USART_INT_RX_TIMEOUT (USART_CR1_RTOIE) /*!< USART RX timerout interrupt */
  213. #define USART_INT_TX_END (USART_CR1_TENDIE) /*!< USART transmission complete interrupt */
  214. #define USART_LIN (USART_CR2_LINEN << 16UL) /*!< USART LIN function */
  215. #define USART_LIN_WKUP (USART_CR2_WKUPE << 16UL) /*!< USART LIN wakeup signal detect function */
  216. #define USART_LIN_ERR (USART_CR2_BEE << 16UL) /*!< USART LIN bus error detect function */
  217. #define USART_LIN_BREAK (USART_CR2_LBDL << 16UL) /*!< USART LIN bus break field detect function */
  218. #define USART_LIN_INT_ERR (USART_CR2_BEIE << 16UL) /*!< USART LIN bus error detect interrupt function */
  219. #define USART_LIN_INT_BREAK (USART_CR2_LBDIE << 16UL) /*!< USART LIN bus break field detect interrupt function */
  220. #define USART_LIN_INT_WKUP (USART_CR2_WKUPIE << 16UL) /*!< USART LIN bus wakeup signal detect interrupt function */
  221. #define USART_FUNC_ALL (USART_TX | USART_RX | USART_INT_RX | USART_INT_TX_CPLT | USART_RX_TIMEOUT | \
  222. USART_INT_RX_TIMEOUT | USART_INT_TX_EMPTY | USART_LIN | USART_LIN_WKUP | \
  223. USART_LIN_ERR | USART_LIN_BREAK | USART_LIN_INT_ERR | USART_LIN_INT_BREAK | \
  224. USART_LIN_INT_WKUP | USART_INT_TX_END)
  225. /**
  226. * @}
  227. */
  228. /**
  229. * @defgroup USART_Parity_Control USART Parity Control
  230. * @{
  231. */
  232. #define USART_PARITY_NONE (0UL) /*!< Parity control disabled */
  233. #define USART_PARITY_EVEN (USART_CR1_PCE) /*!< Parity control enabled and Even Parity is selected */
  234. #define USART_PARITY_ODD (USART_CR1_PCE | \
  235. USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  236. /**
  237. * @}
  238. */
  239. /**
  240. * @defgroup USART_Data_Width_Bit USART Data Width Bit
  241. * @{
  242. */
  243. #define USART_DATA_WIDTH_8BIT (0UL) /*!< 8 bits */
  244. #define USART_DATA_WIDTH_9BIT (USART_CR1_M) /*!< 9 bits */
  245. /**
  246. * @}
  247. */
  248. /**
  249. * @defgroup USART_Over_Sample_Bit USART Over Sample Bit
  250. * @{
  251. */
  252. #define USART_OVER_SAMPLE_16BIT (0UL) /*!< Oversampling by 16 bits */
  253. #define USART_OVER_SAMPLE_8BIT (USART_CR1_OVER8) /*!< Oversampling by 8 bits */
  254. /**
  255. * @}
  256. */
  257. /**
  258. * @defgroup USART_First_Bit USART First Bit
  259. * @{
  260. */
  261. #define USART_FIRST_BIT_LSB (0UL) /*!< LSB(Least Significant Bit) */
  262. #define USART_FIRST_BIT_MSB (USART_CR1_ML) /*!< MSB(Most Significant Bit) */
  263. /**
  264. * @}
  265. */
  266. /**
  267. * @defgroup USART_Start_Bit_Polarity USART Start Bit Polarity
  268. * @{
  269. */
  270. #define USART_START_BIT_LOW (0UL) /*!< Detect RX pin low level */
  271. #define USART_START_BIT_FALLING (USART_CR1_SBS) /*!< Detect RX pin falling edge */
  272. /**
  273. * @}
  274. */
  275. /**
  276. * @defgroup USART_Clock_Source USART Clock Source
  277. * @{
  278. */
  279. #define USART_CLK_SRC_INTERNCLK (0UL) /*!< Select internal clock source and don't output clock */
  280. #define USART_CLK_SRC_EXTCLK (USART_CR2_CLKC_1) /*!< Select external clock source. */
  281. /**
  282. * @}
  283. */
  284. /**
  285. * @defgroup USART_CK_Output_Selection USART_CK Output Selection
  286. * @{
  287. */
  288. #define USART_CK_OUTPUT_DISABLE (0UL) /*!< Disable USART_CK output */
  289. #define USART_CK_OUTPUT_ENABLE (USART_CR2_CLKC_0) /*!< Enable USART_CK output. */
  290. /**
  291. * @}
  292. */
  293. /**
  294. * @defgroup USART_Stop_Bit USART Stop Bit
  295. * @{
  296. */
  297. #define USART_STOPBIT_1BIT (0UL) /*!< 1 stop bit */
  298. #define USART_STOPBIT_2BIT (USART_CR2_STOP) /*!< 2 stop bit */
  299. /**
  300. * @}
  301. */
  302. /**
  303. * @defgroup USART_Hardware_Flow_Control USART Hardware Flow Control
  304. * @{
  305. */
  306. #define USART_HW_FLOWCTRL_CTS (USART_CR3_CTSE) /*!< USART hardware flow control CTS mode */
  307. #define USART_HW_FLOWCTRL_RTS (USART_CR3_CTSE >> 1U) /*!< USART hardware flow control RTS mode */
  308. #define USART_HW_FLOWCTRL_NONE (0UL) /*!< Disable USART hardware flow controle */
  309. #define USART_HW_FLOWCTRL_RTS_CTS (USART_HW_FLOWCTRL_CTS | \
  310. USART_HW_FLOWCTRL_RTS) /*!< USART hardware flow control RTS and CTS mode */
  311. /**
  312. * @}
  313. */
  314. /**
  315. * @defgroup USART_Clock_Division USART Clock Division
  316. * @{
  317. */
  318. #define USART_CLK_DIV1 (0UL) /*!< CLK */
  319. #define USART_CLK_DIV4 (1UL) /*!< CLK/4 */
  320. #define USART_CLK_DIV16 (2UL) /*!< CLK/16 */
  321. #define USART_CLK_DIV64 (3UL) /*!< CLK/64 */
  322. #define USART_CLK_DIV128 (0UL | USART_PR_ULBREN) /*!< CLK/128 */
  323. #define USART_CLK_DIV256 (1UL | USART_PR_ULBREN) /*!< CLK/256 */
  324. #define USART_CLK_DIV512 (2UL | USART_PR_ULBREN) /*!< CLK/512 */
  325. #define USART_CLK_DIV1024 (3UL | USART_PR_ULBREN) /*!< CLK/1024 */
  326. /**
  327. * @}
  328. */
  329. /**
  330. * @defgroup USART_Max_Timeout USART Max Timeout
  331. * @{
  332. */
  333. #define USART_MAX_TIMEOUT (0xFFFFFFFFUL)
  334. /**
  335. * @}
  336. */
  337. /**
  338. * @defgroup USART_Smartcard_ETU_Clock USART Smartcard ETU Clock
  339. * @{
  340. */
  341. #define USART_SC_ETU_CLK32 (0UL << USART_CR3_BCN_POS) /*!< 1 etu = 32/f */
  342. #define USART_SC_ETU_CLK64 (1UL << USART_CR3_BCN_POS) /*!< 1 etu = 64/f */
  343. #define USART_SC_ETU_CLK128 (2UL << USART_CR3_BCN_POS) /*!< 1 etu = 128/f */
  344. #define USART_SC_ETU_CLK256 (3UL << USART_CR3_BCN_POS) /*!< 1 etu = 256/f */
  345. #define USART_SC_ETU_CLK372 (6UL << USART_CR3_BCN_POS) /*!< 1 etu = 372/f */
  346. /**
  347. * @}
  348. */
  349. /**
  350. * @defgroup USART_Stop_Mode_Noise_Filter_Width_Level USART Stop Mode Noise Filter Width Level
  351. * @{
  352. */
  353. #define USART_STOP_MD_FILTER_LVL1 (0UL) /*!< Filter width level 1 */
  354. #define USART_STOP_MD_FILTER_LVL2 (PERIC_USART1_NFC_USASRT1_NFS_0) /*!< Filter width level 2 */
  355. #define USART_STOP_MD_FILTER_LVL3 (PERIC_USART1_NFC_USASRT1_NFS_1) /*!< Filter width level 3 */
  356. #define USART_STOP_MD_FILTER_LVL4 (PERIC_USART1_NFC_USASRT1_NFS) /*!< Filter width level 4 */
  357. /**
  358. * @}
  359. */
  360. /**
  361. * @defgroup USART_LIN_BMC_Clock_Division USART LIN Baudrate Measure Counter Clock Division
  362. * @{
  363. */
  364. #define USART_LIN_BMC_CLK_DIV1 (0UL) /*!< CLK */
  365. #define USART_LIN_BMC_CLK_DIV2 (USART_PR_LBMPSC_0) /*!< CLK/2 */
  366. #define USART_LIN_BMC_CLK_DIV4 (USART_PR_LBMPSC_1) /*!< CLK/4 */
  367. #define USART_LIN_BMC_CLK_DIV8 (USART_PR_LBMPSC) /*!< CLK/8 */
  368. /**
  369. * @}
  370. */
  371. /**
  372. * @defgroup USART_LIN_Send_Break_Mode USART LIN Send Break Mode
  373. * @{
  374. */
  375. #define USART_LIN_SEND_BREAK_MD_SBK (0UL) /*!< Start send break after USART_CR2 SBK bit set 1 value */
  376. #define USART_LIN_SEND_BREAK_MD_TDR (USART_CR2_SBKM) /*!< Start send break after USART_DR TDR write 0x00 value */
  377. /**
  378. * @}
  379. */
  380. /**
  381. * @defgroup USART_LIN_Detect_Break_Length USART LIN Detect Break Length
  382. * @{
  383. */
  384. #define USART_LIN_DETECT_BREAK_10BIT (0UL) /*!< Detect break 10-bit */
  385. #define USART_LIN_DETECT_BREAK_11BIT (USART_CR2_LBDL) /*!< Detect break 11-bit */
  386. /**
  387. * @}
  388. */
  389. /**
  390. * @defgroup USART_LIN_Send_Break_Length USART LIN Send Break Length
  391. * @{
  392. */
  393. #define USART_LIN_SEND_BREAK_10BIT (0UL) /*!< Send break 10-bit */
  394. #define USART_LIN_SEND_BREAK_11BIT (USART_CR2_SBKL_0) /*!< Send break 11-bit */
  395. #define USART_LIN_SEND_BREAK_13BIT (USART_CR2_SBKL_1) /*!< Send break 13-bit */
  396. #define USART_LIN_SEND_BREAK_14BIT (USART_CR2_SBKL) /*!< Send break 14-bit */
  397. /**
  398. * @}
  399. */
  400. /**
  401. * @}
  402. */
  403. /*******************************************************************************
  404. * Global variable definitions ('extern')
  405. ******************************************************************************/
  406. /*******************************************************************************
  407. Global function prototypes (definition in C source)
  408. ******************************************************************************/
  409. /**
  410. * @addtogroup USART_Global_Functions
  411. * @{
  412. */
  413. int32_t USART_ClockSync_StructInit(stc_usart_clocksync_init_t *pstcClockSyncInit);
  414. int32_t USART_ClockSync_Init(CM_USART_TypeDef *USARTx,
  415. const stc_usart_clocksync_init_t *pstcClockSyncInit, float32_t *pf32Error);
  416. int32_t USART_MultiProcessor_StructInit(stc_usart_multiprocessor_init_t *pstcMultiProcessorInit);
  417. int32_t USART_MultiProcessor_Init(CM_USART_TypeDef *USARTx,
  418. const stc_usart_multiprocessor_init_t *pstcMultiProcessorInit, float32_t *pf32Error);
  419. int32_t USART_UART_StructInit(stc_usart_uart_init_t *pstcUartInit);
  420. int32_t USART_UART_Init(CM_USART_TypeDef *USARTx, const stc_usart_uart_init_t *pstcUartInit, float32_t *pf32Error);
  421. int32_t USART_HalfDuplex_Init(CM_USART_TypeDef *USARTx,
  422. const stc_usart_uart_init_t *pstcUartInit, float32_t *pf32Error);
  423. int32_t USART_LIN_StructInit(stc_usart_lin_init_t *pstcLinInit);
  424. int32_t USART_LIN_Init(CM_USART_TypeDef *USARTx, const stc_usart_lin_init_t *pstcLinInit, float32_t *pf32Error);
  425. int32_t USART_SmartCard_StructInit(stc_usart_smartcard_init_t *pstcSmartCardInit);
  426. int32_t USART_SmartCard_Init(CM_USART_TypeDef *USARTx,
  427. const stc_usart_smartcard_init_t *pstcSmartCardInit, float32_t *pf32Error);
  428. void USART_DeInit(CM_USART_TypeDef *USARTx);
  429. void USART_FuncCmd(CM_USART_TypeDef *USARTx, uint32_t u32Func, en_functional_state_t enNewState);
  430. en_flag_status_t USART_GetStatus(const CM_USART_TypeDef *USARTx, uint32_t u32Flag);
  431. void USART_ClearStatus(CM_USART_TypeDef *USARTx, uint32_t u32Flag);
  432. void USART_SetParity(CM_USART_TypeDef *USARTx, uint32_t u32Parity);
  433. void USART_SetFirstBit(CM_USART_TypeDef *USARTx, uint32_t u32FirstBit);
  434. void USART_SetStopBit(CM_USART_TypeDef *USARTx, uint32_t u32StopBit);
  435. void USART_SetDataWidth(CM_USART_TypeDef *USARTx, uint32_t u32DataWidth);
  436. void USART_SetOverSampleBit(CM_USART_TypeDef *USARTx, uint32_t u32OverSampleBit);
  437. void USART_SetStartBitPolarity(CM_USART_TypeDef *USARTx, uint32_t u32Polarity);
  438. void USART_SetTransType(CM_USART_TypeDef *USARTx, uint32_t u32Type);
  439. void USART_SetClockDiv(CM_USART_TypeDef *USARTx, uint32_t u32ClockDiv);
  440. uint32_t USART_GetClockDiv(const CM_USART_TypeDef *USARTx);
  441. void USART_SetClockSrc(CM_USART_TypeDef *USARTx, uint32_t u32ClockSrc);
  442. uint32_t USART_GetClockSrc(const CM_USART_TypeDef *USARTx);
  443. void USART_FilterCmd(CM_USART_TypeDef *USARTx, en_functional_state_t enNewState);
  444. void USART_SilenceCmd(CM_USART_TypeDef *USARTx, en_functional_state_t enNewState);
  445. void USART_SetHWFlowControl(CM_USART_TypeDef *USARTx, uint32_t u32HWFlowControl);
  446. uint16_t USART_ReadData(const CM_USART_TypeDef *USARTx);
  447. void USART_WriteData(CM_USART_TypeDef *USARTx, uint16_t u16Data);
  448. void USART_WriteID(CM_USART_TypeDef *USARTx, uint16_t u16ID);
  449. int32_t USART_SetBaudrate(CM_USART_TypeDef *USARTx, uint32_t u32Baudrate, float32_t *pf32Error);
  450. void USART_SmartCard_SetEtuClock(CM_USART_TypeDef *USARTx, uint32_t u32EtuClock);
  451. void USART_StopModeNoiseFilterCmd(const CM_USART_TypeDef *USARTx, en_functional_state_t enNewState);
  452. void USART_SetStopModeNoiseFilter(const CM_USART_TypeDef *USARTx, uint32_t u32Level);
  453. void USART_LIN_LoopbackCmd(CM_USART_TypeDef *USARTx, en_functional_state_t enNewState);
  454. void USART_LIN_SetBmcClockDiv(CM_USART_TypeDef *USARTx, uint32_t u32ClockDiv);
  455. void USART_LIN_RequestBreakSending(CM_USART_TypeDef *USARTx);
  456. en_flag_status_t USART_LIN_GetRequestBreakStatus(const CM_USART_TypeDef *USARTx);
  457. void USART_LIN_SetBreakMode(CM_USART_TypeDef *USARTx, uint32_t u32Mode);
  458. uint32_t USART_LIN_GetBreakMode(const CM_USART_TypeDef *USARTx);
  459. uint32_t USART_LIN_GetMeasureCount(const CM_USART_TypeDef *USARTx);
  460. uint32_t USART_LIN_GetMeasureBaudrate(const CM_USART_TypeDef *USARTx);
  461. void USART_LIN_SetDetectBreakLen(CM_USART_TypeDef *USARTx, uint32_t u32Len);
  462. void USART_LIN_SetSendBreakLen(CM_USART_TypeDef *USARTx, uint32_t u32Len);
  463. int32_t USART_UART_Trans(CM_USART_TypeDef *USARTx, const void *pvBuf, uint32_t u32Len, uint32_t u32Timeout);
  464. int32_t USART_UART_Receive(const CM_USART_TypeDef *USARTx, void *pvBuf, uint32_t u32Len, uint32_t u32Timeout);
  465. int32_t USART_ClockSync_Trans(CM_USART_TypeDef *USARTx, const uint8_t au8Buf[], uint32_t u32Len, uint32_t u32Timeout);
  466. int32_t USART_ClockSync_Receive(CM_USART_TypeDef *USARTx, uint8_t au8Buf[], uint32_t u32Len, uint32_t u32Timeout);
  467. int32_t USART_ClockSync_TransReceive(CM_USART_TypeDef *USARTx, const uint8_t au8TxBuf[], uint8_t au8RxBuf[],
  468. uint32_t u32Len, uint32_t u32Timeout);
  469. /**
  470. * @}
  471. */
  472. #endif /* LL_USART_ENABLE */
  473. /**
  474. * @}
  475. */
  476. /**
  477. * @}
  478. */
  479. #ifdef __cplusplus
  480. }
  481. #endif
  482. #endif /* __HC32_LL_USART_H__ */
  483. /*******************************************************************************
  484. * EOF (not truncated)
  485. ******************************************************************************/