1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  *   of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  *   list of conditions and the following disclaimer in the documentation and/or
13  *   other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  *   contributors may be used to endorse or promote products derived from this
17  *   software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "uart_imx.h"
32 
33 /*******************************************************************************
34  * Code
35  ******************************************************************************/
36 
37 /*******************************************************************************
38  * Initialization and Configuration functions
39  ******************************************************************************/
40 /*FUNCTION**********************************************************************
41  *
42  * Function Name : UART_Init
43  * Description   : This function initializes the module according to uart
44  *                 initialize structure.
45  *
46  *END**************************************************************************/
UART_Init(UART_Type * base,const uart_init_config_t * initConfig)47 void UART_Init(UART_Type* base, const uart_init_config_t* initConfig)
48 {
49     assert(initConfig);
50 
51     /* Disable UART Module. */
52     UART_UCR1_REG(base) &= ~UART_UCR1_UARTEN_MASK;
53 
54     /* Reset UART register to its default value. */
55     UART_Deinit(base);
56 
57     /* Set UART data word length, stop bit count, parity mode and communication
58      * direction according to uart init struct, disable RTS hardware flow
59      * control. */
60     UART_UCR2_REG(base) |= (initConfig->wordLength |
61                             initConfig->stopBitNum |
62                             initConfig->parity     |
63                             initConfig->direction  |
64                             UART_UCR2_IRTS_MASK);
65 
66     /* For imx family device, UARTs are used in MUXED mode,
67      * so that this bit should always be set.*/
68     UART_UCR3_REG(base) |= UART_UCR3_RXDMUXSEL_MASK;
69 
70     /* Set BaudRate according to uart initialize struct. */
71     /* Baud Rate = Ref Freq / (16 * (UBMR + 1)/(UBIR+1)) */
72     UART_SetBaudRate(base, initConfig->clockRate, initConfig->baudRate);
73 }
74 
75 /*FUNCTION**********************************************************************
76  *
77  * Function Name : UART_Deinit
78  * Description   : This function reset Uart module register content to its
79  *                 default value.
80  *
81  *END**************************************************************************/
UART_Deinit(UART_Type * base)82 void UART_Deinit(UART_Type* base)
83 {
84     /* Disable UART Module */
85     UART_UCR1_REG(base) &= ~UART_UCR1_UARTEN_MASK;
86 
87     /* Reset UART Module Register content to default value */
88     UART_UCR1_REG(base)  = 0x0;
89     UART_UCR2_REG(base)  = UART_UCR2_SRST_MASK;
90     UART_UCR3_REG(base)  = UART_UCR3_DSR_MASK |
91                            UART_UCR3_DCD_MASK |
92                            UART_UCR3_RI_MASK;
93     UART_UCR4_REG(base)  = UART_UCR4_CTSTL(32);
94     UART_UFCR_REG(base)  = UART_UFCR_TXTL(2) | UART_UFCR_RXTL(1);
95     UART_UESC_REG(base)  = UART_UESC_ESC_CHAR(0x2B);
96     UART_UTIM_REG(base)  = 0x0;
97     UART_ONEMS_REG(base) = 0x0;
98     UART_UTS_REG(base)   = UART_UTS_TXEMPTY_MASK | UART_UTS_RXEMPTY_MASK;
99     UART_UMCR_REG(base)  = 0x0;
100 
101     /* Reset the transmit and receive state machines, all FIFOs and register
102      * USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD and UTS[6-3]. */
103     UART_UCR2_REG(base) &= ~UART_UCR2_SRST_MASK;
104     while (!(UART_UCR2_REG(base) & UART_UCR2_SRST_MASK));
105 }
106 
107 /*FUNCTION**********************************************************************
108  *
109  * Function Name : UART_SetBaudRate
110  * Description   :
111  *
112  *END**************************************************************************/
UART_SetBaudRate(UART_Type * base,uint32_t clockRate,uint32_t baudRate)113 void UART_SetBaudRate(UART_Type* base, uint32_t clockRate, uint32_t baudRate)
114 {
115     uint32_t numerator;
116     uint32_t denominator;
117     uint32_t divisor;
118     uint32_t refFreqDiv;
119     uint32_t divider = 1;
120 
121     /* get the approximately maximum divisor */
122     numerator = clockRate;
123     denominator = baudRate << 4;
124     divisor = 1;
125 
126     while (denominator != 0)
127     {
128         divisor = denominator;
129         denominator = numerator % denominator;
130         numerator = divisor;
131     }
132 
133     numerator = clockRate / divisor;
134     denominator = (baudRate << 4) / divisor;
135 
136     /* numerator ranges from 1 ~ 7 * 64k */
137     /* denominator ranges from 1 ~ 64k */
138     if ((numerator > (UART_UBIR_INC_MASK * 7)) ||
139         (denominator > UART_UBIR_INC_MASK))
140     {
141         uint32_t m = (numerator - 1) / (UART_UBIR_INC_MASK * 7) + 1;
142         uint32_t n = (denominator - 1) / UART_UBIR_INC_MASK + 1;
143         uint32_t max = m > n ? m : n;
144         numerator /= max;
145         denominator /= max;
146         if (0 == numerator)
147             numerator = 1;
148         if (0 == denominator)
149             denominator = 1;
150     }
151     divider = (numerator - 1) / UART_UBIR_INC_MASK + 1;
152 
153     switch (divider)
154     {
155         case 1:
156             refFreqDiv = 0x05;
157             break;
158         case 2:
159             refFreqDiv = 0x04;
160             break;
161         case 3:
162             refFreqDiv = 0x03;
163             break;
164         case 4:
165             refFreqDiv = 0x02;
166             break;
167         case 5:
168             refFreqDiv = 0x01;
169             break;
170         case 6:
171             refFreqDiv = 0x00;
172             break;
173         case 7:
174             refFreqDiv = 0x06;
175             break;
176         default:
177         refFreqDiv = 0x05;
178     }
179 
180     UART_UFCR_REG(base) &= ~UART_UFCR_RFDIV_MASK;
181     UART_UFCR_REG(base) |= UART_UFCR_RFDIV(refFreqDiv);
182     UART_UBIR_REG(base) = UART_UBIR_INC(denominator - 1);
183     UART_UBMR_REG(base) = UART_UBMR_MOD(numerator / divider - 1);
184     UART_ONEMS_REG(base) = UART_ONEMS_ONEMS(clockRate/(1000 * divider));
185 }
186 
187 /*FUNCTION**********************************************************************
188  *
189  * Function Name : UART_SetInvertCmd
190  * Description   : This function is used to set the polarity of UART signal.
191  *                 The polarity of Tx and Rx can be set separately.
192  *
193  *END**************************************************************************/
UART_SetInvertCmd(UART_Type * base,uint32_t direction,bool invert)194 void UART_SetInvertCmd(UART_Type* base, uint32_t direction, bool invert)
195 {
196     assert((direction & uartDirectionTx) || (direction & uartDirectionRx));
197 
198     if (invert)
199     {
200         if (direction & UART_UCR2_RXEN_MASK)
201             UART_UCR4_REG(base) |= UART_UCR4_INVR_MASK;
202         if (direction & UART_UCR2_TXEN_MASK)
203             UART_UCR3_REG(base) |= UART_UCR3_INVT_MASK;
204     }
205     else
206     {
207         if (direction & UART_UCR2_RXEN_MASK)
208             UART_UCR4_REG(base) &= ~UART_UCR4_INVR_MASK;
209         if (direction & UART_UCR2_TXEN_MASK)
210             UART_UCR3_REG(base) &= ~UART_UCR3_INVT_MASK;
211     }
212 }
213 
214 /*******************************************************************************
215  * Low Power Mode functions
216  ******************************************************************************/
217 /*FUNCTION**********************************************************************
218  *
219  * Function Name : UART_SetDozeMode
220  * Description   : This function is used to set UART enable condition in the
221  *                 DOZE state.
222  *
223  *END**************************************************************************/
UART_SetDozeMode(UART_Type * base,bool enable)224 void UART_SetDozeMode(UART_Type* base, bool enable)
225 {
226     if (enable)
227         UART_UCR1_REG(base) &= UART_UCR1_DOZE_MASK;
228     else
229         UART_UCR1_REG(base) |= ~UART_UCR1_DOZE_MASK;
230 }
231 
232 /*FUNCTION**********************************************************************
233  *
234  * Function Name : UART_SetLowPowerMode
235  * Description   : This function is used to set UART enable condition of the
236  *                 UART low power feature.
237  *
238  *END**************************************************************************/
UART_SetLowPowerMode(UART_Type * base,bool enable)239 void UART_SetLowPowerMode(UART_Type* base, bool enable)
240 {
241     if (enable)
242         UART_UCR4_REG(base) &= ~UART_UCR4_LPBYP_MASK;
243     else
244         UART_UCR4_REG(base) |= UART_UCR4_LPBYP_MASK;
245 }
246 
247 /*******************************************************************************
248  * Interrupt and Flag control functions
249  ******************************************************************************/
250 /*FUNCTION**********************************************************************
251  *
252  * Function Name : UART_SetIntCmd
253  * Description   : This function is used to set the enable condition of
254  *                 specific UART interrupt source. The available interrupt
255  *                 source can be select from uart_int_source enumeration.
256  *
257  *END**************************************************************************/
UART_SetIntCmd(UART_Type * base,uint32_t intSource,bool enable)258 void UART_SetIntCmd(UART_Type* base, uint32_t intSource, bool enable)
259 {
260     volatile uint32_t* uart_reg = 0;
261     uint32_t uart_mask = 0;
262 
263     uart_reg = (uint32_t *)((uint32_t)base + (intSource >> 16));
264     uart_mask = (1 << (intSource & 0x0000FFFF));
265 
266     if (enable)
267         *uart_reg |= uart_mask;
268     else
269         *uart_reg &= ~uart_mask;
270 }
271 
272 /*FUNCTION**********************************************************************
273  *
274  * Function Name : UART_GetStatusFlag
275  * Description   : This function is used to get the current status of specific
276  *                 UART status flag. The available status flag can be select
277  *                 from uart_status_flag & uart_interrupt_flag enumeration.
278  *
279  *END**************************************************************************/
280 /*
281 bool UART_GetStatusFlag(UART_Type* base, uint32_t flag)
282 {
283     volatile uint32_t* uart_reg = 0;
284 
285     uart_reg = (uint32_t *)((uint32_t)base + (flag >> 16));
286     return (bool)((*uart_reg >> (flag & 0x0000FFFF)) & 0x1);
287 }
288 */
289 
290 /*FUNCTION**********************************************************************
291  *
292  * Function Name : UART_ClearStatusFlag
293  * Description   : This function is used to get the current status
294  *                 of specific UART status flag. The available status
295  *                 flag can be select from uart_status_flag &
296  *                 uart_interrupt_flag enumeration.
297  *
298  *END**************************************************************************/
UART_ClearStatusFlag(UART_Type * base,uint32_t flag)299 void UART_ClearStatusFlag(UART_Type* base, uint32_t flag)
300 {
301     volatile uint32_t* uart_reg = 0;
302     uint32_t uart_mask = 0;
303 
304     uart_reg = (uint32_t *)((uint32_t)base + (flag >> 16));
305     uart_mask = (1 << (flag & 0x0000FFFF));
306 
307     /* write 1 to clear. */
308     *uart_reg = uart_mask;
309 }
310 
311 /*******************************************************************************
312  * DMA control functions
313  ******************************************************************************/
314 /*FUNCTION**********************************************************************
315  *
316  * Function Name : UART_SetDmaCmd
317  * Description   : This function is used to set the enable condition of
318  *                 specific UART DMA source. The available DMA
319  *                 source can be select from uart_dma_source enumeration.
320  *
321  *END**************************************************************************/
UART_SetDmaCmd(UART_Type * base,uint32_t dmaSource,bool enable)322 void UART_SetDmaCmd(UART_Type* base, uint32_t dmaSource, bool enable)
323 {
324     volatile uint32_t* uart_reg = 0;
325     uint32_t uart_mask = 0;
326 
327     uart_reg = (uint32_t *)((uint32_t)base + (dmaSource >> 16));
328     uart_mask = (1 << (dmaSource & 0x0000FFFF));
329     if (enable)
330         *uart_reg |= uart_mask;
331     else
332         *uart_reg &= ~uart_mask;
333 }
334 
335 /*******************************************************************************
336  * Hardware Flow control and Modem Signal functions
337  ******************************************************************************/
338 /*FUNCTION**********************************************************************
339  *
340  * Function Name : UART_SetRtsFlowCtrlCmd
341  * Description   : This function is used to set the enable condition of RTS
342  *                 Hardware flow control.
343  *
344  *END**************************************************************************/
UART_SetRtsFlowCtrlCmd(UART_Type * base,bool enable)345 void UART_SetRtsFlowCtrlCmd(UART_Type* base, bool enable)
346 {
347     if (enable)
348         UART_UCR2_REG(base) &= ~UART_UCR2_IRTS_MASK;
349     else
350         UART_UCR2_REG(base) |= UART_UCR2_IRTS_MASK;
351 }
352 
353 /*FUNCTION**********************************************************************
354  *
355  * Function Name : UART_SetCtsFlowCtrlCmd
356  * Description   : This function is used to set the enable condition of CTS
357  *                 auto control. if CTS control is enabled, the CTS_B pin will
358  *                 be controlled by the receiver, otherwise the CTS_B pin will
359  *                 controlled by UART_CTSPinCtrl function.
360  *
361  *END**************************************************************************/
UART_SetCtsFlowCtrlCmd(UART_Type * base,bool enable)362 void UART_SetCtsFlowCtrlCmd(UART_Type* base, bool enable)
363 {
364     if (enable)
365         UART_UCR2_REG(base) |= UART_UCR2_CTSC_MASK;
366     else
367         UART_UCR2_REG(base) &= ~UART_UCR2_CTSC_MASK;
368 }
369 
370 /*FUNCTION**********************************************************************
371  *
372  * Function Name : UART_SetCtsPinLevel
373  * Description   : This function is used to control the CTS_B pin state when
374  *                 auto CTS control is disabled.
375  *                 The CTS_B pin is low (active)
376  *                 The CTS_B pin is high (inactive)
377  *
378  *END**************************************************************************/
UART_SetCtsPinLevel(UART_Type * base,bool active)379 void UART_SetCtsPinLevel(UART_Type* base, bool active)
380 {
381     if (active)
382         UART_UCR2_REG(base) |= UART_UCR2_CTS_MASK;
383     else
384         UART_UCR2_REG(base) &= ~UART_UCR2_CTS_MASK;
385 }
386 
387 /*FUNCTION**********************************************************************
388  *
389  * Function Name : UART_SetModemMode
390  * Description   : This function is used to set the role(DTE/DCE) of UART module
391  *                 in RS-232 communication.
392  *
393  *END**************************************************************************/
UART_SetModemMode(UART_Type * base,uint32_t mode)394 void UART_SetModemMode(UART_Type* base, uint32_t mode)
395 {
396     assert((mode == uartModemModeDce) || (mode == uartModemModeDte));
397 
398     if (uartModemModeDce == mode)
399         UART_UFCR_REG(base) &= ~UART_UFCR_DCEDTE_MASK;
400     else
401         UART_UFCR_REG(base) |= UART_UFCR_DCEDTE_MASK;
402 }
403 
404 /*FUNCTION**********************************************************************
405  *
406  * Function Name : UART_SetDtrPinLevel
407  * Description   : This function is used to set the pin state of
408  *                 DSR pin(for DCE mode) or DTR pin(for DTE mode) for the
409  *                 modem interface.
410  *
411  *END**************************************************************************/
UART_SetDtrPinLevel(UART_Type * base,bool active)412 void UART_SetDtrPinLevel(UART_Type* base, bool active)
413 {
414     if (active)
415         UART_UCR3_REG(base) |= UART_UCR3_DSR_MASK;
416     else
417         UART_UCR3_REG(base) &= ~UART_UCR3_DSR_MASK;
418 }
419 
420 /*FUNCTION**********************************************************************
421  *
422  * Function Name : UART_SetDcdPinLevel
423  * Description   : This function is used to set the pin state of
424  *                 DCD pin. THIS FUNCTION IS FOR DCE MODE ONLY.
425  *
426  *END**************************************************************************/
UART_SetDcdPinLevel(UART_Type * base,bool active)427 void UART_SetDcdPinLevel(UART_Type* base, bool active)
428 {
429     if (active)
430         UART_UCR3_REG(base) |= UART_UCR3_DCD_MASK;
431     else
432         UART_UCR3_REG(base) &= ~UART_UCR3_DCD_MASK;
433 }
434 
435 /*FUNCTION**********************************************************************
436  *
437  * Function Name : UART_SetRiPinLevel
438  * Description   : This function is used to set the pin state of
439  *                 RI pin. THIS FUNCTION IS FOR DCE MODE ONLY.
440  *
441  *END**************************************************************************/
UART_SetRiPinLevel(UART_Type * base,bool active)442 void UART_SetRiPinLevel(UART_Type* base, bool active)
443 {
444     if (active)
445         UART_UCR3_REG(base) |= UART_UCR3_RI_MASK;
446     else
447         UART_UCR3_REG(base) &= ~UART_UCR3_RI_MASK;
448 }
449 
450 /*******************************************************************************
451  * Multiprocessor and RS-485 functions
452  ******************************************************************************/
453 /*FUNCTION**********************************************************************
454  *
455  * Function Name : UART_Putchar9
456  * Description   : This function is used to send 9 Bits length data in
457  *                 RS-485 Multidrop mode.
458  *
459  *END**************************************************************************/
UART_Putchar9(UART_Type * base,uint16_t data)460 void UART_Putchar9(UART_Type* base, uint16_t data)
461 {
462     assert(data <= 0x1FF);
463 
464     if (data & 0x0100)
465         UART_UMCR_REG(base) |= UART_UMCR_TXB8_MASK;
466     else
467         UART_UMCR_REG(base) &= ~UART_UMCR_TXB8_MASK;
468     UART_UTXD_REG(base) = (data & UART_UTXD_TX_DATA_MASK);
469 }
470 
471 /*FUNCTION**********************************************************************
472  *
473  * Function Name : UART_Getchar9
474  * Description   : This functions is used to receive 9 Bits length data in
475  *                 RS-485 Multidrop mode.
476  *
477  *END**************************************************************************/
UART_Getchar9(UART_Type * base)478 uint16_t UART_Getchar9(UART_Type* base)
479 {
480     uint16_t rxData = UART_URXD_REG(base);
481 
482     if (rxData & UART_URXD_PRERR_MASK)
483     {
484         rxData = (rxData & 0x00FF) | 0x0100;
485     }
486     else
487     {
488         rxData &= 0x00FF;
489     }
490 
491     return rxData;
492 }
493 
494 /*FUNCTION**********************************************************************
495  *
496  * Function Name : UART_SetMultidropMode
497  * Description   : This function is used to set the enable condition of
498  *                 9-Bits data or Multidrop mode.
499  *
500  *END**************************************************************************/
UART_SetMultidropMode(UART_Type * base,bool enable)501 void UART_SetMultidropMode(UART_Type* base, bool enable)
502 {
503     if (enable)
504         UART_UMCR_REG(base) |= UART_UMCR_MDEN_MASK;
505     else
506         UART_UMCR_REG(base) &= ~UART_UMCR_MDEN_MASK;
507 }
508 
509 /*FUNCTION**********************************************************************
510  *
511  * Function Name : UART_SetSlaveAddressDetectCmd
512  * Description   : This function is used to set the enable condition of
513  *                 Automatic Address Detect Mode.
514  *
515  *END**************************************************************************/
UART_SetSlaveAddressDetectCmd(UART_Type * base,bool enable)516 void UART_SetSlaveAddressDetectCmd(UART_Type* base, bool enable)
517 {
518     if (enable)
519         UART_UMCR_REG(base) |= UART_UMCR_SLAM_MASK;
520     else
521         UART_UMCR_REG(base) &= ~UART_UMCR_SLAM_MASK;
522 }
523 
524 /*******************************************************************************
525  * IrDA control functions
526  ******************************************************************************/
527 /*FUNCTION**********************************************************************
528  *
529  * Function Name : UART_SetIrDACmd
530  * Description   : This function is used to set the enable condition of
531  *                 IrDA Mode.
532  *
533  *END**************************************************************************/
UART_SetIrDACmd(UART_Type * base,bool enable)534 void UART_SetIrDACmd(UART_Type* base, bool enable)
535 {
536     if (enable)
537         UART_UCR1_REG(base) |= UART_UCR1_IREN_MASK;
538     else
539         UART_UCR1_REG(base) &= ~UART_UCR1_IREN_MASK;
540 }
541 
542 /*FUNCTION**********************************************************************
543  *
544  * Function Name : UART_SetIrDAVoteClock
545  * Description   : This function is used to set the clock for the IR pulsed
546  *                 vote logic. The available clock can be select from
547  *                 uart_irda_vote_clock enumeration.
548  *
549  *END**************************************************************************/
UART_SetIrDAVoteClock(UART_Type * base,uint32_t voteClock)550 void UART_SetIrDAVoteClock(UART_Type* base, uint32_t voteClock)
551 {
552     assert((voteClock == uartIrdaVoteClockSampling) || \
553            (voteClock == uartIrdaVoteClockReference));
554 
555     if (uartIrdaVoteClockSampling == voteClock)
556         UART_UCR4_REG(base) |= UART_UCR4_IRSC_MASK;
557     else
558         UART_UCR4_REG(base) &= ~UART_UCR4_IRSC_MASK;
559 }
560 
561 /*******************************************************************************
562  * Misc. functions
563  ******************************************************************************/
564 /*FUNCTION**********************************************************************
565  *
566  * Function Name : UART_SetAutoBaudRateCmd
567  * Description   : This function is used to set the enable condition of
568  *                 Automatic Baud Rate Detection feature.
569  *
570  *END**************************************************************************/
UART_SetAutoBaudRateCmd(UART_Type * base,bool enable)571 void UART_SetAutoBaudRateCmd(UART_Type* base, bool enable)
572 {
573     if (enable)
574         UART_UCR1_REG(base) |= UART_UCR1_ADBR_MASK;
575     else
576         UART_UCR1_REG(base) &= ~UART_UCR1_ADBR_MASK;
577 }
578 
579 /*FUNCTION**********************************************************************
580  *
581  * Function Name : UART_SendBreakChar
582  * Description   : This function is used to send BREAK character.It is
583  *                 important that SNDBRK is asserted high for a sufficient
584  *                 period of time to generate a valid BREAK.
585  *
586  *END**************************************************************************/
UART_SendBreakChar(UART_Type * base,bool active)587 void UART_SendBreakChar(UART_Type* base, bool active)
588 {
589     if (active)
590         UART_UCR1_REG(base) |= UART_UCR1_SNDBRK_MASK;
591     else
592         UART_UCR1_REG(base) &= ~UART_UCR1_SNDBRK_MASK;
593 }
594 
595 /*FUNCTION**********************************************************************
596  *
597  * Function Name : UART_SetEscapeDecectCmd
598  * Description   : This function is used to set the enable condition of
599  *                 Escape Sequence Detection feature.
600  *
601  *END**************************************************************************/
UART_SetEscapeDecectCmd(UART_Type * base,bool enable)602 void UART_SetEscapeDecectCmd(UART_Type* base, bool enable)
603 {
604     if (enable)
605         UART_UCR2_REG(base) |= UART_UCR2_ESCEN_MASK;
606     else
607         UART_UCR2_REG(base) &= ~UART_UCR2_ESCEN_MASK;
608 }
609 
610 /*******************************************************************************
611  * EOF
612  ******************************************************************************/
613