1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
\r
2 * File Name : 91x_uart.c
\r
3 * Author : MCD Application Team
\r
4 * Date First Issued : 05/18/2006 : Version 1.0
\r
5 * Description : This file provides all the UART software functions.
\r
6 ********************************************************************************
\r
8 * 05/24/2006 : Version 1.1
\r
9 * 05/18/2006 : Version 1.0
\r
10 ********************************************************************************
\r
11 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
\r
13 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
\r
14 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
\r
15 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
\r
16 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
17 *******************************************************************************/
\r
19 /* Includes ------------------------------------------------------------------*/
\r
20 #include "91x_uart.h"
\r
21 #include "91x_scu.h"
\r
23 /* Private typedef -----------------------------------------------------------*/
\r
24 /* Private define ------------------------------------------------------------*/
\r
25 /* UART IrDA Mask */
\r
26 #define UART_IrDA_Disable_Mask 0xFFFD /* IrDA Disable Mask */
\r
27 #define UART_IrDA_Enable_Mask 0x0002 /* IrDA Enable Mask */
\r
28 #define IrDA_LowPower_Enable_Mask 0x0004 /*IrDA lower power mode enable*/
\r
29 #define IrDA_LowPower_Disable_Mask 0xFFFB /*IrDA lower power mode enable*/
\r
32 #define UART_Enable_Mask 0x0001 /* UART Enable Mask */
\r
33 #define UART_Disable_Mask 0xFFFE /* UART Disable Mask */
\r
36 #define UART_LoopBack_Disable_Mask 0xFF7F /* LoopBack Disable Mask */
\r
37 #define UART_LoopBack_Enable_Mask 0x0080 /* LoopBack Enable Mask */
\r
39 #define UART_WordLength_Mask 0xFF9F /* UART Word Length Mask */
\r
40 #define UART_Parity_Mask 0xFF79 /* UART Parity Mask */
\r
41 #define UART_HardwareFlowControl_Mask 0x3FFF /* UART Hardware Flow Control Mask */
\r
42 #define UART_TxRxFIFOLevel_Mask 0xFFC0 /* UART Tx Rx FIFO Level Mask */
\r
43 #define UART_BreakChar_Mask 0x0001 /* UART Break Character send Mask*/
\r
44 #define UART_FLAG_Mask 0x1F /* UART Flag Mask */
\r
45 #define UART_Mode_Mask 0xFCFF /* UART Mode Mask */
\r
46 #define UART_RTS_LowLevel_Mask 0x0800 /* RTS signal is low */
\r
47 #define UART_RTS_HighLevel_Mask 0xF7FF /* RTS signal is High */
\r
48 #define UART_DTR_LowLevel_Mask 0x0400 /* DTR signal is low */
\r
49 #define UART_DTR_HighLevel_Mask 0xFBFF /* DTR signal is High */
\r
50 #define UART_ClearFlag_Mask 0xAA /* Clear Flag Mask */
\r
52 /* Private macro -------------------------------------------------------------*/
\r
53 /* Private variables ---------------------------------------------------------*/
\r
54 /* Private function prototypes -----------------------------------------------*/
\r
55 /* Private functions ---------------------------------------------------------*/
\r
57 /*******************************************************************************
\r
58 * Function Name : UART_DeInit
\r
59 * Description : Deinitializes the UARTx peripheral registers
\r
60 * to their default reset values.
\r
61 * Input : UARTx: where x can be 0,1 or 2 to select the UART peripheral.
\r
64 *******************************************************************************/
\r
65 void UART_DeInit(UART_TypeDef* UARTx)
\r
67 /* Reset the UARTx registers values */
\r
70 SCU_APBPeriphReset(__UART0,ENABLE);
\r
71 SCU_APBPeriphReset(__UART0,DISABLE);
\r
73 else if(UARTx == UART1)
\r
75 SCU_APBPeriphReset(__UART1,ENABLE);
\r
76 SCU_APBPeriphReset(__UART1,DISABLE);
\r
78 else if(UARTx == UART2)
\r
80 SCU_APBPeriphReset(__UART2,ENABLE);
\r
81 SCU_APBPeriphReset(__UART2,DISABLE);
\r
85 /*******************************************************************************
\r
86 * Function Name : UART_Init
\r
87 * Description : Initializes the UARTx peripheral according to the specified
\r
88 * parameters in the UART_InitStruct .
\r
89 * Input : - UARTx: where x can be 0,1or 2 to select the UART peripheral.
\r
90 * - UART_InitStruct: pointer to a UART_InitTypeDef structure
\r
91 * that contains the configuration information for the
\r
92 * specified UART peripheral.
\r
95 *******************************************************************************/
\r
96 void UART_Init(UART_TypeDef* UARTx, UART_InitTypeDef* UART_InitStruct)
\r
99 u64 UART_MainClock = 0;
\r
100 u32 IntegerDivider = 0;
\r
101 u32 FractionalDivider = 0;
\r
103 /* Clear the LCR[6:5] bits */
\r
104 UARTx->LCR &= UART_WordLength_Mask;
\r
105 /* Set the LCR[6:5] bits according to UART_WordLength value */
\r
106 UARTx->LCR |= UART_InitStruct->UART_WordLength;
\r
108 /* Choose Stop Bits */
\r
109 if(UART_InitStruct->UART_StopBits == UART_StopBits_2)
\r
112 UARTx->LCR |= UART_StopBits_2;
\r
116 /* One Stop Bits */
\r
117 UARTx->LCR &= UART_StopBits_1;
\r
120 /* Configure the Parity */
\r
121 /* Clear the LCR[7]and LCR[2:1] bits */
\r
122 UARTx->LCR &= UART_Parity_Mask;
\r
123 /* Set the LCR[7]and LCR[2:1] bits according to UART_Parity value */
\r
124 UARTx->LCR |= UART_InitStruct->UART_Parity;
\r
126 /* Configure the BaudRate */
\r
127 UART_MainClock = (SCU_GetMCLKFreqValue())*1000;
\r
128 if((SCU->CLKCNTR & 0x200) != 0x200)
\r
130 UART_MainClock = UART_MainClock/2;
\r
132 /* Determine the integer part */
\r
133 IntegerDivider = ((100) * (UART_MainClock) / (16 * (UART_InitStruct->UART_BaudRate)));
\r
134 UARTx->IBRD = IntegerDivider / 100;
\r
136 /* Determine the fractional part */
\r
137 FractionalDivider = IntegerDivider - (100 * (UARTx->IBRD));
\r
138 UARTx->FBRD = ((((FractionalDivider * 64) + 50) / 100));
\r
140 /* Choose the Hardware Flow Control */
\r
141 /* Clear the CR[15:14] bits */
\r
142 UARTx->CR &= UART_HardwareFlowControl_Mask;
\r
143 /* Set the CR[15:14] bits according to UART_HardwareFlowControl value */
\r
144 UARTx->CR |= UART_InitStruct->UART_HardwareFlowControl;
\r
146 /* Configure the UART mode */
\r
147 /* Clear the CR[9:8] bits */
\r
148 UARTx->CR &= UART_Mode_Mask;
\r
149 /* Set the CR[9:8] bits according to UART_Mode value */
\r
150 UARTx->CR |= UART_InitStruct->UART_Mode;
\r
152 /* Enable or disable the FIFOs */
\r
153 /* Set the FIFOs Levels */
\r
154 if(UART_InitStruct->UART_FIFO == UART_FIFO_Enable)
\r
156 /* Enable the FIFOs */
\r
157 UARTx->LCR |= UART_FIFO_Enable;
\r
159 /* Clear TXIFLSEL and RXIFLSEL bits */
\r
160 UARTx->IFLS &= UART_TxRxFIFOLevel_Mask;
\r
162 /* Set RXIFLSEL bits according to UART_RxFIFOLevel value */
\r
163 UARTx->IFLS |= (UART_InitStruct->UART_RxFIFOLevel << 3);
\r
165 /* Set TXIFLSEL bits according to UART_TxFIFOLevel value */
\r
166 UARTx->IFLS |= UART_InitStruct->UART_TxFIFOLevel;
\r
170 /* Disable the FIFOs */
\r
171 UARTx->LCR &= UART_FIFO_Disable;
\r
175 /*******************************************************************************
\r
176 * Function Name : UART_StructInit
\r
177 * Description : Fills each UART_InitStruct member with its reset value.
\r
178 * Input : UART_InitStruct: pointer to a UART_InitTypeDef structure which
\r
179 * will be initialized.
\r
182 *******************************************************************************/
\r
183 void UART_StructInit(UART_InitTypeDef* UART_InitStruct)
\r
185 /* Reset the UART_InitStruct members */
\r
186 UART_InitStruct->UART_WordLength = UART_WordLength_8D;
\r
187 UART_InitStruct->UART_StopBits = UART_StopBits_1;
\r
188 UART_InitStruct->UART_Parity = UART_Parity_Odd ;
\r
189 UART_InitStruct->UART_BaudRate = 9600;
\r
190 UART_InitStruct->UART_HardwareFlowControl = UART_HardwareFlowControl_None;
\r
191 UART_InitStruct->UART_Mode = UART_Mode_Tx_Rx;
\r
192 UART_InitStruct->UART_FIFO = UART_FIFO_Enable;
\r
193 UART_InitStruct->UART_TxFIFOLevel = UART_FIFOLevel_1_2;
\r
194 UART_InitStruct->UART_RxFIFOLevel = UART_FIFOLevel_1_2;
\r
197 /*******************************************************************************
\r
198 * Function Name : UART_Cmd
\r
199 * Description : Enables or disables the specified UART peripheral.
\r
200 * Input : - UARTx: where x can be 0,1 or 2 to select the UART peripheral
\r
201 * - NewState: new state of the UARTx peripheral.
\r
202 * This parameter can be: ENABLE or DISABLE.
\r
205 *******************************************************************************/
\r
206 void UART_Cmd(UART_TypeDef* UARTx, FunctionalState NewState)
\r
208 if (NewState == ENABLE)
\r
210 /* Enable the selected UART by setting the UARTEN bit in the CR register */
\r
211 UARTx->CR |= UART_Enable_Mask;
\r
215 /* Disable the selected UART by clearing the UARTEN bit in the CR register */
\r
216 UARTx->CR &= UART_Disable_Mask;
\r
220 /*******************************************************************************
\r
221 * Function Name : UART_ITConfig
\r
222 * Description : Enables or disables the specified UART interrupts.
\r
223 * Input : - UARTx: where x can be 0,1 or 2 to select the UART peripheral
\r
224 * - UART_IT: specifies the UART interrupts sources to be
\r
225 * enabled or disabled. This parameter can be any combination
\r
226 * of the following values:
\r
227 * - UART_IT_OverrunError: Overrun Error interrupt
\r
228 * - UART_IT_BreakError: Break Error interrupt
\r
229 * - UART_IT_ParityError: Parity Error interrupt
\r
230 * - UART_IT_FrameError: Frame Error interrupt
\r
231 * - UART_IT_ReceiveTimeOut: Receive Time Out interrupt
\r
232 * - UART_IT_Transmit: Transmit interrupt
\r
233 * - UART_IT_Receive: Receive interrupt
\r
234 * - UART_IT_DSR: DSR interrupt
\r
235 * - UART_IT_DCD: DCD interrupt
\r
236 * - UART_IT_CTS: CTS interrupt
\r
237 * - UART_IT_RI: RI interrupt
\r
238 * - NewState: new state of the UARTx peripheral.
\r
239 * This parameter can be: ENABLE or DISABLE.
\r
242 *******************************************************************************/
\r
243 void UART_ITConfig(UART_TypeDef* UARTx, u16 UART_IT, FunctionalState NewState)
\r
245 if(NewState == ENABLE)
\r
247 /* Enables the selected interrupts */
\r
248 UARTx->IMSC |= UART_IT;
\r
252 /* Disables the selected interrupts */
\r
253 UARTx->IMSC &= ~UART_IT;
\r
257 /*******************************************************************************
\r
258 * Function Name : UART_DMAConfig
\r
259 * Description : Configures the UARTx
\92s DMA interface.
\r
260 * Input : - UARTx: where x can be 1 or 2 to select the UART peripheral
\r
261 * - UART_DMAOnError: specifies the DMA on error request.
\r
262 * This parameter can be:
\r
263 * - UART_DMAOnError_Enable: DMA receive request enabled
\r
264 * when the UART error interrupt is asserted.
\r
265 * - UART_DMAOnError_Disable: DMA receive request disabled
\r
266 * when the UART error interrupt is asserted.
\r
269 *******************************************************************************/
\r
270 void UART_DMAConfig(UART_TypeDef* UARTx, u16 UART_DMAOnError)
\r
272 if(UART_DMAOnError == UART_DMAOnError_Enable)
\r
274 UARTx->DMACR &= UART_DMAOnError_Enable;
\r
278 UARTx->DMACR |= UART_DMAOnError_Disable;
\r
282 /*******************************************************************************
\r
283 * Function Name : UART_DMACmd
\r
284 * Description : Enables or disables the UARTx
\92s DMA interface.
\r
285 * Input : - UARTx: where x can be 1 or 2 to select the UART peripheral
\r
286 * - UART_DMAReq: enables or disables the request of DMA from UART.
\r
287 * This parameter can be:
\r
288 * - UART_DMAReq_Tx: Transmit DMA Enable
\r
289 * - UART_DMAReq_Rx: Receive DMA Enable
\r
290 * - NewState: new state of the UARTx peripheral.
\r
291 * This parameter can be: ENABLE or DISABLE.
\r
294 *******************************************************************************/
\r
295 void UART_DMACmd(UART_TypeDef* UARTx, u8 UART_DMAReq, FunctionalState NewState)
\r
297 if(UART_DMAReq == UART_DMAReq_Tx)
\r
299 if(NewState == ENABLE)
\r
301 UARTx->DMACR |= UART_DMAReq_Tx;
\r
305 UARTx->DMACR &= ~UART_DMAReq_Tx;
\r
309 if(UART_DMAReq == UART_DMAReq_Rx)
\r
311 if(NewState == ENABLE)
\r
313 UARTx->DMACR |= UART_DMAReq_Rx;
\r
317 UARTx->DMACR &= ~UART_DMAReq_Rx;
\r
322 /*******************************************************************************
\r
323 * Function Name : UART_LoopBackConfig
\r
324 * Description : Enables or disables the LoopBack mode.
\r
325 * Input : - UARTx: where x can be 0,1 or 2 to select the UART peripheral
\r
326 * - NewState: new state of the UARTx peripheral.
\r
327 * This parameter can be: ENABLE or DISABLE.
\r
330 *******************************************************************************/
\r
331 void UART_LoopBackConfig(UART_TypeDef* UARTx, FunctionalState NewState)
\r
333 if (NewState == ENABLE)
\r
335 /* Enable the LoopBack mode of the specified UART */
\r
336 UARTx->CR |= UART_LoopBack_Enable_Mask;
\r
340 /* Disable the LoopBack mode of the specified UART */
\r
341 UARTx->CR &= UART_LoopBack_Disable_Mask;
\r
345 /*******************************************************************************
\r
346 * Function Name : UART_GetFlagStatus
\r
347 * Description : Checks whether the specified UART flag is set or not.
\r
348 * Input : - UARTx: where x can be 0,1 or 2 to select the UART peripheral
\r
349 * - UART_FLAG: specifies the flag to check.
\r
350 * This parameter can be one of the following values:
\r
351 * - UART_FLAG_OverrunError: Overrun error flag
\r
352 * - UART_FLAG_Break: break error flag
\r
353 * - UART_FLAG_ParityError: parity error flag
\r
354 * - UART_FLAG_FrameError: frame error flag
\r
355 * - UART_FLAG_RI: RI flag
\r
356 * - UART_FLAG_TxFIFOEmpty: Transmit FIFO Empty flag
\r
357 * - UART_FLAG_RxFIFOFull: Receive FIFO Full flag
\r
358 * - UART_FLAG_TxFIFOFull: Transmit FIFO Full flag
\r
359 * - UART_FLAG_RxFIFOEmpty: Receive FIFO Empty flag
\r
360 * - UART_FLAG_Busy: UART Busy flag
\r
361 * - UART_FLAG_CTS: CTS flag
\r
362 * - UART_FLAG_DCD: DCD flag
\r
363 * - UART_FLAG_DSR: DSR flag
\r
364 * - UART_RawIT_OverrunError: Overrun Error interrupt flag
\r
365 * - UART_RawIT_BreakError: Break Error interrupt flag
\r
366 * - UART_RawIT_ParityError: Parity Error interrupt flag
\r
367 * - UART_RawIT_FrameError: Frame Error interrupt flag
\r
368 * - UART_RawIT_ReceiveTimeOut: ReceiveTimeOut interrupt flag
\r
369 * - UART_RawIT_Transmit: Transmit interrupt flag
\r
370 * - UART_RawIT_Receive: Receive interrupt flag
\r
371 * - UART_RawIT_DSR: DSR interrupt flag
\r
372 * - UART_RawIT_DCD: DCD interrupt flag
\r
373 * - UART_RawIT_CTS: CTS interrupt flag
\r
374 * - UART_RawIT_RI: RI interrupt flag
\r
376 * Return : The new state of UART_FLAG (SET or RESET).
\r
377 *******************************************************************************/
\r
378 FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, u16 UART_FLAG)
\r
381 u32 UARTReg = 0, FlagPos = 0;
\r
384 /* Get the UART register index */
\r
385 UARTReg = UART_FLAG >> 5;
\r
387 /* Get the flag position */
\r
388 FlagPos = UART_FLAG & UART_FLAG_Mask;
\r
390 if(UARTReg == 1) /* The flag to check is in RSR register */
\r
392 StatusReg = UARTx->RSECR;
\r
394 else if (UARTReg == 2) /* The flag to check is in FR register */
\r
396 StatusReg = UARTx->FR;
\r
398 else if(UARTReg == 3) /* The flag to check is in RIS register */
\r
400 StatusReg = UARTx->RIS;
\r
403 if((StatusReg & (1 << FlagPos))!= RESET)
\r
413 /*******************************************************************************
\r
414 * Function Name : UART_ClearFlag
\r
415 * Description : Clears the UARTx
\92s flags(Frame, Parity, Break, Overrun error).
\r
416 * Input : - UARTx: where x can be 0,1or 2 to select the UART peripheral.
\r
419 *******************************************************************************/
\r
420 void UART_ClearFlag(UART_TypeDef* UARTx)
\r
422 /* Clear the flag */
\r
423 UARTx->RSECR = UART_ClearFlag_Mask;
\r
426 /*******************************************************************************
\r
427 * Function Name : UART_GetITStatus
\r
428 * Description : Checks whether the specified UART interrupt has occured or not.
\r
429 * Input : - UARTx: where x can be 0,1or 2 to select the UART peripheral.
\r
430 * - UART_IT: specifies the interrupt pending bit to be checked.
\r
431 * This parameter can be one of the following values:
\r
432 * - UART_IT_OverrunError: Overrun Error interrupt
\r
433 * - UART_IT_BreakError: Break Error interrupt
\r
434 * - UART_IT_ParityError: Parity Error interrupt
\r
435 * - UART_IT_FrameError: Frame Error interrupt
\r
436 * - UART_IT_ReceiveTimeOut: Receive Time Out interrupt
\r
437 * - UART_IT_Transmit: Transmit interrupt
\r
438 * - UART_IT_Receive: Receive interrupt
\r
439 * - UART_IT_DSR: DSR interrupt
\r
440 * - UART_IT_DCD: DCD interrupt
\r
441 * - UART_IT_CTS: CTS interrupt
\r
442 * - UART_IT_RI: RI interrupt
\r
444 * Return : The new state of UART_IT (SET or RESET).
\r
445 *******************************************************************************/
\r
446 ITStatus UART_GetITStatus(UART_TypeDef* UARTx, u16 UART_IT)
\r
448 if((UARTx->MIS & UART_IT) != RESET)
\r
458 /*******************************************************************************
\r
459 * Function Name : UART_ClearITPendingBit
\r
460 * Description : Clears the UARTx
\92s interrupt pending bits.
\r
461 * Input : - UARTx: where x can be 0,1or 2 to select the UART peripheral.
\r
462 * - UART_IT: specifies the interrupt pending bit to clear.
\r
463 * More than one interrupt can be cleared using the
\93|
\94 operator.
\r
464 * This parameter can be:
\r
465 * - UART_IT_OverrunError: Overrun Error interrupt
\r
466 * - UART_IT_BreakError: Break Error interrupt
\r
467 * - UART_IT_ParityError: Parity Error interrupt
\r
468 * - UART_IT_FrameError: Frame Error interrupt
\r
469 * - UART_IT_ReceiveTimeOut: Receive Time Out interrupt
\r
470 * - UART_IT_Transmit: Transmit interrupt
\r
471 * - UART_IT_Receive: Receive interrupt
\r
472 * - UART_IT_DSR: DSR interrupt
\r
473 * - UART_IT_DCD: DCD interrupt
\r
474 * - UART_IT_CTS: CTS interrupt
\r
475 * - UART_IT_RI: RI interrupt
\r
478 *******************************************************************************/
\r
479 void UART_ClearITPendingBit(UART_TypeDef* UARTx, u16 UART_IT)
\r
481 /* Clear the specified interrupt */
\r
482 UARTx->ICR &= UART_IT;
\r
485 /*******************************************************************************
\r
486 * Function Name : UART_IrDALowPowerConfig
\r
487 * Description : Sets the IrDA low power mode
\r
488 * Input : - IrDAx: where x can be 0,1 or 2 to select the UART/IrDA peripheral.
\r
489 * - NewState: new state of the UARTIrDA peripheral.
\r
490 * This parameter can be: ENABLE or DISABLE.
\r
493 *******************************************************************************/
\r
494 void UART_IrDALowPowerConfig(u8 IrDAx, FunctionalState NewState)
\r
496 UART_TypeDef* UARTx;
\r
500 case IrDA0: UARTx = UART0;
\r
502 case IrDA1: UARTx = UART1;
\r
504 case IrDA2: UARTx = UART2;
\r
508 if (NewState == ENABLE)
\r
510 UARTx->CR |= IrDA_LowPower_Enable_Mask;
\r
514 UARTx->CR &= IrDA_LowPower_Disable_Mask;
\r
518 /*******************************************************************************
\r
519 * Function Name : UART_IrDASetCounter
\r
520 * Description : Sets the IrDA counter divisor value.
\r
521 * Input : - UARTx: where x can be 0,1 or 2 to select the UART/IrDA peripheral.
\r
522 * - IrDA_Counter: IrDA counter divisor new value n low power mode(Hz).
\r
525 *******************************************************************************/
\r
526 void UART_IrDASetCounter(u8 IrDAx, u32 IrDA_Counter)
\r
528 UART_TypeDef* UARTx;
\r
532 case IrDA0: UARTx = UART0;
\r
534 case IrDA1: UARTx = UART1;
\r
536 case IrDA2: UARTx = UART2;
\r
539 /* Get the APB frequency */
\r
540 APBClock = (SCU_GetPCLKFreqValue())*1000;
\r
541 /* Determine the Counter Divisor part */
\r
542 UARTx->ILPR = (((APBClock*10) / ( IrDA_Counter)) + 5 )/10;
\r
545 /*******************************************************************************
\r
546 * Function Name : UART_IrDACmd
\r
547 * Description : Enables or disables the UARTx
\92s IrDA interface.
\r
548 * Input : - IrDAx: where x can be 0,1 or 2 to select the UART/IrDA peripheral
\r
549 * - NewState: new state of the UARTx peripheral.
\r
550 * This parameter can be: ENABLE or DISABLE.
\r
553 *******************************************************************************/
\r
554 void UART_IrDACmd(u8 IrDAx, FunctionalState NewState)
\r
556 UART_TypeDef* UARTx;
\r
560 case IrDA0: UARTx = UART0;
\r
562 case IrDA1: UARTx = UART1;
\r
564 case IrDA2: UARTx = UART2;
\r
567 if(NewState == ENABLE)
\r
569 /* Enable the IrDA mode of the specified UART */
\r
570 UARTx->CR |= UART_IrDA_Enable_Mask;
\r
574 /* Disable the IrDA mode of the specified UART */
\r
575 UARTx->CR &= UART_IrDA_Disable_Mask;
\r
579 /*******************************************************************************
\r
580 * Function Name : UART_SendData
\r
581 * Description : Transmits signle Byte of data through the UARTx peripheral.
\r
582 * Input : - UARTx: where x can be 0,1 or 2 to select the UART peripheral.
\r
583 * - Data: the byte to transmit
\r
586 *******************************************************************************/
\r
587 void UART_SendData(UART_TypeDef* UARTx, u8 Data)
\r
589 /* Transmit one byte */
\r
593 /*******************************************************************************
\r
594 * Function Name : UART_ReceiveData
\r
595 * Description : Returns the most recent received Byte by the UARTx peripheral.
\r
596 * Input : UARTx: where x can be 0,1 or 2 to select the UART peripheral.
\r
598 * Return : The received data
\r
599 *******************************************************************************/
\r
600 u8 UART_ReceiveData(UART_TypeDef* UARTx)
\r
602 /* Receive one byte */
\r
603 return ((u8)UARTx->DR);
\r
606 /*******************************************************************************
\r
607 * Function Name : UART_SendBreak
\r
608 * Description : Transmits break characters.
\r
609 * Input : UARTx: where x can be 0,1 or 2 to select the UART peripheral.
\r
612 *******************************************************************************/
\r
613 void UART_SendBreak(UART_TypeDef* UARTx)
\r
615 /* Send break characters */
\r
616 UARTx->LCR |= UART_BreakChar_Mask;
\r
619 /*******************************************************************************
\r
620 * Function Name : UART_RTSConfig
\r
621 * Description : Sets or Resets the RTS signal
\r
622 * Input : - LevelState: new state of the RTS signal for UART0 only.
\r
623 * This parameter can be: LowLevel or HighLevel
\r
626 *******************************************************************************/
\r
627 void UART_RTSConfig(UART_LevelTypeDef LevelState)
\r
629 if(LevelState == LowLevel)
\r
631 UART0->CR |= UART_RTS_LowLevel_Mask;
\r
635 UART0->CR &= UART_RTS_HighLevel_Mask;
\r
639 /*******************************************************************************
\r
640 * Function Name : UART_DTRConfig
\r
641 * Description : Sets or Resets the DTR signal for UART0 only
\r
642 * Input : - LevelState: new state of the DTR signal.
\r
643 * This parameter can be: LowLevel or HighLevel
\r
646 *******************************************************************************/
\r
647 void UART_DTRConfig(UART_LevelTypeDef LevelState)
\r
649 if(LevelState == LowLevel)
\r
651 UART0->CR |= UART_DTR_LowLevel_Mask;
\r
655 UART0->CR &= UART_DTR_HighLevel_Mask;
\r
658 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
\r