hpm_uart_drv.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * Copyright (c) 2021-2022 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_UART_DRV_H
  8. #define HPM_UART_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_uart_regs.h"
  11. #include "hpm_soc_feature.h"
  12. /**
  13. *
  14. * @brief UART driver APIs
  15. * @defgroup uart_interface UART driver APIs
  16. * @ingroup io_interfaces
  17. * @{
  18. */
  19. /**
  20. * @brief UART status
  21. */
  22. enum {
  23. status_uart_no_suitable_baudrate_parameter_found = MAKE_STATUS(status_group_uart, 1),
  24. };
  25. /* @brief Parity */
  26. typedef enum parity {
  27. parity_none = 0,
  28. parity_odd,
  29. parity_even,
  30. parity_always_1,
  31. parity_always_0,
  32. } parity_setting_t;
  33. /* @brief Stop bits */
  34. typedef enum num_of_stop_bits {
  35. stop_bits_1 = 0,
  36. stop_bits_1_5,
  37. stop_bits_2,
  38. } num_of_stop_bits_t;
  39. /* @brief Word length */
  40. typedef enum word_length {
  41. word_length_5_bits = 0,
  42. word_length_6_bits,
  43. word_length_7_bits,
  44. word_length_8_bits,
  45. } word_length_t;
  46. /* @brief UART fifo trigger levels */
  47. typedef enum uart_fifo_trg_lvl {
  48. uart_rx_fifo_trg_not_empty = 0,
  49. uart_rx_fifo_trg_gt_one_quarter = 1,
  50. uart_rx_fifo_trg_gt_half = 2,
  51. uart_rx_fifo_trg_gt_three_quarters = 3,
  52. uart_tx_fifo_trg_not_full = 0,
  53. uart_tx_fifo_trg_lt_three_quarters = 1,
  54. uart_tx_fifo_trg_lt_half = 2,
  55. uart_tx_fifo_trg_lt_one_quarter = 3,
  56. } uart_fifo_trg_lvl_t;
  57. #if defined(UART_SOC_HAS_NEW_FIFO_THR) && (UART_SOC_HAS_NEW_FIFO_THR == 1)
  58. /* @brief UART new fifo trigger levels */
  59. typedef enum uart_new_fifo_trg_lvl {
  60. uart_fifo_1_byte = 0,
  61. uart_fifo_2_bytes = 1,
  62. uart_fifo_3_bytes = 2,
  63. uart_fifo_4_bytes = 3,
  64. uart_fifo_5_bytes = 4,
  65. uart_fifo_6_bytes = 5,
  66. uart_fifo_7_bytes = 6,
  67. uart_fifo_8_bytes = 7,
  68. uart_fifo_9_bytes = 8,
  69. uart_fifo_10_bytes = 9,
  70. uart_fifo_11_bytes = 10,
  71. uart_fifo_12_bytes = 11,
  72. uart_fifo_13_bytes = 12,
  73. uart_fifo_14_bytes = 13,
  74. uart_fifo_15_bytes = 14,
  75. uart_fifo_16_bytes = 15,
  76. } uart_new_fifo_trg_lvl_t;
  77. #endif
  78. /* @brief UART signals */
  79. typedef enum uart_signal {
  80. uart_signal_rts = UART_MCR_RTS_MASK,
  81. } uart_signal_t;
  82. /* @brief UART signal levels */
  83. typedef enum uart_signal_level {
  84. uart_signal_level_high,
  85. uart_signal_level_low,
  86. } uart_signal_level_t;
  87. /* @brief UART modem status */
  88. typedef enum uart_modem_stat {
  89. uart_modem_stat_cts = UART_MSR_CTS_MASK,
  90. uart_modem_stat_dcts_changed = UART_MSR_DCTS_MASK,
  91. } uart_modem_stat_t;
  92. /* @brief UART interrupt enable masks */
  93. typedef enum uart_intr_enable {
  94. uart_intr_rx_data_avail_or_timeout = UART_IER_ERBI_MASK,
  95. uart_intr_tx_slot_avail = UART_IER_ETHEI_MASK,
  96. uart_intr_rx_line_stat = UART_IER_ELSI_MASK,
  97. uart_intr_modem_stat = UART_IER_EMSI_MASK,
  98. #if defined(UART_SOC_HAS_RXLINE_IDLE_DETECTION) && (UART_SOC_HAS_RXLINE_IDLE_DETECTION == 1)
  99. uart_intr_rx_line_idle = UART_IER_ERXIDLE_MASK,
  100. #endif
  101. } uart_intr_enable_t;
  102. /* @brief UART interrupt IDs */
  103. typedef enum uart_intr_id {
  104. uart_intr_id_modem_stat = 0x0,
  105. uart_intr_id_tx_slot_avail = 0x2,
  106. uart_intr_id_rx_data_avail = 0x4,
  107. uart_intr_id_rx_line_stat = 0x6,
  108. uart_intr_id_rx_timeout = 0xc,
  109. } uart_intr_id_t;
  110. /* @brief UART status */
  111. typedef enum uart_stat {
  112. uart_stat_data_ready = UART_LSR_DR_MASK, /* rx data ready in fifo */
  113. uart_stat_overrun_error = UART_LSR_OE_MASK,
  114. uart_stat_parity_error = UART_LSR_PE_MASK,
  115. uart_stat_framing_error = UART_LSR_FE_MASK,
  116. uart_stat_line_break = UART_LSR_LBREAK_MASK,
  117. uart_stat_tx_slot_avail = UART_LSR_THRE_MASK,
  118. uart_stat_transmitter_empty = UART_LSR_TEMT_MASK,
  119. uart_stat_rx_fifo_error = UART_LSR_ERRF_MASK,
  120. } uart_stat_t;
  121. /**
  122. * @brief UART modem config
  123. */
  124. typedef struct uart_modem_config {
  125. bool auto_flow_ctrl_en; /**< Auto flow control enable flag */
  126. bool loop_back_en; /**< Loop back enable flag */
  127. bool set_rts_high; /**< Set signal RTS level high flag */
  128. } uart_modem_config_t;
  129. #if defined(UART_SOC_HAS_RXLINE_IDLE_DETECTION) && (UART_SOC_HAS_RXLINE_IDLE_DETECTION == 1)
  130. /**
  131. * @brief UART RX Line Idle detection conditions
  132. */
  133. typedef enum hpm_uart_rxline_idle_cond {
  134. uart_rxline_idle_cond_rxline_logic_one = 0, /**< Treat as idle if the RX Line high duration exceeds threshold */
  135. uart_rxline_idle_cond_state_machine_idle = 1 /**< Treat as idle if the RX state machine idle state duration exceeds threshold */
  136. } uart_rxline_idle_cond_t;
  137. typedef struct hpm_uart_rxline_idle_detect_config {
  138. bool detect_enable; /**< RX Line Idle detection flag */
  139. bool detect_irq_enable; /**< Enable RX Line Idle detection interrupt */
  140. uart_rxline_idle_cond_t idle_cond; /**< RX Line Idle detection condition */
  141. uint8_t threshold; /**< UART RX Line Idle detection threshold, in terms of bits */
  142. } uart_rxline_idle_config_t;
  143. #endif
  144. /**
  145. * @brief UART config
  146. */
  147. typedef struct hpm_uart_config {
  148. uint32_t src_freq_in_hz; /**< Source clock frequency in Hz */
  149. uint32_t baudrate; /**< Baudrate */
  150. uint8_t num_of_stop_bits; /**< Number of stop bits */
  151. uint8_t word_length; /**< Word length */
  152. uint8_t parity; /**< Parity */
  153. uint8_t tx_fifo_level; /**< TX Fifo level */
  154. uint8_t rx_fifo_level; /**< RX Fifo level */
  155. #if defined(UART_SOC_HAS_NEW_FIFO_THR) && (UART_SOC_HAS_NEW_FIFO_THR == 1)
  156. bool using_new_fifo_thr;
  157. #endif
  158. bool dma_enable; /**< DMA Enable flag */
  159. bool fifo_enable; /**< Fifo Enable flag */
  160. uart_modem_config_t modem_config; /**< Modem config */
  161. #if defined(UART_SOC_HAS_RXLINE_IDLE_DETECTION) && (UART_SOC_HAS_RXLINE_IDLE_DETECTION == 1)
  162. uart_rxline_idle_config_t rxidle_config; /**< RX Idle configuration */
  163. #endif
  164. #if defined(UART_SOC_HAS_RXEN_CFG) && (UART_SOC_HAS_RXEN_CFG == 1)
  165. bool rx_enable; /**< RX Enable configuration */
  166. #endif
  167. } uart_config_t;
  168. #if defined(UART_SOC_HAS_NEW_FIFO_THR) && (UART_SOC_HAS_NEW_FIFO_THR == 1)
  169. typedef struct {
  170. uint16_t stop_bit_len;
  171. bool en_stop_bit_insert;
  172. bool hardware_trig;
  173. bool trig_mode;
  174. bool trig_clr_rxfifo;
  175. } uart_trig_config_t;
  176. #endif
  177. typedef struct {
  178. uint8_t tx_fifo_level; /**< TX Fifo level */
  179. uint8_t rx_fifo_level; /**< RX Fifo level */
  180. bool reset_tx_fifo; /**< reset tx Fifo */
  181. bool reset_rx_fifo; /**< reset rx Fifo */
  182. bool dma_enable; /**< DMA Enable flag */
  183. bool fifo_enable; /**< Fifo Enable flag */
  184. } uart_fifo_ctrl_t;
  185. #ifdef __cplusplus
  186. extern "C" {
  187. #endif
  188. /**
  189. * @brief Get fifo size
  190. *
  191. * @param [in] ptr UART base address
  192. * @retval size of Fifo
  193. */
  194. static inline uint8_t uart_get_fifo_size(UART_Type *ptr)
  195. {
  196. return 16 << ((ptr->CFG & UART_CFG_FIFOSIZE_MASK) >> UART_CFG_FIFOSIZE_SHIFT);
  197. }
  198. /**
  199. * @brief uart config fifo control
  200. *
  201. * @note fifo control register is WO access, prepare all bitfiled value to write
  202. *
  203. * @param [in] ptr UART base address
  204. * @param [in] ctrl uart_fifo_ctrl_t
  205. */
  206. void uart_config_fifo_ctrl(UART_Type *ptr, uart_fifo_ctrl_t *ctrl);
  207. /**
  208. * @brief uart clear rx fifo by reading data
  209. *
  210. * @note read out all data in rx fifo, the uart_intr_rx_data_avail_or_timeout is cleared
  211. * when RBR register is read
  212. *
  213. * @param [in] ptr UART base address
  214. */
  215. static inline void uart_clear_rx_fifo(UART_Type *ptr)
  216. {
  217. while (ptr->LSR & UART_LSR_DR_MASK) {
  218. ptr->RBR;
  219. }
  220. }
  221. /**
  222. * @brief Reset TX Fifo
  223. *
  224. * @note this API may modify other bit fields in FIFO control register
  225. *
  226. * @param [in] ptr UART base address
  227. */
  228. static inline void uart_reset_tx_fifo(UART_Type *ptr)
  229. {
  230. ptr->FCR = UART_FCR_TFIFORST_MASK;
  231. }
  232. /**
  233. * @brief Reset RX Fifo
  234. *
  235. * @note this API may modify other bit fields in FIFO control register
  236. *
  237. * @param [in] ptr UART base address
  238. */
  239. static inline void uart_reset_rx_fifo(UART_Type *ptr)
  240. {
  241. ptr->FCR = UART_FCR_RFIFORST_MASK;
  242. }
  243. /**
  244. * @brief [in] Reset both TX and RX Fifo
  245. *
  246. * @note this API may modify other bit fields in FIFO control register
  247. *
  248. * @param [in] ptr UART base address
  249. */
  250. static inline void uart_reset_all_fifo(UART_Type *ptr)
  251. {
  252. ptr->FCR = UART_FCR_RFIFORST_MASK | UART_FCR_TFIFORST_MASK;
  253. }
  254. /**
  255. * @brief Enable modem loopback
  256. *
  257. * @param [in] ptr UART base address
  258. */
  259. static inline void uart_modem_enable_loopback(UART_Type *ptr)
  260. {
  261. ptr->MCR |= UART_MCR_LOOP_MASK;
  262. }
  263. /**
  264. * @brief Disable modem loopback
  265. *
  266. * @param [in] ptr UART base address
  267. */
  268. static inline void uart_modem_disable_loopback(UART_Type *ptr)
  269. {
  270. ptr->MCR &= ~UART_MCR_LOOP_MASK;
  271. }
  272. /**
  273. * @brief Disable modem auto flow control
  274. *
  275. * @param [in] ptr UART base address
  276. */
  277. static inline void uart_modem_disable_auto_flow_control(UART_Type *ptr)
  278. {
  279. ptr->MCR &= ~UART_MCR_AFE_MASK;
  280. }
  281. /**
  282. * @brief Enable modem auto flow control
  283. *
  284. * @param [in] ptr UART base address
  285. */
  286. static inline void uart_modem_enable_auto_flow_control(UART_Type *ptr)
  287. {
  288. ptr->MCR |= UART_MCR_AFE_MASK;
  289. }
  290. /**
  291. * @brief Configure modem
  292. *
  293. * @param [in] ptr UART base address
  294. * @param config Pointer to modem config struct
  295. */
  296. static inline void uart_modem_config(UART_Type *ptr, uart_modem_config_t *config)
  297. {
  298. ptr->MCR = UART_MCR_AFE_SET(config->auto_flow_ctrl_en)
  299. | UART_MCR_LOOP_SET(config->loop_back_en)
  300. | UART_MCR_RTS_SET(!config->set_rts_high);
  301. }
  302. /**
  303. * @brief Get modem status
  304. *
  305. * @param [in] ptr UART base address
  306. * @retval Current modem status
  307. */
  308. static inline uint8_t uart_get_modem_status(UART_Type *ptr)
  309. {
  310. return ptr->MSR;
  311. }
  312. /**
  313. * @brief Write byte to TX
  314. *
  315. * @param ptr UART base address
  316. * @param c data to be sent
  317. */
  318. static inline void uart_write_byte(UART_Type *ptr, uint8_t c)
  319. {
  320. ptr->THR = UART_THR_THR_SET(c);
  321. }
  322. /**
  323. * @brief Read byte from RX
  324. *
  325. * @param ptr UART base address
  326. * @retval RX byte
  327. */
  328. static inline uint8_t uart_read_byte(UART_Type *ptr)
  329. {
  330. return (ptr->RBR & UART_RBR_RBR_MASK);
  331. }
  332. /**
  333. * @brief Check modem status with given mask
  334. *
  335. * @param [in] ptr UART base address
  336. * @param mask Status mask value to be checked against
  337. * @retval true if any bit in given mask is set
  338. * @retval false if none of any bit in given mask is set
  339. */
  340. static inline bool uart_check_modem_status(UART_Type *ptr, uart_modem_stat_t mask)
  341. {
  342. return ((ptr->MSR & mask) != 0U) ? true : false;
  343. }
  344. /**
  345. * @brief Disable IRQ with mask
  346. *
  347. * @param [in] ptr UART base address
  348. * @param irq_mask IRQ mask value to be disabled
  349. */
  350. static inline void uart_disable_irq(UART_Type *ptr, uart_intr_enable_t irq_mask)
  351. {
  352. ptr->IER &= ~irq_mask;
  353. }
  354. /**
  355. * @brief Enable IRQ with mask
  356. *
  357. * @param [in] ptr UART base address
  358. * @param irq_mask IRQ mask value to be enabled
  359. */
  360. static inline void uart_enable_irq(UART_Type *ptr, uart_intr_enable_t irq_mask)
  361. {
  362. ptr->IER |= irq_mask;
  363. }
  364. /**
  365. * @brief Get Enabled IRQ
  366. *
  367. * @param [in] ptr UART base address
  368. * @return enabled irq
  369. */
  370. static inline uint32_t uart_get_enabled_irq(UART_Type *ptr)
  371. {
  372. return ptr->IER;
  373. }
  374. /**
  375. * @brief Get interrupt identification
  376. *
  377. * @param [in] ptr UART base address
  378. * @retval interrupt id
  379. */
  380. static inline uint8_t uart_get_irq_id(UART_Type *ptr)
  381. {
  382. return (ptr->IIR & UART_IIR_INTRID_MASK);
  383. }
  384. #if defined(UART_SOC_HAS_RXLINE_IDLE_DETECTION) && (UART_SOC_HAS_RXLINE_IDLE_DETECTION == 1)
  385. /**
  386. * @brief Determine whether UART RX Line is idle
  387. * @param [in] ptr UART base address
  388. */
  389. static inline bool uart_is_rxline_idle(UART_Type *ptr)
  390. {
  391. return ((ptr->IIR & UART_IIR_RXIDLE_FLAG_MASK) != 0U) ? true : false;
  392. }
  393. /**
  394. * @brief Clear UART RX Line Idle Flag
  395. * @param [in] ptr UART base address
  396. */
  397. static inline void uart_clear_rxline_idle_flag(UART_Type *ptr)
  398. {
  399. ptr->IIR = UART_IIR_RXIDLE_FLAG_MASK; /* Write-1-Clear Logic */
  400. }
  401. /**
  402. * @brief Enable UART RX Idle Line detection logic
  403. * @param [in] ptr UART base address
  404. */
  405. static inline void uart_enable_rxline_idle_detection(UART_Type *ptr)
  406. {
  407. ptr->IDLE_CFG |= UART_IDLE_CFG_RX_IDLE_EN_MASK;
  408. }
  409. /**
  410. * @brief Disable UART RX Idle Line detection logic
  411. *
  412. * @param [in] ptr UART base address
  413. */
  414. static inline void uart_disable_rxline_idle_detection(UART_Type *ptr)
  415. {
  416. ptr->IDLE_CFG &= ~UART_IDLE_CFG_RX_IDLE_EN_MASK;
  417. }
  418. /**
  419. * @brief Configure UART RX Line detection
  420. * @param [in] ptr UART base address
  421. * @param [in] rxidle_config RXLine IDLE detection configuration
  422. * @retval status_success if no error occurs
  423. */
  424. hpm_stat_t uart_init_rxline_idle_detection(UART_Type *ptr, uart_rxline_idle_config_t rxidle_config);
  425. #endif
  426. /**
  427. * @brief Get status
  428. *
  429. * @param [in] ptr UART base address
  430. * @retval current status
  431. */
  432. static inline uint8_t uart_get_status(UART_Type *ptr)
  433. {
  434. return ptr->LSR;
  435. }
  436. /**
  437. * @brief Check uart status according to the given status mask
  438. *
  439. * @param [in] ptr UART base address
  440. * @param mask Status mask value to be checked against
  441. * @retval true if any bit in given mask is set
  442. * @retval false if none of any bit in given mask is set
  443. */
  444. static inline bool uart_check_status(UART_Type *ptr, uart_stat_t mask)
  445. {
  446. return ((ptr->LSR & mask) != 0U) ? true : false;
  447. }
  448. /**
  449. * @brief Get default config
  450. *
  451. * @param [in] ptr UART base address
  452. * @param config Pointer to the buffer to save default values
  453. */
  454. void uart_default_config(UART_Type *ptr, uart_config_t *config);
  455. /**
  456. * @brief Initialization
  457. *
  458. * @param [in] ptr UART base address
  459. * @param config Pointer to config struct
  460. * @retval status_success only if it succeeds
  461. */
  462. hpm_stat_t uart_init(UART_Type *ptr, uart_config_t *config);
  463. /**
  464. * @brief Send one byte after checking thresh hold status
  465. *
  466. * @param [in] ptr UART base address
  467. * @param c Byte to be sent
  468. * @retval status_success only if it succeeds
  469. */
  470. hpm_stat_t uart_send_byte(UART_Type *ptr, uint8_t c);
  471. /**
  472. * @brief Receive one byte after checking data ready status
  473. *
  474. * @param [in] ptr UART base address
  475. * @param c Pointer to buffer to save the byte received on UART
  476. * @retval status_success only if it succeeds
  477. */
  478. hpm_stat_t uart_receive_byte(UART_Type *ptr, uint8_t *c);
  479. /**
  480. * @brief Set uart signal output level
  481. *
  482. * @param [in] ptr UART base address
  483. * @param signal Target signal
  484. * @param level Target signal level
  485. */
  486. void uart_set_signal_level(UART_Type *ptr,
  487. uart_signal_t signal,
  488. uart_signal_level_t level);
  489. /**
  490. * @brief Flush sending buffer/fifo
  491. *
  492. * @param [in] ptr UART base address
  493. * @retval status_success only if it succeeds
  494. */
  495. hpm_stat_t uart_flush(UART_Type *ptr);
  496. /**
  497. * @brief Receive bytes blocking
  498. *
  499. * @param [in] ptr UART base address
  500. * @param buf Pointer to the buffer to save received data
  501. * @param size_in_byte Size in byte to be sent
  502. * @retval status_success only if it succeeds
  503. */
  504. hpm_stat_t uart_receive_data(UART_Type *ptr, uint8_t *buf, uint32_t size_in_byte);
  505. /**
  506. * @brief Send bytes blocking
  507. *
  508. * @param [in] ptr UART base address
  509. * @param buf Pointer to the buffer to be sent
  510. * @param size_in_byte Size in byte to be sent
  511. * @retval status_success only if it succeeds
  512. */
  513. hpm_stat_t uart_send_data(UART_Type *ptr, uint8_t *buf, uint32_t size_in_byte);
  514. /**
  515. * @brief Sets UART baudrate.
  516. *
  517. * This function configures the UART module baud rate. This function is used to update
  518. * the UART module baud rate after the UART module is initialized by the uart_init.
  519. *
  520. * @param ptr UART base address
  521. * @param baudrate UART baudrate to be set
  522. * @param src_clock_hz UART clock source frequency in Hz.
  523. * @retval status_uart_no_suitable_baudrate_parameter_found Baudrate is not supported in the current clock source
  524. * @retval status_success Set baudrate succeeded.
  525. */
  526. hpm_stat_t uart_set_baudrate(UART_Type *ptr, uint32_t baudrate, uint32_t src_clock_hz);
  527. #if defined(UART_SOC_HAS_NEW_FIFO_THR) && (UART_SOC_HAS_NEW_FIFO_THR == 1)
  528. /**
  529. * @brief Config uart trigger mode for communication
  530. *
  531. * This function is used to tomagawa communication, uart sent out data in fifo then generate interrupt after
  532. * received specify count of data into fifo.
  533. *
  534. * @param ptr UART base address
  535. * @param uart_trig_config_t config
  536. */
  537. void uart_config_trig_mode(UART_Type *ptr, uart_trig_config_t *config);
  538. /**
  539. * @brief uart trigger communication
  540. *
  541. * This function triggers uart communication, the communication configed by uart_config_trig_mode()
  542. *
  543. * @param ptr UART base address
  544. */
  545. static inline void uart_trigger_communication(UART_Type *ptr)
  546. {
  547. ptr->MOTO_CFG &= ~UART_MOTO_CFG_HWTRG_EN_MASK;
  548. ptr->MOTO_CFG |= UART_MOTO_CFG_SWTRG_MASK;
  549. }
  550. /**
  551. * @brief uart enable hardware trigger mode
  552. *
  553. * This function configures uart start communication by hardware trigger from motor periphrals
  554. *
  555. * @param ptr UART base address
  556. * @param bool enable
  557. */
  558. static inline void uart_enable_hardware_trigger_mode(UART_Type *ptr, bool enable)
  559. {
  560. if (enable) {
  561. ptr->MOTO_CFG |= UART_MOTO_CFG_HWTRG_EN_MASK;
  562. } else {
  563. ptr->MOTO_CFG &= ~UART_MOTO_CFG_HWTRG_EN_MASK;
  564. }
  565. }
  566. #endif
  567. #ifdef __cplusplus
  568. }
  569. #endif
  570. /**
  571. * @}
  572. */
  573. #endif /* HPM_UART_DRV_H */