wm_uart.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. /**
  2. * @file wm_uart.c
  3. *
  4. * @brief uart Driver Module
  5. *
  6. * @author dave
  7. *
  8. * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #include <string.h>
  11. #include "wm_regs.h"
  12. #include "wm_uart.h"
  13. #include "wm_debug.h"
  14. #include "wm_irq.h"
  15. #include "wm_config.h"
  16. #include "wm_mem.h"
  17. #include "wm_dma.h"
  18. #include "wm_cpu.h"
  19. #if TLS_CONFIG_UART
  20. #define RX_CACHE_LIMIT 128
  21. #define STEP_SIZE (HR_UART1_BASE_ADDR - HR_UART0_BASE_ADDR)
  22. extern void tls_irq_priority(u8 vec_no, u32 prio);
  23. void tls_uart_tx_callback_register(u16 uart_no, s16(*tx_callback) (struct tls_uart_port *port));
  24. const u32 baud_rates[] = { 2000000, 1500000, 1250000, 1000000, 921600, 460800,
  25. 230400, 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 1200, 600 };
  26. struct tls_uart_port uart_port[TLS_UART_MAX];
  27. static u8 uart_rx_byte_cb_flag[TLS_UART_MAX] = {0};
  28. static void tls_uart_tx_enable(struct tls_uart_port *port)
  29. {
  30. u32 ucon;
  31. ucon = port->regs->UR_LC;
  32. ucon |= ULCON_TX_EN;
  33. port->regs->UR_LC = ucon;
  34. }
  35. /**
  36. * @brief This function is used to continue transfer data.
  37. * @param[in] port: is the uart port.
  38. * @retval
  39. */
  40. static void tls_uart_tx_chars(struct tls_uart_port *port)
  41. {
  42. struct dl_list *pending_list = &port->tx_msg_pending_list;
  43. tls_uart_tx_msg_t *tx_msg = NULL;
  44. int tx_count;
  45. u32 cpu_sr;
  46. /* send some chars */
  47. tx_count = 32;
  48. cpu_sr = tls_os_set_critical();
  49. if (!dl_list_empty(pending_list))
  50. {
  51. tx_msg = dl_list_first(pending_list, tls_uart_tx_msg_t, list);
  52. while (tx_count-- > 0 && tx_msg->offset < tx_msg->buflen)
  53. {
  54. /* ���tx fifo�Ƿ����� */
  55. if ((port->regs->UR_FIFOS & UFS_TX_FIFO_CNT_MASK) == port->tx_fifofull)
  56. {
  57. break;
  58. }
  59. port->regs->UR_TXW = tx_msg->buf[tx_msg->offset];
  60. tx_msg->offset++;
  61. port->icount.tx++;
  62. }
  63. if (tx_msg->offset >= tx_msg->buflen)
  64. {
  65. dl_list_del(&tx_msg->list);
  66. dl_list_add_tail(&port->tx_msg_to_be_freed_list, &tx_msg->list);
  67. tls_os_release_critical(cpu_sr);
  68. if (port->tx_sent_callback)
  69. port->tx_sent_callback(port);
  70. if (port->tx_callback)
  71. port->tx_callback(port);
  72. }else{
  73. tls_os_release_critical(cpu_sr);
  74. }
  75. }
  76. else{
  77. tls_os_release_critical(cpu_sr);
  78. }
  79. }
  80. static void UartRegInit(int uart_no)
  81. {
  82. u32 bd;
  83. u32 apbclk;
  84. tls_sys_clk sysclk;
  85. tls_sys_clk_get(&sysclk);
  86. apbclk = sysclk.apbclk * 1000000;
  87. if (TLS_UART_0 == uart_no)
  88. {
  89. bd = (apbclk / (16 * 115200) - 1) | (((apbclk % (115200 * 16)) * 16 / (115200 * 16)) << 16);
  90. tls_reg_write32(HR_UART0_BAUD_RATE_CTRL, bd);
  91. /* Line control register : Normal,No parity,1 stop,8 bits, only use tx */
  92. tls_reg_write32(HR_UART0_LINE_CTRL, ULCON_WL8 | ULCON_TX_EN);
  93. /* disable auto flow control */
  94. tls_reg_write32(HR_UART0_FLOW_CTRL, 0);
  95. /* disable dma */
  96. tls_reg_write32(HR_UART0_DMA_CTRL, 0);
  97. /* one byte tx */
  98. tls_reg_write32(HR_UART0_FIFO_CTRL, 0);
  99. /* disable interrupt */
  100. tls_reg_write32(HR_UART0_INT_MASK, 0xFF);
  101. }
  102. else
  103. {
  104. /* 4 byte tx, 8 bytes rx */
  105. tls_reg_write32(HR_UART0_FIFO_CTRL + uart_no*STEP_SIZE, (0x01 << 2) | (0x02 << 4));
  106. /* enable rx timeout, disable rx dma, disable tx dma */
  107. tls_reg_write32(HR_UART0_DMA_CTRL + uart_no*STEP_SIZE, (8 << 3) | (1 << 2));
  108. /* enable rx/timeout interrupt */
  109. tls_reg_write32(HR_UART0_INT_MASK + uart_no*STEP_SIZE, ~(3 << 2));
  110. }
  111. }
  112. int tls_uart_check_baudrate(u32 baudrate)
  113. {
  114. int i;
  115. for (i = 0; i < sizeof(baud_rates) / sizeof(u32); i++)
  116. {
  117. if (baudrate == baud_rates[i])
  118. return 1;
  119. }
  120. /* not found match baudrate */
  121. return -1;
  122. }
  123. u32 tls_uart_get_baud_rate(struct tls_uart_port * port)
  124. {
  125. if ((port != NULL) && (port->regs != NULL))
  126. return port->opts.baudrate;
  127. else
  128. return 0;
  129. }
  130. static int tls_uart_set_baud_rate_inside(struct tls_uart_port *port, u32 baudrate)
  131. {
  132. int index;
  133. u32 value;
  134. u32 apbclk;
  135. tls_sys_clk sysclk;
  136. index = tls_uart_check_baudrate(baudrate);
  137. if (index < 0)
  138. {
  139. return WM_FAILED;
  140. }
  141. tls_sys_clk_get(&sysclk);
  142. apbclk = sysclk.apbclk * 1000000;
  143. value = (apbclk / (16 * baudrate) - 1) |
  144. (((apbclk % (baudrate * 16)) * 16 / (baudrate * 16)) << 16);
  145. port->regs->UR_BD = value;
  146. port->opts.baudrate = baudrate;
  147. return WM_SUCCESS;
  148. }
  149. static int tls_uart_set_parity_inside(struct tls_uart_port *port, TLS_UART_PMODE_T paritytype)
  150. {
  151. if (port == NULL)
  152. return WM_FAILED;
  153. port->opts.paritytype = paritytype;
  154. if (paritytype == TLS_UART_PMODE_DISABLED)
  155. port->regs->UR_LC &= ~ULCON_PMD_EN;
  156. else if (paritytype == TLS_UART_PMODE_EVEN)
  157. {
  158. port->regs->UR_LC &= ~ULCON_PMD_MASK;
  159. port->regs->UR_LC |= ULCON_PMD_EVEN;
  160. }
  161. else if (paritytype == TLS_UART_PMODE_ODD)
  162. {
  163. port->regs->UR_LC &= ~ULCON_PMD_MASK;
  164. port->regs->UR_LC |= ULCON_PMD_ODD;
  165. }
  166. else
  167. return WM_FAILED;
  168. return WM_SUCCESS;
  169. }
  170. #if 0
  171. static TLS_UART_PMODE_T tls_uart_get_parity(struct tls_uart_port * port)
  172. {
  173. return port->opts.paritytype;
  174. }
  175. #endif
  176. static int tls_uart_set_data_bits(struct tls_uart_port *port, TLS_UART_CHSIZE_T charlength)
  177. {
  178. if (!port)
  179. return WM_FAILED;
  180. port->opts.charlength = charlength;
  181. port->regs->UR_LC &= ~ULCON_WL_MASK;
  182. if (charlength == TLS_UART_CHSIZE_5BIT)
  183. port->regs->UR_LC |= ULCON_WL5;
  184. else if (charlength == TLS_UART_CHSIZE_6BIT)
  185. port->regs->UR_LC |= ULCON_WL6;
  186. else if (charlength == TLS_UART_CHSIZE_7BIT)
  187. port->regs->UR_LC |= ULCON_WL7;
  188. else if (charlength == TLS_UART_CHSIZE_8BIT)
  189. port->regs->UR_LC |= ULCON_WL8;
  190. else
  191. return WM_FAILED;
  192. return WM_SUCCESS;
  193. }
  194. #if 0
  195. static TLS_UART_CHSIZE_T tls_uart_get_data_bits(struct tls_uart_port * port)
  196. {
  197. return port->opts.charlength;
  198. }
  199. #endif
  200. static int tls_uart_set_stop_bits_inside(struct tls_uart_port *port, TLS_UART_STOPBITS_T stopbits)
  201. {
  202. if (!port)
  203. return WM_FAILED;
  204. port->opts.stopbits = stopbits;
  205. if (stopbits == TLS_UART_TWO_STOPBITS)
  206. port->regs->UR_LC |= ULCON_STOP_2;
  207. else
  208. port->regs->UR_LC &= ~ULCON_STOP_2;
  209. return WM_SUCCESS;
  210. }
  211. #if 0
  212. static TLS_UART_STOPBITS_T tls_uart_get_stop_bits(struct tls_uart_port * port)
  213. {
  214. return port->opts.stopbits;
  215. }
  216. #endif
  217. static TLS_UART_STATUS_T tls_uart_set_flow_ctrl(struct tls_uart_port * port, TLS_UART_FLOW_CTRL_MODE_T flow_ctrl)
  218. {
  219. TLS_UART_STATUS_T status = TLS_UART_STATUS_OK;
  220. if (!port)
  221. return TLS_UART_STATUS_ERROR;
  222. // port->opts.flow_ctrl = flow_ctrl;
  223. // //�����������޸ģ�Ϊ�����͸����ATָ��������Լ��޸�flowctrl���ã����Dz������ǹ̶������
  224. //printf("\nport %d flow ctrl==%d\n",port->uart_no,flow_ctrl);
  225. switch (flow_ctrl)
  226. {
  227. case TLS_UART_FLOW_CTRL_NONE:
  228. port->regs->UR_FC = 0;
  229. break;
  230. case TLS_UART_FLOW_CTRL_HARDWARE:
  231. if (TLS_UART_FLOW_CTRL_HARDWARE == port->opts.flow_ctrl)
  232. {
  233. port->regs->UR_FC = (1UL << 0) | (6UL << 2);
  234. }
  235. break;
  236. default:
  237. return TLS_UART_STATUS_ERROR;
  238. }
  239. return status;
  240. }
  241. void tls_uart_set_fc_status(int uart_no, TLS_UART_FLOW_CTRL_MODE_T status)
  242. {
  243. struct tls_uart_port *port;
  244. port = &uart_port[uart_no];
  245. port->fcStatus = status;
  246. tls_uart_set_flow_ctrl(port, status);
  247. if (TLS_UART_FLOW_CTRL_HARDWARE == port->opts.flow_ctrl && 0 == status && port->hw_stopped) // ׼���ر�����ʱ������tx�Ѿ�ֹͣ����Ҫ�ٴ�tx
  248. {
  249. tls_uart_tx_enable(port);
  250. tls_uart_tx_chars(port);
  251. port->hw_stopped = 0;
  252. }
  253. }
  254. void tls_uart_rx_disable(struct tls_uart_port *port)
  255. {
  256. u32 ucon;
  257. ucon = port->regs->UR_LC;
  258. ucon &= ~ULCON_RX_EN;
  259. port->regs->UR_LC = ucon;
  260. }
  261. void tls_uart_rx_enable(struct tls_uart_port *port)
  262. {
  263. port->regs->UR_LC |= ULCON_RX_EN;
  264. }
  265. static void tls_uart_tx_disable(struct tls_uart_port *port)
  266. {
  267. u32 ucon;
  268. ucon = port->regs->UR_LC;
  269. ucon &= ~ULCON_TX_EN;
  270. port->regs->UR_LC = ucon;
  271. }
  272. static int tls_uart_config(struct tls_uart_port *port, struct tls_uart_options *opts)
  273. {
  274. if (NULL == port || NULL == opts)
  275. return WM_FAILED;
  276. tls_uart_set_baud_rate_inside(port, opts->baudrate);
  277. tls_uart_set_parity_inside(port, opts->paritytype);
  278. tls_uart_set_data_bits(port, opts->charlength);
  279. tls_uart_set_stop_bits_inside(port, opts->stopbits);
  280. port->opts.flow_ctrl = opts->flow_ctrl;
  281. tls_uart_set_flow_ctrl(port, opts->flow_ctrl);
  282. {
  283. /* clear interrupt */
  284. port->regs->UR_INTS = 0xFFFFFFFF;
  285. /* enable interupt */
  286. port->regs->UR_INTM = 0x0;
  287. port->regs->UR_DMAC = (4UL << UDMA_RX_FIFO_TIMEOUT_SHIFT) | UDMA_RX_FIFO_TIMEOUT;
  288. }
  289. /* config FIFO control */
  290. port->regs->UR_FIFOC = UFC_TX_FIFO_LVL_16_BYTE | UFC_RX_FIFO_LVL_16_BYTE |
  291. UFC_TX_FIFO_RESET | UFC_RX_FIFO_RESET;
  292. port->regs->UR_LC &= ~(ULCON_TX_EN | ULCON_RX_EN);
  293. port->regs->UR_LC |= ULCON_RX_EN | ULCON_TX_EN;
  294. return WM_SUCCESS;
  295. }
  296. /**
  297. * @brief handle a change of clear-to-send state
  298. * @param[in] port: uart_port structure for the open port
  299. * @param[in] status: new clear to send status, nonzero if active
  300. */
  301. static void uart_handle_cts_change(struct tls_uart_port *port, unsigned int status)
  302. {
  303. if (((1 == port->fcStatus)
  304. && (port->opts.flow_ctrl == TLS_UART_FLOW_CTRL_HARDWARE))
  305. && (port->uart_no == TLS_UART_1))
  306. {
  307. if (port->hw_stopped)
  308. {
  309. if (status)
  310. {
  311. port->hw_stopped = 0;
  312. tls_uart_tx_enable(port);
  313. tls_uart_tx_chars(port);
  314. }
  315. }
  316. else
  317. {
  318. if (!status)
  319. {
  320. port->hw_stopped = 1;
  321. tls_uart_tx_disable(port);
  322. }
  323. }
  324. }
  325. }
  326. static void uart_tx_finish_callback(void *arg)
  327. {
  328. if (arg)
  329. {
  330. tls_mem_free(arg);
  331. }
  332. }
  333. int tls_uart_tx_remain_len(struct tls_uart_port *port)
  334. {
  335. tls_uart_tx_msg_t *tx_msg = NULL;
  336. u16 buf_len = 0;
  337. u32 cpu_sr;
  338. cpu_sr = tls_os_set_critical();
  339. dl_list_for_each(tx_msg, &port->tx_msg_pending_list, tls_uart_tx_msg_t, list)
  340. {
  341. buf_len += tx_msg->buflen;
  342. }
  343. tls_os_release_critical(cpu_sr);
  344. return TLS_UART_TX_BUF_SIZE - buf_len;
  345. }
  346. /**
  347. * @brief This function is used to fill tx buffer.
  348. * @param[in] port: is the uart port.
  349. * @param[in] buf: is the user buffer.
  350. * @param[in] count: is the user data length
  351. * @retval
  352. */
  353. int tls_uart_fill_buf(struct tls_uart_port *port, char *buf, u32 count)
  354. {
  355. tls_uart_tx_msg_t *uart_tx_msg;
  356. int ret = 0;
  357. u32 cpu_sr;
  358. uart_tx_msg = tls_mem_alloc(sizeof(tls_uart_tx_msg_t));
  359. if (uart_tx_msg == NULL)
  360. {
  361. TLS_DBGPRT_ERR("mem err\n");
  362. return -1;
  363. }
  364. dl_list_init(&uart_tx_msg->list);
  365. uart_tx_msg->buf = tls_mem_alloc(count);
  366. if (uart_tx_msg->buf == NULL)
  367. {
  368. tls_mem_free(uart_tx_msg);
  369. TLS_DBGPRT_ERR("mem err 1 count=%d\n", count);
  370. return -1;
  371. }
  372. memcpy(uart_tx_msg->buf, buf, count);
  373. uart_tx_msg->buflen = count;
  374. uart_tx_msg->offset = 0;
  375. uart_tx_msg->finish_callback = uart_tx_finish_callback;
  376. uart_tx_msg->callback_arg = uart_tx_msg->buf;
  377. cpu_sr = tls_os_set_critical();
  378. dl_list_add_tail(&port->tx_msg_pending_list, &uart_tx_msg->list);
  379. tls_os_release_critical(cpu_sr);
  380. return ret;
  381. }
  382. /**
  383. * @brief free the data buffer has been transmitted.
  384. * @param[in] port: is the uart port.
  385. * @retval
  386. */
  387. s16 tls_uart_free_tx_sent_data(struct tls_uart_port *port)
  388. {
  389. tls_uart_tx_msg_t *tx_msg = NULL;
  390. u32 cpu_sr = tls_os_set_critical();
  391. while (!dl_list_empty(&port->tx_msg_to_be_freed_list))
  392. {
  393. tx_msg = dl_list_first(&port->tx_msg_to_be_freed_list, tls_uart_tx_msg_t, list);
  394. dl_list_del(&tx_msg->list);
  395. tls_os_release_critical(cpu_sr);
  396. if (tx_msg->buf != NULL)
  397. {
  398. if (tx_msg->finish_callback)
  399. tx_msg->finish_callback(tx_msg->callback_arg);
  400. tls_mem_free(tx_msg);
  401. }
  402. cpu_sr = tls_os_set_critical();
  403. }
  404. tls_os_release_critical(cpu_sr);
  405. return 0;
  406. }
  407. /**
  408. * @brief This function is used to start transfer data.
  409. * @param[in] port: is the uart port.
  410. * @retval
  411. */
  412. void tls_uart_tx_chars_start(struct tls_uart_port *port)
  413. {
  414. struct dl_list *pending_list = &port->tx_msg_pending_list;
  415. tls_uart_tx_msg_t *tx_msg = NULL;
  416. int tx_count;
  417. u32 cpu_sr;
  418. /* send some chars */
  419. tx_count = 32;
  420. cpu_sr = tls_os_set_critical();
  421. if (!dl_list_empty(pending_list))
  422. {
  423. tx_msg = dl_list_first(pending_list, tls_uart_tx_msg_t, list);
  424. while (tx_count-- > 0 && tx_msg->offset < tx_msg->buflen)
  425. {
  426. /* ���tx fifo�Ƿ����� */
  427. if ((port->regs->UR_FIFOS & UFS_TX_FIFO_CNT_MASK) ==
  428. port->tx_fifofull)
  429. {
  430. break;
  431. }
  432. port->regs->UR_TXW = tx_msg->buf[tx_msg->offset];
  433. tx_msg->offset++;
  434. port->icount.tx++;
  435. }
  436. if (tx_msg->offset >= tx_msg->buflen)
  437. {
  438. dl_list_del(&tx_msg->list);
  439. dl_list_add_tail(&port->tx_msg_to_be_freed_list, &tx_msg->list);
  440. tls_os_release_critical(cpu_sr);
  441. if (port->tx_sent_callback)
  442. port->tx_sent_callback(port);
  443. if (port->tx_callback)
  444. port->tx_callback(port);
  445. }else{
  446. tls_os_release_critical(cpu_sr);
  447. }
  448. }else{
  449. tls_os_release_critical(cpu_sr);
  450. }
  451. }
  452. void tls_set_uart_rx_status(int uart_no, int status)
  453. {
  454. u32 cpu_sr;
  455. struct tls_uart_port *port;
  456. if (TLS_UART_1 == uart_no)
  457. {
  458. port = &uart_port[1];
  459. if ((TLS_UART_RX_DISABLE == port->rxstatus
  460. && TLS_UART_RX_DISABLE == status)
  461. || (TLS_UART_RX_ENABLE == port->rxstatus
  462. && TLS_UART_RX_ENABLE == status))
  463. return;
  464. if (TLS_UART_RX_DISABLE == status)
  465. {
  466. if ((TLS_UART_FLOW_CTRL_HARDWARE == port->opts.flow_ctrl)
  467. && (TLS_UART_FLOW_CTRL_HARDWARE == port->fcStatus))
  468. {
  469. cpu_sr = tls_os_set_critical();
  470. // ��rxfifo trigger level interrupt��overrun error
  471. port->regs->UR_INTM |= ((0x1 << 2) | (0x01 << 8));
  472. port->rxstatus = TLS_UART_RX_DISABLE;
  473. tls_os_release_critical(cpu_sr);
  474. }
  475. }
  476. else
  477. {
  478. cpu_sr = tls_os_set_critical();
  479. uart_port[1].regs->UR_INTM &= ~((0x1 << 2) | (0x01 << 8));
  480. port->rxstatus = TLS_UART_RX_ENABLE;
  481. tls_os_release_critical(cpu_sr);
  482. }
  483. }
  484. }
  485. ATTRIBUTE_ISR void UART0_IRQHandler(void)
  486. {
  487. struct tls_uart_port *port = &uart_port[0];
  488. struct tls_uart_circ_buf *recv = &port->recv;
  489. u8 rx_byte_cb_flag = uart_rx_byte_cb_flag[0];
  490. u32 intr_src;
  491. u32 rx_fifocnt;
  492. u32 fifos;
  493. u8 ch;
  494. u32 rxlen = 0;
  495. csi_kernel_intrpt_enter();
  496. /* check interrupt status */
  497. intr_src = port->regs->UR_INTS;
  498. port->regs->UR_INTS = intr_src;
  499. if ((intr_src & UART_RX_INT_FLAG) && (0 == (port->regs->UR_INTM & UIS_RX_FIFO)))
  500. {
  501. rx_fifocnt = (port->regs->UR_FIFOS >> 6) & 0x3F;
  502. while (rx_fifocnt-- > 0)
  503. {
  504. ch = (u8) port->regs->UR_RXW;
  505. if (intr_src & UART_RX_ERR_INT_FLAG)
  506. {
  507. port->regs->UR_INTS |= UART_RX_ERR_INT_FLAG;
  508. TLS_DBGPRT_INFO("\nrx err=%x,c=%d,ch=%x\n", intr_src, rx_fifocnt, ch);
  509. /* not insert to buffer */
  510. continue;
  511. }
  512. if (CIRC_SPACE(recv->head, recv->tail, TLS_UART_RX_BUF_SIZE) <= 2)
  513. {
  514. TLS_DBGPRT_INFO("\nrx buf overrun int_src=%x\n", intr_src);
  515. if (TLS_UART_FLOW_CTRL_HARDWARE == port->fcStatus)
  516. {
  517. tls_set_uart_rx_status(port->uart_no, TLS_UART_RX_DISABLE);
  518. rx_fifocnt = 0; // �����Ӳ�����أ��رս��գ������һ���ַ��Ž�����buffer��
  519. }
  520. else
  521. break;
  522. }
  523. /* insert the character into the buffer */
  524. recv->buf[recv->head] = ch;
  525. recv->head = (recv->head + 1) & (TLS_UART_RX_BUF_SIZE - 1);
  526. rxlen++;
  527. if(port->rx_callback != NULL && rx_byte_cb_flag)
  528. {
  529. port->rx_callback(1, port->priv_data);
  530. }
  531. }
  532. if (port->rx_callback != NULL && !rx_byte_cb_flag)
  533. {
  534. port->rx_callback(rxlen, port->priv_data);
  535. }
  536. }
  537. if (intr_src & UART_TX_INT_FLAG)
  538. {
  539. tls_uart_tx_chars(port);
  540. }
  541. if (intr_src & UIS_CTS_CHNG)
  542. {
  543. fifos = port->regs->UR_FIFOS;
  544. uart_handle_cts_change(port, fifos & UFS_CST_STS);
  545. }
  546. if (intr_src & UIS_RX_FIFO_TIMEOUT)
  547. {
  548. port->rx_callback(0, (void*)((int)port->priv_data*10));
  549. }
  550. csi_kernel_intrpt_exit();
  551. }
  552. void tls_uart_push(int index, u8* data, int length)
  553. {
  554. int i = 0;
  555. struct tls_uart_port *port = &uart_port[1];
  556. struct tls_uart_circ_buf *recv = &port->recv;
  557. while(i<length)
  558. {
  559. recv->buf[recv->head] = data[i];
  560. recv->head = (recv->head + 1) & (TLS_UART_RX_BUF_SIZE - 1);
  561. i++;
  562. }
  563. }
  564. ATTRIBUTE_ISR void UART1_IRQHandler(void)
  565. {
  566. struct tls_uart_port *port = &uart_port[1];
  567. struct tls_uart_circ_buf *recv = &port->recv;
  568. u8 rx_byte_cb_flag = uart_rx_byte_cb_flag[1];
  569. u32 intr_src;
  570. u32 rx_fifocnt;
  571. u32 fifos;
  572. u8 ch = 0;
  573. u8 escapefifocnt = 0;
  574. u32 rxlen = 0;
  575. csi_kernel_intrpt_enter();
  576. intr_src = port->regs->UR_INTS;
  577. port->regs->UR_INTS = intr_src;
  578. if (intr_src & UIS_OVERRUN)
  579. {
  580. port->regs->UR_INTS |= UIS_OVERRUN;
  581. if(port->tx_dma_on)
  582. {
  583. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) & ~0x01));
  584. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) | 0x01));
  585. }
  586. }
  587. if ((intr_src & UART_RX_INT_FLAG) && (0 == (port->regs->UR_INTM & UIS_RX_FIFO)))
  588. {
  589. rx_fifocnt = (port->regs->UR_FIFOS >> 6) & 0x3F;
  590. escapefifocnt = rx_fifocnt;
  591. port->plus_char_cnt = 0;
  592. rxlen = rx_fifocnt;
  593. if (CIRC_SPACE(recv->head, recv->tail, TLS_UART_RX_BUF_SIZE) <= RX_CACHE_LIMIT)
  594. {
  595. recv->tail = (recv->tail + RX_CACHE_LIMIT) & (TLS_UART_RX_BUF_SIZE - 1);
  596. }
  597. while (rx_fifocnt-- > 0)
  598. {
  599. ch = (u8) port->regs->UR_RXW;
  600. if (intr_src & UART_RX_ERR_INT_FLAG)
  601. {
  602. port->regs->UR_INTS |= UART_RX_ERR_INT_FLAG;
  603. TLS_DBGPRT_INFO("\nrx err=%x,c=%d,ch=%x\n", intr_src, rx_fifocnt, ch);
  604. continue;
  605. }
  606. recv->buf[recv->head] = ch;
  607. recv->head = (recv->head + 1) & (TLS_UART_RX_BUF_SIZE - 1);
  608. }
  609. if( escapefifocnt==3 && ch=='+')
  610. {
  611. switch(recv->head-1)
  612. {
  613. case 0:
  614. if(recv->buf[TLS_UART_RX_BUF_SIZE-1]=='+' && recv->buf[TLS_UART_RX_BUF_SIZE-2]=='+')
  615. port->plus_char_cnt = 3;
  616. break;
  617. case 1:
  618. if(recv->buf[0]=='+' && recv->buf[TLS_UART_RX_BUF_SIZE-1]=='+')
  619. port->plus_char_cnt = 3;
  620. break;
  621. default:
  622. if(recv->buf[recv->head-2]=='+' && recv->buf[recv->head-3]=='+')
  623. port->plus_char_cnt = 3;
  624. break;
  625. }
  626. if(port->rx_callback != NULL && rx_byte_cb_flag)
  627. {
  628. port->rx_callback(1, port->priv_data);
  629. }
  630. }
  631. if (port->rx_callback!=NULL && !rx_byte_cb_flag)
  632. {
  633. port->rx_callback(rxlen, port->priv_data);
  634. }
  635. }
  636. if (intr_src & UART_TX_INT_FLAG)
  637. {
  638. tls_uart_tx_chars(port);
  639. }
  640. if (intr_src & UIS_CTS_CHNG)
  641. {
  642. fifos = port->regs->UR_FIFOS;
  643. uart_handle_cts_change(port, fifos & UFS_CST_STS);
  644. }
  645. csi_kernel_intrpt_exit();
  646. }
  647. static int findOutIntUart(void)
  648. {
  649. int i;
  650. u32 regValue;
  651. for( i=TLS_UART_2; i< TLS_UART_MAX; i++ )
  652. {
  653. regValue = tls_reg_read32(HR_UART0_INT_SRC + i*STEP_SIZE);
  654. regValue &= 0x1FF;
  655. if( regValue )
  656. break;
  657. }
  658. return i;
  659. }
  660. ATTRIBUTE_ISR void UART2_4_IRQHandler(void)
  661. {
  662. int intUartNum = findOutIntUart();
  663. struct tls_uart_port *port = &uart_port[intUartNum];
  664. struct tls_uart_circ_buf *recv = &port->recv;
  665. u32 intr_src;
  666. u32 rx_fifocnt;
  667. u32 fifos;
  668. u32 rxlen = 0;
  669. u8 ch;
  670. csi_kernel_intrpt_enter();
  671. intr_src = port->regs->UR_INTS;
  672. if (intr_src & UIS_OVERRUN)
  673. {
  674. port->regs->UR_INTS |= UIS_OVERRUN;
  675. if(port->tx_dma_on)
  676. {
  677. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) & ~0x01));
  678. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) | 0x01));
  679. }
  680. }
  681. if ((intr_src & UART_RX_INT_FLAG) && (0 == (port->regs->UR_INTM & UIS_RX_FIFO)))
  682. {
  683. rx_fifocnt = (port->regs->UR_FIFOS >> 6) & 0x3F;
  684. while (rx_fifocnt-- > 0)
  685. {
  686. ch = (u8) port->regs->UR_RXW;
  687. if (intr_src & UART_RX_ERR_INT_FLAG)
  688. {
  689. port->regs->UR_INTS |= UART_RX_ERR_INT_FLAG;
  690. continue; /* not insert to buffer */
  691. }
  692. if (CIRC_SPACE(recv->head, recv->tail, TLS_UART_RX_BUF_SIZE) <= 2)
  693. {
  694. if (TLS_UART_FLOW_CTRL_HARDWARE == port->fcStatus)
  695. {
  696. tls_set_uart_rx_status(port->uart_no, TLS_UART_RX_DISABLE);
  697. rx_fifocnt = 0; // �����Ӳ�����أ��رս��գ������һ���ַ��Ž�����buffer��
  698. }
  699. else
  700. break;
  701. }
  702. recv->buf[recv->head] = ch;
  703. recv->head = (recv->head + 1) & (TLS_UART_RX_BUF_SIZE - 1);
  704. rxlen++;
  705. }
  706. if(port->rx_callback != NULL && rxlen)
  707. {
  708. port->rx_callback(rxlen, port->priv_data);
  709. }
  710. }
  711. if (intr_src & UART_TX_INT_FLAG)
  712. {
  713. tls_uart_tx_chars(port);
  714. }
  715. if (intr_src & UIS_CTS_CHNG)
  716. {
  717. fifos = port->regs->UR_FIFOS;
  718. uart_handle_cts_change(port, fifos & UFS_CST_STS);
  719. }
  720. if (intr_src & UIS_RX_FIFO_TIMEOUT)
  721. {
  722. port->rx_callback(0, (void*)((int)port->priv_data*10));
  723. }
  724. port->regs->UR_INTS = intr_src;
  725. csi_kernel_intrpt_exit();
  726. }
  727. /**
  728. * @brief This function is used to initial uart port.
  729. *
  730. * @param[in] uart_no: is the uart number.
  731. * - \ref TLS_UART_0 TLS_UART_1 TLS_UART_2 TLS_UART_3 TLS_UART_4 TLS_UART5
  732. * @param[in] opts: is the uart setting options,if this param is NULL,this function will use the default options.
  733. * @param[in] modeChoose:; choose uart2 mode or 7816 mode when uart_no is TLS_UART_2, 0 for uart2 mode and 1 for 7816 mode.
  734. *
  735. * @retval
  736. * - \ref WM_SUCCESS
  737. * - \ref WM_FAILED
  738. *
  739. * @note When the system is initialized, the function has been called, so users can not call the function.
  740. */
  741. int tls_uart_port_init(u16 uart_no, tls_uart_options_t * opts, u8 modeChoose)
  742. {
  743. struct tls_uart_port *port;
  744. int ret;
  745. char *bufrx; // ,*buftx
  746. tls_uart_options_t opt;
  747. if (TLS_UART_MAX <= uart_no)
  748. {
  749. return WM_FAILED;
  750. }
  751. switch( uart_no )
  752. {
  753. case TLS_UART_0:
  754. case TLS_UART_1:
  755. tls_irq_disable((UART0_IRQn+uart_no));
  756. break;
  757. case TLS_UART_2:
  758. case TLS_UART_3:
  759. case TLS_UART_4:
  760. case TLS_UART_5:
  761. tls_irq_disable(UART24_IRQn);
  762. break;
  763. }
  764. UartRegInit(uart_no);
  765. if (uart_port[uart_no].recv.buf)
  766. {
  767. tls_mem_free((void *)uart_port[uart_no].recv.buf);
  768. uart_port[uart_no].recv.buf = NULL;
  769. }
  770. memset(&uart_port[uart_no], 0, sizeof(struct tls_uart_port));
  771. port = &uart_port[uart_no];
  772. port->regs = (TLS_UART_REGS_T *)(HR_UART0_BASE_ADDR + uart_no*STEP_SIZE);
  773. if( uart_no==TLS_UART_2 )
  774. {
  775. (modeChoose == 1)?(port->regs->UR_LC |= (1 << 24)):(port->regs->UR_LC &= ~(0x1000000));
  776. }
  777. port->uart_no = uart_no;
  778. if (NULL == opts)
  779. {
  780. opt.baudrate = UART_BAUDRATE_B115200;
  781. opt.charlength = TLS_UART_CHSIZE_8BIT;
  782. opt.flow_ctrl = TLS_UART_FLOW_CTRL_NONE;
  783. opt.paritytype = TLS_UART_PMODE_DISABLED;
  784. opt.stopbits = TLS_UART_ONE_STOPBITS;
  785. ret = tls_uart_config(port, &opt);
  786. }
  787. else
  788. {
  789. ret = tls_uart_config(port, opts);
  790. }
  791. if (ret != WM_SUCCESS)
  792. return WM_FAILED;
  793. port->rxstatus = TLS_UART_RX_ENABLE;
  794. switch( uart_no )
  795. {
  796. case TLS_UART_0:
  797. case TLS_UART_1:
  798. port->uart_irq_no = (UART0_IRQn+uart_no);
  799. break;
  800. case TLS_UART_2:
  801. case TLS_UART_3:
  802. case TLS_UART_4:
  803. case TLS_UART_5:
  804. port->uart_irq_no = UART24_IRQn;
  805. break;
  806. }
  807. if (port->recv.buf == NULL)
  808. {
  809. bufrx = tls_mem_alloc(TLS_UART_RX_BUF_SIZE);
  810. if (!bufrx)
  811. return WM_FAILED;
  812. memset(bufrx, 0, TLS_UART_RX_BUF_SIZE);
  813. port->recv.buf = (u8 *) bufrx;
  814. }
  815. port->recv.head = 0;
  816. port->recv.tail = 0;
  817. port->tx_fifofull = 16;
  818. dl_list_init(&port->tx_msg_pending_list);
  819. dl_list_init(&port->tx_msg_to_be_freed_list);
  820. tls_uart_tx_callback_register(uart_no, tls_uart_free_tx_sent_data);
  821. tls_irq_enable(port->uart_irq_no); /* enable uart interrupt */
  822. return WM_SUCCESS;
  823. }
  824. /**
  825. * @brief This function is used to register uart rx interrupt.
  826. *
  827. * @param[in] uart_no: is the uart numer.
  828. * @param[in] callback: is the uart rx interrupt call back function.
  829. *
  830. * @retval
  831. *
  832. * @note This function should be called after the fucntion tls_uart_port_init() or it won't work.
  833. */
  834. void tls_uart_rx_callback_register(u16 uart_no, s16(*rx_callback) (u16 len, void* user_data), void *priv_data)
  835. {
  836. uart_port[uart_no].rx_callback = rx_callback;
  837. uart_port[uart_no].priv_data = priv_data;
  838. }
  839. void tls_uart_rx_byte_callback_flag(u16 uart_no, u8 flag)
  840. {
  841. uart_rx_byte_cb_flag[uart_no] = flag;
  842. }
  843. /**
  844. * @brief This function is used to register uart tx interrupt.
  845. *
  846. * @param[in] uart_no: is the uart numer.
  847. * @param[in] callback: is the uart tx interrupt call back function.
  848. *
  849. * @retval
  850. */
  851. void tls_uart_tx_callback_register(u16 uart_no, s16(*tx_callback) (struct tls_uart_port *port))
  852. {
  853. uart_port[uart_no].tx_callback = tx_callback;
  854. }
  855. void tls_uart_tx_sent_callback_register(u16 uart_no, s16(*tx_callback) (struct tls_uart_port *port))
  856. {
  857. uart_port[uart_no].tx_sent_callback = tx_callback;
  858. }
  859. int tls_uart_try_read(u16 uart_no, int32_t read_size)
  860. {
  861. int data_cnt = 0;
  862. struct tls_uart_port *port = NULL;
  863. struct tls_uart_circ_buf *recv;
  864. port = &uart_port[uart_no];
  865. recv = &port->recv;
  866. data_cnt = CIRC_CNT(recv->head, recv->tail, TLS_UART_RX_BUF_SIZE);
  867. if(data_cnt >= read_size)
  868. {
  869. return read_size;
  870. }else
  871. {
  872. return 0;
  873. }
  874. }
  875. /**
  876. * @brief This function is used to copy circular buffer data to user buffer.
  877. * @param[in] uart_no: is the uart numer.
  878. * @param[in] buf: is the user buffer.
  879. * @param[in] readsize: is the user read size.
  880. * @retval
  881. */
  882. int tls_uart_read(u16 uart_no, u8 * buf, u16 readsize)
  883. {
  884. int data_cnt, buflen, bufcopylen;
  885. struct tls_uart_port *port = NULL;
  886. struct tls_uart_circ_buf *recv;
  887. if (NULL == buf || readsize < 1)
  888. {
  889. return WM_FAILED;
  890. }
  891. port = &uart_port[uart_no];
  892. recv = &port->recv;
  893. data_cnt = CIRC_CNT(recv->head, recv->tail, TLS_UART_RX_BUF_SIZE);
  894. (data_cnt >= readsize)?(buflen = readsize):(buflen = data_cnt);
  895. if ((recv->tail + buflen) > TLS_UART_RX_BUF_SIZE)
  896. {
  897. bufcopylen = (TLS_UART_RX_BUF_SIZE - recv->tail);
  898. MEMCPY(buf, (void *)(recv->buf + recv->tail), bufcopylen);
  899. MEMCPY(buf + bufcopylen, (void *)recv->buf, buflen - bufcopylen);
  900. }
  901. else
  902. {
  903. MEMCPY(buf, (void *)(recv->buf + recv->tail), buflen);
  904. }
  905. recv->tail = (recv->tail + buflen) & (TLS_UART_RX_BUF_SIZE - 1);
  906. return buflen;
  907. }
  908. /**
  909. * @brief This function is used to transfer data throuth DMA.
  910. *
  911. * @param[in] buf is a buf for saving user data
  912. * @param[in] writesize is the user data length
  913. * @param[in] cmpl_callback function point,when the transfer is completed, the function will be called.
  914. *
  915. * @retval WM_SUCCESS success
  916. * @retval WM_FAILED failed
  917. *
  918. * @note Only uart1 support DMA transfer.
  919. */
  920. int tls_uart_dma_write(char *buf, u16 writesize, void (*cmpl_callback) (void *p), u16 uart_no)
  921. {
  922. unsigned char dmaCh = 0;
  923. struct tls_dma_descriptor DmaDesc;
  924. struct tls_uart_port *port = &uart_port[uart_no];
  925. if (NULL == buf || writesize < 1 || writesize >= 4096)
  926. {
  927. TLS_DBGPRT_ERR("param err\n");
  928. return WM_FAILED;
  929. }
  930. if (port->tx_dma_on)
  931. {
  932. TLS_DBGPRT_ERR("transmiting,wait\n");
  933. return WM_FAILED;
  934. }
  935. tls_reg_write32(HR_DMA_CHNL_SEL, uart_no);
  936. /* Request DMA Channel */
  937. dmaCh = tls_dma_request(2, TLS_DMA_FLAGS_CHANNEL_SEL(TLS_DMA_SEL_UART_TX) | TLS_DMA_FLAGS_HARD_MODE);
  938. if (dmaCh == 0xFF)
  939. {
  940. TLS_DBGPRT_ERR("dma request err\n");
  941. return WM_FAILED;
  942. }
  943. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) & ~0x01));
  944. tls_dma_irq_register(dmaCh, cmpl_callback, (void *)(u32)uart_no, TLS_DMA_IRQ_TRANSFER_DONE);
  945. DmaDesc.src_addr = (int) buf;
  946. DmaDesc.dest_addr = (int)&port->regs->UR_TXW;
  947. DmaDesc.dma_ctrl = TLS_DMA_DESC_CTRL_SRC_ADD_INC | TLS_DMA_DESC_CTRL_DATA_SIZE_BYTE | (writesize << 7);
  948. DmaDesc.valid = TLS_DMA_DESC_VALID;
  949. DmaDesc.next = NULL;
  950. tls_dma_start(dmaCh, &DmaDesc, 0);
  951. /* Enable uart TX DMA */
  952. port->tx_dma_on = TRUE;
  953. tls_reg_write32((int)&port->regs->UR_DMAC, (tls_reg_read32((int)&port->regs->UR_DMAC) | 0x01));
  954. tls_reg_write32(HR_DMA_INT_MASK, (tls_reg_read32(HR_DMA_INT_MASK) & ~(0x01 << 5)));
  955. /* enable dma interrupt */
  956. tls_irq_enable(DMA_Channel2_IRQn);
  957. return WM_SUCCESS;
  958. }
  959. /**
  960. * @brief This function is used to transfer data asynchronous.
  961. *
  962. * @param[in] uart_no is the uart number
  963. * @param[in] buf is a buf for saving user data.
  964. * @param[in] writesize is the data length
  965. *
  966. * @retval WM_SUCCESS success
  967. * @retval WM_FAILED failed
  968. *
  969. * @note The function only start transmission, fill buffer in the callback function.
  970. */
  971. int tls_uart_write_async(u16 uart_no, char *buf, u16 writesize)
  972. {
  973. struct tls_uart_port *port = NULL;
  974. int ret;
  975. if (NULL == buf || writesize < 1)
  976. {
  977. TLS_DBGPRT_ERR("param err\n");
  978. return WM_FAILED;
  979. }
  980. port = &uart_port[uart_no];
  981. ret = tls_uart_fill_buf(port, buf, writesize);
  982. if (0 == ret)
  983. {
  984. tls_uart_tx_chars_start(port);
  985. }
  986. return ret;
  987. }
  988. /**
  989. * @brief get the data length has been transmitted.
  990. *
  991. * @param[in] uart_no is the uart number
  992. *
  993. * @retval the length has been transmitted
  994. *
  995. */
  996. int tls_uart_tx_length(u16 uart_no)
  997. {
  998. struct tls_uart_port *port = &uart_port[uart_no];
  999. return port->icount.tx;
  1000. }
  1001. /**
  1002. * @brief This function is used to transfer data synchronous.
  1003. *
  1004. * @param[in] uart_no is the uart number
  1005. * @param[in] buf is a buf for saving user data.
  1006. * @param[in] writesize is the data length
  1007. *
  1008. * @retval WM_SUCCESS success
  1009. * @retval WM_FAILED failed
  1010. *
  1011. * @note The function only start transmission, fill buffer in the callback function.
  1012. */
  1013. int tls_uart_write(u16 uart_no, char *buf, u16 writesize)
  1014. {
  1015. return tls_uart_write_async(uart_no, buf, writesize);
  1016. }
  1017. /**
  1018. * @brief This function is used to set uart parity.
  1019. *
  1020. * @param[in] paritytype is a parity type defined in TLS_UART_PMODE_T
  1021. *
  1022. * @retval WM_SUCCESS success
  1023. * @retval WM_FAILED failed
  1024. *
  1025. */
  1026. int tls_uart_set_parity(u16 uart_no, TLS_UART_PMODE_T paritytype)
  1027. {
  1028. return tls_uart_set_parity_inside(&uart_port[uart_no], paritytype);
  1029. }
  1030. /**
  1031. * @brief This function is used to set uart baudrate.
  1032. *
  1033. * @param[in] uart_no is the uart number
  1034. * @param[in] baudrate is the baudrate user want used,the unit is HZ.
  1035. *
  1036. * @retval WM_SUCCESS success
  1037. * @retval WM_FAILED failed
  1038. *
  1039. */
  1040. int tls_uart_set_baud_rate(u16 uart_no, u32 baudrate)
  1041. {
  1042. return tls_uart_set_baud_rate_inside(&uart_port[uart_no], baudrate);
  1043. }
  1044. /**
  1045. * @brief This function is used to set uart stop bits.
  1046. *
  1047. * @param[in] uart_no is the uart number
  1048. * @param[in] stopbits is a stop bit type defined in TLS_UART_STOPBITS_T.
  1049. *
  1050. * @retval WM_SUCCESS success
  1051. * @retval WM_FAILED failed
  1052. *
  1053. */
  1054. int tls_uart_set_stop_bits(u16 uart_no, TLS_UART_STOPBITS_T stopbits)
  1055. {
  1056. return tls_uart_set_stop_bits_inside(&uart_port[uart_no], stopbits);
  1057. }
  1058. int tls_uart_dma_off(u16 uart_no)
  1059. {
  1060. uart_port[uart_no].tx_dma_on = FALSE;
  1061. return WM_SUCCESS;
  1062. }
  1063. #endif
  1064. //TLS_CONFIG_UART