ft32f0xx_usart.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_usart.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the USART
  6. * firmware library.
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_USART_H
  13. #define __FT32F0XX_USART_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. /** @addtogroup USART
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /**
  24. * @brief USART Init Structure definition
  25. */
  26. typedef struct
  27. {
  28. uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate.
  29. The baud rate is computed using the following formula:
  30. - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate)))
  31. - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
  32. uint32_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  33. This parameter can be a value of @ref USART_Word_Length */
  34. uint32_t USART_StopBits; /*!< Specifies the number of stop bits transmitted.
  35. This parameter can be a value of @ref USART_Stop_Bits */
  36. uint32_t USART_Parity; /*!< Specifies the parity mode.
  37. This parameter can be a value of @ref USART_Parity
  38. @note When parity is enabled, the computed parity is inserted
  39. at the MSB position of the transmitted data (9th bit when
  40. the word length is set to 9 data bits; 8th bit when the
  41. word length is set to 8 data bits). */
  42. uint32_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
  43. This parameter can be a value of @ref USART_Mode */
  44. uint32_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
  45. or disabled.
  46. This parameter can be a value of @ref USART_Hardware_Flow_Control*/
  47. } USART_InitTypeDef;
  48. /**
  49. * @brief USART Clock Init Structure definition
  50. */
  51. typedef struct
  52. {
  53. uint32_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled.
  54. This parameter can be a value of @ref USART_Clock */
  55. uint32_t USART_CPOL; /*!< Specifies the steady state of the serial clock.
  56. This parameter can be a value of @ref USART_Clock_Polarity */
  57. uint32_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made.
  58. This parameter can be a value of @ref USART_Clock_Phase */
  59. uint32_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
  60. data bit (MSB) has to be output on the SCLK pin in synchronous mode.
  61. This parameter can be a value of @ref USART_Last_Bit */
  62. } USART_ClockInitTypeDef;
  63. /* Exported constants --------------------------------------------------------*/
  64. /** @defgroup USART_Exported_Constants
  65. * @{
  66. */
  67. #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \
  68. ((PERIPH) == USART2))
  69. #define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \
  70. ((PERIPH) == USART2) || \
  71. ((PERIPH) == USART3))
  72. /** @defgroup USART_Word_Length
  73. * @{
  74. */
  75. #define USART_WordLength_8b ((uint32_t)0x00000000)
  76. #define USART_WordLength_9b USART_CR1_M /* should be ((uint32_t)0x00001000) */
  77. #define USART_WordLength_7b ((uint32_t)0x10001000)
  78. #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \
  79. ((LENGTH) == USART_WordLength_9b) || \
  80. ((LENGTH) == USART_WordLength_7b))
  81. /**
  82. * @}
  83. */
  84. /** @defgroup USART_Stop_Bits
  85. * @{
  86. */
  87. #define USART_StopBits_1 ((uint32_t)0x00000000)
  88. #define USART_StopBits_2 USART_CR2_STOP_1
  89. #define USART_StopBits_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1)
  90. #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \
  91. ((STOPBITS) == USART_StopBits_2) || \
  92. ((STOPBITS) == USART_StopBits_1_5))
  93. /**
  94. * @}
  95. */
  96. /** @defgroup USART_Parity
  97. * @{
  98. */
  99. #define USART_Parity_No ((uint32_t)0x00000000)
  100. #define USART_Parity_Even USART_CR1_PCE
  101. #define USART_Parity_Odd (USART_CR1_PCE | USART_CR1_PS)
  102. #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \
  103. ((PARITY) == USART_Parity_Even) || \
  104. ((PARITY) == USART_Parity_Odd))
  105. /**
  106. * @}
  107. */
  108. /** @defgroup USART_Mode
  109. * @{
  110. */
  111. #define USART_Mode_Rx USART_CR1_RE
  112. #define USART_Mode_Tx USART_CR1_TE
  113. #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFFFFFF3) == 0x00) && \
  114. ((MODE) != (uint32_t)0x00))
  115. /**
  116. * @}
  117. */
  118. /** @defgroup USART_Hardware_Flow_Control
  119. * @{
  120. */
  121. #define USART_HardwareFlowControl_None ((uint32_t)0x00000000)
  122. #define USART_HardwareFlowControl_RTS USART_CR3_RTSE
  123. #define USART_HardwareFlowControl_CTS USART_CR3_CTSE
  124. #define USART_HardwareFlowControl_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE)
  125. #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\
  126. (((CONTROL) == USART_HardwareFlowControl_None) || \
  127. ((CONTROL) == USART_HardwareFlowControl_RTS) || \
  128. ((CONTROL) == USART_HardwareFlowControl_CTS) || \
  129. ((CONTROL) == USART_HardwareFlowControl_RTS_CTS))
  130. /**
  131. * @}
  132. */
  133. /** @defgroup USART_Clock
  134. * @{
  135. */
  136. #define USART_Clock_Disable ((uint32_t)0x00000000)
  137. #define USART_Clock_Enable USART_CR2_CLKEN
  138. #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \
  139. ((CLOCK) == USART_Clock_Enable))
  140. /**
  141. * @}
  142. */
  143. /** @defgroup USART_Clock_Polarity
  144. * @{
  145. */
  146. #define USART_CPOL_Low ((uint32_t)0x00000000)
  147. #define USART_CPOL_High USART_CR2_CPOL
  148. #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High))
  149. /**
  150. * @}
  151. */
  152. /** @defgroup USART_Clock_Phase
  153. * @{
  154. */
  155. #define USART_CPHA_1Edge ((uint32_t)0x00000000)
  156. #define USART_CPHA_2Edge USART_CR2_CPHA
  157. #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge))
  158. /**
  159. * @}
  160. */
  161. /** @defgroup USART_Last_Bit
  162. * @{
  163. */
  164. #define USART_LastBit_Disable ((uint32_t)0x00000000)
  165. #define USART_LastBit_Enable USART_CR2_LBCL
  166. #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \
  167. ((LASTBIT) == USART_LastBit_Enable))
  168. /**
  169. * @}
  170. */
  171. /** @defgroup USART_DMA_Requests
  172. * @{
  173. */
  174. #define USART_DMAReq_Tx USART_CR3_DMAT
  175. #define USART_DMAReq_Rx USART_CR3_DMAR
  176. #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint32_t)0xFFFFFF3F) == 0x00) && \
  177. ((DMAREQ) != (uint32_t)0x00))
  178. /**
  179. * @}
  180. */
  181. /** @defgroup USART_DMA_Recception_Error
  182. * @{
  183. */
  184. #define USART_DMAOnError_Enable ((uint32_t)0x00000000)
  185. #define USART_DMAOnError_Disable USART_CR3_DDRE
  186. #define IS_USART_DMAONERROR(DMAERROR) (((DMAERROR) == USART_DMAOnError_Disable)|| \
  187. ((DMAERROR) == USART_DMAOnError_Enable))
  188. /**
  189. * @}
  190. */
  191. /** @defgroup USART_MuteMode_WakeUp_methods
  192. * @{
  193. */
  194. #define USART_WakeUp_IdleLine ((uint32_t)0x00000000)
  195. #define USART_WakeUp_AddressMark USART_CR1_WAKE
  196. #define IS_USART_MUTEMODE_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \
  197. ((WAKEUP) == USART_WakeUp_AddressMark))
  198. /**
  199. * @}
  200. */
  201. /** @defgroup USART_Address_Detection
  202. * @{
  203. */
  204. #define USART_AddressLength_4b ((uint32_t)0x00000000)
  205. #define USART_AddressLength_7b USART_CR2_ADDM7
  206. #define IS_USART_ADDRESS_DETECTION(ADDRESS) (((ADDRESS) == USART_AddressLength_4b) || \
  207. ((ADDRESS) == USART_AddressLength_7b))
  208. /**
  209. * @}
  210. */
  211. /**
  212. * @}
  213. */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup USART_IrDA_Low_Power
  218. * @{
  219. */
  220. #define USART_IrDAMode_LowPower USART_CR3_IRLP
  221. #define USART_IrDAMode_Normal ((uint32_t)0x00000000)
  222. #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \
  223. ((MODE) == USART_IrDAMode_Normal))
  224. /**
  225. * @}
  226. */
  227. /** @defgroup USART_DE_Polarity
  228. * @{
  229. */
  230. #define USART_DEPolarity_High ((uint32_t)0x00000000)
  231. #define USART_DEPolarity_Low USART_CR3_DEP
  232. #define IS_USART_DE_POLARITY(POLARITY) (((POLARITY) == USART_DEPolarity_Low) || \
  233. ((POLARITY) == USART_DEPolarity_High))
  234. /**
  235. * @}
  236. */
  237. /** @defgroup USART_Inversion_Pins
  238. * @{
  239. */
  240. #define USART_InvPin_Tx USART_CR2_TXINV
  241. #define USART_InvPin_Rx USART_CR2_RXINV
  242. #define IS_USART_INVERSTION_PIN(PIN) ((((PIN) & (uint32_t)0xFFFCFFFF) == 0x00) && \
  243. ((PIN) != (uint32_t)0x00))
  244. /**
  245. * @}
  246. */
  247. /** @defgroup USART_AutoBaudRate_Mode
  248. * @{
  249. */
  250. #define USART_AutoBaudRate_StartBit ((uint32_t)0x00000000)
  251. #define USART_AutoBaudRate_FallingEdge USART_CR2_ABRMODE_0
  252. #define IS_USART_AUTOBAUDRATE_MODE(MODE) (((MODE) == USART_AutoBaudRate_StartBit) || \
  253. ((MODE) == USART_AutoBaudRate_FallingEdge))
  254. /**
  255. * @}
  256. */
  257. /** @defgroup USART_OVR_DETECTION
  258. * @{
  259. */
  260. #define USART_OVRDetection_Enable ((uint32_t)0x00000000)
  261. #define USART_OVRDetection_Disable USART_CR3_OVRDIS
  262. #define IS_USART_OVRDETECTION(OVR) (((OVR) == USART_OVRDetection_Enable)|| \
  263. ((OVR) == USART_OVRDetection_Disable))
  264. /**
  265. * @}
  266. */
  267. /** @defgroup USART_Request
  268. * @{
  269. */
  270. #define USART_Request_ABRRQ USART_RQR_ABRRQ
  271. #define USART_Request_SBKRQ USART_RQR_SBKRQ
  272. #define USART_Request_MMRQ USART_RQR_MMRQ
  273. #define USART_Request_RXFRQ USART_RQR_RXFRQ
  274. #define USART_Request_TXFRQ USART_RQR_TXFRQ
  275. #define IS_USART_REQUEST(REQUEST) (((REQUEST) == USART_Request_TXFRQ) || \
  276. ((REQUEST) == USART_Request_RXFRQ) || \
  277. ((REQUEST) == USART_Request_MMRQ) || \
  278. ((REQUEST) == USART_Request_SBKRQ) || \
  279. ((REQUEST) == USART_Request_ABRRQ))
  280. /**
  281. * @}
  282. */
  283. /** @defgroup USART_Flags
  284. * @{
  285. */
  286. #define USART_FLAG_REACK USART_ISR_REACK
  287. #define USART_FLAG_TEACK USART_ISR_TEACK
  288. #define USART_FLAG_WU USART_ISR_WUF
  289. #define USART_FLAG_RWU USART_ISR_RWU
  290. #define USART_FLAG_SBK USART_ISR_SBKF
  291. #define USART_FLAG_CM USART_ISR_CMF
  292. #define USART_FLAG_BUSY USART_ISR_BUSY
  293. #define USART_FLAG_ABRF USART_ISR_ABRF
  294. #define USART_FLAG_ABRE USART_ISR_ABRE
  295. #define USART_FLAG_EOB USART_ISR_EOBF
  296. #define USART_FLAG_RTO USART_ISR_RTOF
  297. #define USART_FLAG_nCTSS USART_ISR_CTS
  298. #define USART_FLAG_CTS USART_ISR_CTSIF
  299. #define USART_FLAG_LBD USART_ISR_LBD
  300. #define USART_FLAG_TXE USART_ISR_TXE
  301. #define USART_FLAG_TC USART_ISR_TC
  302. #define USART_FLAG_RXNE USART_ISR_RXNE
  303. #define USART_FLAG_IDLE USART_ISR_IDLE
  304. #define USART_FLAG_ORE USART_ISR_ORE
  305. #define USART_FLAG_NE USART_ISR_NE
  306. #define USART_FLAG_FE USART_ISR_FE
  307. #define USART_FLAG_PE USART_ISR_PE
  308. #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \
  309. ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \
  310. ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \
  311. ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \
  312. ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \
  313. ((FLAG) == USART_FLAG_nCTSS) || ((FLAG) == USART_FLAG_RTO) || \
  314. ((FLAG) == USART_FLAG_EOB) || ((FLAG) == USART_FLAG_ABRE) || \
  315. ((FLAG) == USART_FLAG_ABRF) || ((FLAG) == USART_FLAG_BUSY) || \
  316. ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_SBK) || \
  317. ((FLAG) == USART_FLAG_RWU) || ((FLAG) == USART_FLAG_WU) || \
  318. ((FLAG) == USART_FLAG_TEACK)|| ((FLAG) == USART_FLAG_REACK))
  319. #define IS_USART_CLEAR_FLAG(FLAG) (((FLAG) == USART_FLAG_WU) || ((FLAG) == USART_FLAG_TC) || \
  320. ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_ORE) || \
  321. ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \
  322. ((FLAG) == USART_FLAG_LBD) || ((FLAG) == USART_FLAG_CTS) || \
  323. ((FLAG) == USART_FLAG_RTO) || ((FLAG) == USART_FLAG_EOB) || \
  324. ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_PE))
  325. /**
  326. * @}
  327. */
  328. /** @defgroup USART_Interrupt_definition
  329. * @brief USART Interrupt definition
  330. * USART_IT possible values
  331. * Elements values convention: 0xZZZZYYXX
  332. * XX: Position of the corresponding Interrupt
  333. * YY: Register index
  334. * ZZZZ: Flag position
  335. * @{
  336. */
  337. #define USART_IT_WU ((uint32_t)0x00140316)
  338. #define USART_IT_CM ((uint32_t)0x0011010E)
  339. #define USART_IT_EOB ((uint32_t)0x000C011B)
  340. #define USART_IT_RTO ((uint32_t)0x000B011A)
  341. #define USART_IT_PE ((uint32_t)0x00000108)
  342. #define USART_IT_TXE ((uint32_t)0x00070107)
  343. #define USART_IT_TC ((uint32_t)0x00060106)
  344. #define USART_IT_RXNE ((uint32_t)0x00050105)
  345. #define USART_IT_IDLE ((uint32_t)0x00040104)
  346. #define USART_IT_LBD ((uint32_t)0x00080206)
  347. #define USART_IT_CTS ((uint32_t)0x0009030A)
  348. #define USART_IT_ERR ((uint32_t)0x00000300)
  349. #define USART_IT_ORE ((uint32_t)0x00030300)
  350. #define USART_IT_NE ((uint32_t)0x00020300)
  351. #define USART_IT_FE ((uint32_t)0x00010300)
  352. #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
  353. ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
  354. ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
  355. ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR) || \
  356. ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
  357. ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
  358. #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \
  359. ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \
  360. ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \
  361. ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \
  362. ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE) || \
  363. ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
  364. ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
  365. #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_PE) || \
  366. ((IT) == USART_IT_FE) || ((IT) == USART_IT_NE) || \
  367. ((IT) == USART_IT_ORE) || ((IT) == USART_IT_IDLE) || \
  368. ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS) || \
  369. ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \
  370. ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU))
  371. /**
  372. * @}
  373. */
  374. /** @defgroup USART_Global_definition
  375. * @{
  376. */
  377. #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x005B8D81))
  378. #define IS_USART_DE_ASSERTION_DEASSERTION_TIME(TIME) ((TIME) <= 0x1F)
  379. #define IS_USART_AUTO_RETRY_COUNTER(COUNTER) ((COUNTER) <= 0x7)
  380. #define IS_USART_TIMEOUT(TIMEOUT) ((TIMEOUT) <= 0x00FFFFFF)
  381. #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF)
  382. /**
  383. * @}
  384. */
  385. /**
  386. * @}
  387. */
  388. /* Exported macro ------------------------------------------------------------*/
  389. /* Exported functions ------------------------------------------------------- */
  390. /* Initialization and Configuration functions *********************************/
  391. void USART_DeInit(USART_TypeDef* USARTx);
  392. void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);
  393. void USART_StructInit(USART_InitTypeDef* USART_InitStruct);
  394. void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct);
  395. void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct);
  396. void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
  397. void USART_DirectionModeCmd(USART_TypeDef* USARTx, uint32_t USART_DirectionMode, FunctionalState NewState);
  398. void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState);
  399. void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  400. void USART_MSBFirstCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  401. void USART_DataInvCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  402. void USART_InvPinCmd(USART_TypeDef* USARTx, uint32_t USART_InvPin, FunctionalState NewState);
  403. void USART_SWAPPinCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  404. void USART_ReceiverTimeOutCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  405. void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut);
  406. /* AutoBaudRate functions *****************************************************/
  407. void USART_AutoBaudRateCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  408. void USART_AutoBaudRateConfig(USART_TypeDef* USARTx, uint32_t USART_AutoBaudRate);
  409. /* Data transfers functions ***************************************************/
  410. void USART_SendData(USART_TypeDef* USARTx, uint16_t Data);
  411. uint16_t USART_ReceiveData(USART_TypeDef* USARTx);
  412. /* Multi-Processor Communication functions ************************************/
  413. void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address);
  414. void USART_MuteModeWakeUpConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUp);
  415. void USART_MuteModeCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  416. void USART_AddressDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_AddressLength);
  417. /* Half-duplex mode function **************************************************/
  418. void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);
  419. /* RS485 mode functions *******************************************************/
  420. void USART_DECmd(USART_TypeDef* USARTx, FunctionalState NewState);
  421. void USART_DEPolarityConfig(USART_TypeDef* USARTx, uint32_t USART_DEPolarity);
  422. void USART_SetDEAssertionTime(USART_TypeDef* USARTx, uint32_t USART_DEAssertionTime);
  423. void USART_SetDEDeassertionTime(USART_TypeDef* USARTx, uint32_t USART_DEDeassertionTime);
  424. /* DMA transfers management functions *****************************************/
  425. void USART_DMACmd(USART_TypeDef* USARTx, uint32_t USART_DMAReq, FunctionalState NewState);
  426. void USART_DMAReceptionErrorConfig(USART_TypeDef* USARTx, uint32_t USART_DMAOnError);
  427. /* Interrupts and flags management functions **********************************/
  428. void USART_ITConfig(USART_TypeDef* USARTx, uint32_t USART_IT, FunctionalState NewState);
  429. void USART_RequestCmd(USART_TypeDef* USARTx, uint32_t USART_Request, FunctionalState NewState);
  430. void USART_OverrunDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_OVRDetection);
  431. FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint32_t USART_FLAG);
  432. void USART_ClearFlag(USART_TypeDef* USARTx, uint32_t USART_FLAG);
  433. ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint32_t USART_IT);
  434. void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint32_t USART_IT);
  435. #ifdef __cplusplus
  436. }
  437. #endif
  438. #endif /* __FT32F0XX_USART_H */
  439. /**
  440. * @}
  441. */
  442. /**
  443. * @}
  444. */
  445. /************************ (C) COPYRIGHT FMD *****END OF FILE****/