1 //*****************************************************************************
2 //
3 // uart.c - Driver for the UART.
4 //
5 // Copyright (c) 2005-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 //*****************************************************************************
41 //
42 //! \addtogroup uart_api
43 //! @{
44 //
45 //*****************************************************************************
46 
47 #include "inc/hw_ints.h"
48 #include "inc/hw_memmap.h"
49 #include "inc/hw_sysctl.h"
50 #include "inc/hw_types.h"
51 #include "inc/hw_uart.h"
52 #include "driverlib/debug.h"
53 #include "driverlib/interrupt.h"
54 #include "driverlib/uart.h"
55 
56 //*****************************************************************************
57 //
58 // The system clock divider defining the maximum baud rate supported by the
59 // UART.
60 //
61 //*****************************************************************************
62 #define UART_CLK_DIVIDER        ((CLASS_IS_SANDSTORM ||                       \
63                                   (CLASS_IS_FURY && REVISION_IS_A2) ||        \
64                                   (CLASS_IS_DUSTDEVIL && REVISION_IS_A0)) ?   \
65                                  16 : 8)
66 
67 //*****************************************************************************
68 //
69 // A mapping of UART base address to interupt number.
70 //
71 //*****************************************************************************
72 static const unsigned long g_ppulUARTIntMap[][2] =
73 {
74     { UART0_BASE, INT_UART0 },
75     { UART1_BASE, INT_UART1 },
76     { UART2_BASE, INT_UART2 },
77     { UART3_BASE, INT_UART3 },
78     { UART4_BASE, INT_UART4 },
79     { UART5_BASE, INT_UART5 },
80     { UART6_BASE, INT_UART6 },
81     { UART7_BASE, INT_UART7 },
82 };
83 
84 //*****************************************************************************
85 //
86 //! \internal
87 //! Checks a UART base address.
88 //!
89 //! \param ulBase is the base address of the UART port.
90 //!
91 //! This function determines if a UART port base address is valid.
92 //!
93 //! \return Returns \b true if the base address is valid and \b false
94 //! otherwise.
95 //
96 //*****************************************************************************
97 #ifdef DEBUG
98 static tBoolean
UARTBaseValid(unsigned long ulBase)99 UARTBaseValid(unsigned long ulBase)
100 {
101     return((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
102            (ulBase == UART2_BASE) || (ulBase == UART3_BASE) ||
103            (ulBase == UART4_BASE) || (ulBase == UART5_BASE) ||
104            (ulBase == UART6_BASE) || (ulBase == UART7_BASE));
105 }
106 #endif
107 
108 //*****************************************************************************
109 //
110 //! \internal
111 //! Gets the UART interrupt number.
112 //!
113 //! \param ulBase is the base address of the UART port.
114 //!
115 //! Given a UART base address, this function returns the corresponding
116 //! interrupt number.
117 //!
118 //! \return Returns a UART interrupt number, or -1 if \e ulBase is invalid.
119 //
120 //*****************************************************************************
121 static long
UARTIntNumberGet(unsigned long ulBase)122 UARTIntNumberGet(unsigned long ulBase)
123 {
124     unsigned long ulIdx;
125 
126     //
127     // Loop through the table that maps UART base addresses to interrupt
128     // numbers.
129     //
130     for(ulIdx = 0; ulIdx < (sizeof(g_ppulUARTIntMap) /
131                             sizeof(g_ppulUARTIntMap[0])); ulIdx++)
132     {
133         //
134         // See if this base address matches.
135         //
136         if(g_ppulUARTIntMap[ulIdx][0] == ulBase)
137         {
138             //
139             // Return the corresponding interrupt number.
140             //
141             return(g_ppulUARTIntMap[ulIdx][1]);
142         }
143     }
144 
145     //
146     // The base address could not be found, so return an error.
147     //
148     return(-1);
149 }
150 
151 //*****************************************************************************
152 //
153 //! Sets the type of parity.
154 //!
155 //! \param ulBase is the base address of the UART port.
156 //! \param ulParity specifies the type of parity to use.
157 //!
158 //! This function configures the type of parity to use for transmitting and
159 //! expect when receiving.  The \e ulParity parameter must be one of
160 //! \b UART_CONFIG_PAR_NONE, \b UART_CONFIG_PAR_EVEN, \b UART_CONFIG_PAR_ODD,
161 //! \b UART_CONFIG_PAR_ONE, or \b UART_CONFIG_PAR_ZERO.  The last two
162 //! parameters allow direct control of the parity bit; it is always either one
163 //! or zero based on the mode.
164 //!
165 //! \return None.
166 //
167 //*****************************************************************************
168 void
UARTParityModeSet(unsigned long ulBase,unsigned long ulParity)169 UARTParityModeSet(unsigned long ulBase, unsigned long ulParity)
170 {
171     //
172     // Check the arguments.
173     //
174     ASSERT(UARTBaseValid(ulBase));
175     ASSERT((ulParity == UART_CONFIG_PAR_NONE) ||
176            (ulParity == UART_CONFIG_PAR_EVEN) ||
177            (ulParity == UART_CONFIG_PAR_ODD) ||
178            (ulParity == UART_CONFIG_PAR_ONE) ||
179            (ulParity == UART_CONFIG_PAR_ZERO));
180 
181     //
182     // Set the parity mode.
183     //
184     HWREG(ulBase + UART_O_LCRH) = ((HWREG(ulBase + UART_O_LCRH) &
185                                     ~(UART_LCRH_SPS | UART_LCRH_EPS |
186                                       UART_LCRH_PEN)) | ulParity);
187 }
188 
189 //*****************************************************************************
190 //
191 //! Gets the type of parity currently being used.
192 //!
193 //! \param ulBase is the base address of the UART port.
194 //!
195 //! This function gets the type of parity used for transmitting data and
196 //! expected when receiving data.
197 //!
198 //! \return Returns the current parity settings, specified as one of
199 //! \b UART_CONFIG_PAR_NONE, \b UART_CONFIG_PAR_EVEN, \b UART_CONFIG_PAR_ODD,
200 //! \b UART_CONFIG_PAR_ONE, or \b UART_CONFIG_PAR_ZERO.
201 //
202 //*****************************************************************************
203 unsigned long
UARTParityModeGet(unsigned long ulBase)204 UARTParityModeGet(unsigned long ulBase)
205 {
206     //
207     // Check the arguments.
208     //
209     ASSERT(UARTBaseValid(ulBase));
210 
211     //
212     // Return the current parity setting.
213     //
214     return(HWREG(ulBase + UART_O_LCRH) &
215            (UART_LCRH_SPS | UART_LCRH_EPS | UART_LCRH_PEN));
216 }
217 
218 //*****************************************************************************
219 //
220 //! Sets the FIFO level at which interrupts are generated.
221 //!
222 //! \param ulBase is the base address of the UART port.
223 //! \param ulTxLevel is the transmit FIFO interrupt level, specified as one of
224 //! \b UART_FIFO_TX1_8, \b UART_FIFO_TX2_8, \b UART_FIFO_TX4_8,
225 //! \b UART_FIFO_TX6_8, or \b UART_FIFO_TX7_8.
226 //! \param ulRxLevel is the receive FIFO interrupt level, specified as one of
227 //! \b UART_FIFO_RX1_8, \b UART_FIFO_RX2_8, \b UART_FIFO_RX4_8,
228 //! \b UART_FIFO_RX6_8, or \b UART_FIFO_RX7_8.
229 //!
230 //! This function configures the FIFO level at which transmit and receive
231 //! interrupts are generated.
232 //!
233 //! \return None.
234 //
235 //*****************************************************************************
236 void
UARTFIFOLevelSet(unsigned long ulBase,unsigned long ulTxLevel,unsigned long ulRxLevel)237 UARTFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel,
238                  unsigned long ulRxLevel)
239 {
240     //
241     // Check the arguments.
242     //
243     ASSERT(UARTBaseValid(ulBase));
244     ASSERT((ulTxLevel == UART_FIFO_TX1_8) ||
245            (ulTxLevel == UART_FIFO_TX2_8) ||
246            (ulTxLevel == UART_FIFO_TX4_8) ||
247            (ulTxLevel == UART_FIFO_TX6_8) ||
248            (ulTxLevel == UART_FIFO_TX7_8));
249     ASSERT((ulRxLevel == UART_FIFO_RX1_8) ||
250            (ulRxLevel == UART_FIFO_RX2_8) ||
251            (ulRxLevel == UART_FIFO_RX4_8) ||
252            (ulRxLevel == UART_FIFO_RX6_8) ||
253            (ulRxLevel == UART_FIFO_RX7_8));
254 
255     //
256     // Set the FIFO interrupt levels.
257     //
258     HWREG(ulBase + UART_O_IFLS) = ulTxLevel | ulRxLevel;
259 }
260 
261 //*****************************************************************************
262 //
263 //! Gets the FIFO level at which interrupts are generated.
264 //!
265 //! \param ulBase is the base address of the UART port.
266 //! \param pulTxLevel is a pointer to storage for the transmit FIFO level,
267 //! returned as one of \b UART_FIFO_TX1_8, \b UART_FIFO_TX2_8,
268 //! \b UART_FIFO_TX4_8, \b UART_FIFO_TX6_8, or \b UART_FIFO_TX7_8.
269 //! \param pulRxLevel is a pointer to storage for the receive FIFO level,
270 //! returned as one of \b UART_FIFO_RX1_8, \b UART_FIFO_RX2_8,
271 //! \b UART_FIFO_RX4_8, \b UART_FIFO_RX6_8, or \b UART_FIFO_RX7_8.
272 //!
273 //! This function gets the FIFO level at which transmit and receive interrupts
274 //! are generated.
275 //!
276 //! \return None.
277 //
278 //*****************************************************************************
279 void
UARTFIFOLevelGet(unsigned long ulBase,unsigned long * pulTxLevel,unsigned long * pulRxLevel)280 UARTFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel,
281                  unsigned long *pulRxLevel)
282 {
283     unsigned long ulTemp;
284 
285     //
286     // Check the arguments.
287     //
288     ASSERT(UARTBaseValid(ulBase));
289 
290     //
291     // Read the FIFO level register.
292     //
293     ulTemp = HWREG(ulBase + UART_O_IFLS);
294 
295     //
296     // Extract the transmit and receive FIFO levels.
297     //
298     *pulTxLevel = ulTemp & UART_IFLS_TX_M;
299     *pulRxLevel = ulTemp & UART_IFLS_RX_M;
300 }
301 
302 //*****************************************************************************
303 //
304 //! Sets the configuration of a UART.
305 //!
306 //! \param ulBase is the base address of the UART port.
307 //! \param ulUARTClk is the rate of the clock supplied to the UART module.
308 //! \param ulBaud is the desired baud rate.
309 //! \param ulConfig is the data format for the port (number of data bits,
310 //! number of stop bits, and parity).
311 //!
312 //! This function configures the UART for operation in the specified data
313 //! format.  The baud rate is provided in the \e ulBaud parameter and the data
314 //! format in the \e ulConfig parameter.
315 //!
316 //! The \e ulConfig parameter is the logical OR of three values: the number of
317 //! data bits, the number of stop bits, and the parity.  \b UART_CONFIG_WLEN_8,
318 //! \b UART_CONFIG_WLEN_7, \b UART_CONFIG_WLEN_6, and \b UART_CONFIG_WLEN_5
319 //! select from eight to five data bits per byte (respectively).
320 //! \b UART_CONFIG_STOP_ONE and \b UART_CONFIG_STOP_TWO select one or two stop
321 //! bits (respectively).  \b UART_CONFIG_PAR_NONE, \b UART_CONFIG_PAR_EVEN,
322 //! \b UART_CONFIG_PAR_ODD, \b UART_CONFIG_PAR_ONE, and \b UART_CONFIG_PAR_ZERO
323 //! select the parity mode (no parity bit, even parity bit, odd parity bit,
324 //! parity bit always one, and parity bit always zero, respectively).
325 //!
326 //! The peripheral clock is the same as the processor clock.  The frequency of
327 //! the system clock is the value returned by SysCtlClockGet(), or it can be
328 //! explicitly hard coded if it is constant and known (to save the
329 //! code/execution overhead of a call to SysCtlClockGet()).
330 //!
331 //! For Stellaris parts that have the ability to specify the UART baud clock
332 //! source (via UARTClockSourceSet()), the peripheral clock can be changed to
333 //! PIOSC.  In this case, the peripheral clock should be specified as
334 //! 16,000,000 (the nominal rate of PIOSC).
335 //!
336 //! This function replaces the original UARTConfigSet() API and performs the
337 //! same actions.  A macro is provided in <tt>uart.h</tt> to map the original
338 //! API to this API.
339 //!
340 //! \return None.
341 //
342 //*****************************************************************************
343 void
UARTConfigSetExpClk(unsigned long ulBase,unsigned long ulUARTClk,unsigned long ulBaud,unsigned long ulConfig)344 UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk,
345                     unsigned long ulBaud, unsigned long ulConfig)
346 {
347     unsigned long ulDiv;
348 
349     //
350     // Check the arguments.
351     //
352     ASSERT(UARTBaseValid(ulBase));
353     ASSERT(ulBaud != 0);
354     ASSERT(ulUARTClk >= (ulBaud * UART_CLK_DIVIDER));
355 
356     //
357     // Stop the UART.
358     //
359     UARTDisable(ulBase);
360 
361     //
362     // Is the required baud rate greater than the maximum rate supported
363     // without the use of high speed mode?
364     //
365     if((ulBaud * 16) > ulUARTClk)
366     {
367         //
368         // Enable high speed mode.
369         //
370         HWREG(ulBase + UART_O_CTL) |= UART_CTL_HSE;
371 
372         //
373         // Half the supplied baud rate to compensate for enabling high speed
374         // mode.  This allows the following code to be common to both cases.
375         //
376         ulBaud /= 2;
377     }
378     else
379     {
380         //
381         // Disable high speed mode.
382         //
383         HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_HSE);
384     }
385 
386     //
387     // Compute the fractional baud rate divider.
388     //
389     ulDiv = (((ulUARTClk * 8) / ulBaud) + 1) / 2;
390 
391     //
392     // Set the baud rate.
393     //
394     HWREG(ulBase + UART_O_IBRD) = ulDiv / 64;
395     HWREG(ulBase + UART_O_FBRD) = ulDiv % 64;
396 
397     //
398     // Set parity, data length, and number of stop bits.
399     //
400     HWREG(ulBase + UART_O_LCRH) = ulConfig;
401 
402     //
403     // Clear the flags register.
404     //
405     HWREG(ulBase + UART_O_FR) = 0;
406 
407     //
408     // Start the UART.
409     //
410     UARTEnable(ulBase);
411 }
412 
413 //*****************************************************************************
414 //
415 //! Gets the current configuration of a UART.
416 //!
417 //! \param ulBase is the base address of the UART port.
418 //! \param ulUARTClk is the rate of the clock supplied to the UART module.
419 //! \param pulBaud is a pointer to storage for the baud rate.
420 //! \param pulConfig is a pointer to storage for the data format.
421 //!
422 //! This function determines the baud rate and data format for the UART, given
423 //! an explicitly provided peripheral clock (hence the ExpClk suffix).  The
424 //! returned baud rate is the actual baud rate; it may not be the exact baud
425 //! rate requested or an ``official'' baud rate.  The data format returned in
426 //! \e pulConfig is enumerated the same as the \e ulConfig parameter of
427 //! UARTConfigSetExpClk().
428 //!
429 //! The peripheral clock is the same as the processor clock.  The frequency of
430 //! the system clock is the value returned by SysCtlClockGet(), or it can be
431 //! explicitly hard coded if it is constant and known (to save the
432 //! code/execution overhead of a call to SysCtlClockGet()).
433 //!
434 //! For Stellaris parts that have the ability to specify the UART baud clock
435 //! source (via UARTClockSourceSet()), the peripheral clock can be changed to
436 //! PIOSC.  In this case, the peripheral clock should be specified as
437 //! 16,000,000 (the nominal rate of PIOSC).
438 //!
439 //! This function replaces the original UARTConfigGet() API and performs the
440 //! same actions.  A macro is provided in <tt>uart.h</tt> to map the original
441 //! API to this API.
442 //!
443 //! \return None.
444 //
445 //*****************************************************************************
446 void
UARTConfigGetExpClk(unsigned long ulBase,unsigned long ulUARTClk,unsigned long * pulBaud,unsigned long * pulConfig)447 UARTConfigGetExpClk(unsigned long ulBase, unsigned long ulUARTClk,
448                     unsigned long *pulBaud, unsigned long *pulConfig)
449 {
450     unsigned long ulInt, ulFrac;
451 
452     //
453     // Check the arguments.
454     //
455     ASSERT(UARTBaseValid(ulBase));
456 
457     //
458     // Compute the baud rate.
459     //
460     ulInt = HWREG(ulBase + UART_O_IBRD);
461     ulFrac = HWREG(ulBase + UART_O_FBRD);
462     *pulBaud = (ulUARTClk * 4) / ((64 * ulInt) + ulFrac);
463 
464     //
465     // See if high speed mode enabled.
466     //
467     if(HWREG(ulBase + UART_O_CTL) & UART_CTL_HSE)
468     {
469         //
470         // High speed mode is enabled so the actual baud rate is actually
471         // double what was just calculated.
472         //
473         *pulBaud *= 2;
474     }
475 
476     //
477     // Get the parity, data length, and number of stop bits.
478     //
479     *pulConfig = (HWREG(ulBase + UART_O_LCRH) &
480                   (UART_LCRH_SPS | UART_LCRH_WLEN_M | UART_LCRH_STP2 |
481                    UART_LCRH_EPS | UART_LCRH_PEN));
482 }
483 
484 //*****************************************************************************
485 //
486 //! Enables transmitting and receiving.
487 //!
488 //! \param ulBase is the base address of the UART port.
489 //!
490 //! This function sets the UARTEN, TXE, and RXE bits and enables the transmit
491 //! and receive FIFOs.
492 //!
493 //! \return None.
494 //
495 //*****************************************************************************
496 void
UARTEnable(unsigned long ulBase)497 UARTEnable(unsigned long ulBase)
498 {
499     //
500     // Check the arguments.
501     //
502     ASSERT(UARTBaseValid(ulBase));
503 
504     //
505     // Enable the FIFO.
506     //
507     HWREG(ulBase + UART_O_LCRH) |= UART_LCRH_FEN;
508 
509     //
510     // Enable RX, TX, and the UART.
511     //
512     HWREG(ulBase + UART_O_CTL) |= (UART_CTL_UARTEN | UART_CTL_TXE |
513                                    UART_CTL_RXE);
514 }
515 
516 //*****************************************************************************
517 //
518 //! Disables transmitting and receiving.
519 //!
520 //! \param ulBase is the base address of the UART port.
521 //!
522 //! This function clears the UARTEN, TXE, and RXE bits, waits for the end of
523 //! transmission of the current character, and flushes the transmit FIFO.
524 //!
525 //! \return None.
526 //
527 //*****************************************************************************
528 void
UARTDisable(unsigned long ulBase)529 UARTDisable(unsigned long ulBase)
530 {
531     //
532     // Check the arguments.
533     //
534     ASSERT(UARTBaseValid(ulBase));
535 
536     //
537     // Wait for end of TX.
538     //
539     while(HWREG(ulBase + UART_O_FR) & UART_FR_BUSY)
540     {
541     }
542 
543     //
544     // Disable the FIFO.
545     //
546     HWREG(ulBase + UART_O_LCRH) &= ~(UART_LCRH_FEN);
547 
548     //
549     // Disable the UART.
550     //
551     HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_UARTEN | UART_CTL_TXE |
552                                     UART_CTL_RXE);
553 }
554 
555 //*****************************************************************************
556 //
557 //! Enables the transmit and receive FIFOs.
558 //!
559 //! \param ulBase is the base address of the UART port.
560 //!
561 //! This functions enables the transmit and receive FIFOs in the UART.
562 //!
563 //! \return None.
564 //
565 //*****************************************************************************
566 void
UARTFIFOEnable(unsigned long ulBase)567 UARTFIFOEnable(unsigned long ulBase)
568 {
569     //
570     // Check the arguments.
571     //
572     ASSERT(UARTBaseValid(ulBase));
573 
574     //
575     // Enable the FIFO.
576     //
577     HWREG(ulBase + UART_O_LCRH) |= UART_LCRH_FEN;
578 }
579 
580 //*****************************************************************************
581 //
582 //! Disables the transmit and receive FIFOs.
583 //!
584 //! \param ulBase is the base address of the UART port.
585 //!
586 //! This function disables the transmit and receive FIFOs in the UART.
587 //!
588 //! \return None.
589 //
590 //*****************************************************************************
591 void
UARTFIFODisable(unsigned long ulBase)592 UARTFIFODisable(unsigned long ulBase)
593 {
594     //
595     // Check the arguments.
596     //
597     ASSERT(UARTBaseValid(ulBase));
598 
599     //
600     // Disable the FIFO.
601     //
602     HWREG(ulBase + UART_O_LCRH) &= ~(UART_LCRH_FEN);
603 }
604 
605 //*****************************************************************************
606 //
607 //! Enables SIR (IrDA) mode on the specified UART.
608 //!
609 //! \param ulBase is the base address of the UART port.
610 //! \param bLowPower indicates if SIR Low Power Mode is to be used.
611 //!
612 //! This function enables the SIREN control bit for IrDA mode on the UART.  If
613 //! the \e bLowPower flag is set, then SIRLP bit is also set.  This
614 //! function only has an effect if the UART has not been enabled
615 //! by a call to UARTEnable().  The call UARTEnableSIR() must be made before
616 //! a call to UARTConfigSetExpClk() because the UARTConfigSetExpClk() function
617 //! calls the UARTEnable() function.  Another option is to call UARTDisable()
618 //! followed by UARTEnableSIR() and then enable the UART by calling
619 //! UARTEnable().
620 //!
621 //! \note The availability of SIR (IrDA) operation varies with the Stellaris
622 //! part in use.  Please consult the datasheet for the part you are using to
623 //! determine whether this support is available.
624 //!
625 //! \return None.
626 //
627 //*****************************************************************************
628 void
UARTEnableSIR(unsigned long ulBase,tBoolean bLowPower)629 UARTEnableSIR(unsigned long ulBase, tBoolean bLowPower)
630 {
631     //
632     // Check the arguments.
633     //
634     ASSERT(UARTBaseValid(ulBase));
635 
636     //
637     // Enable SIR and SIRLP (if appropriate).
638     //
639     if(bLowPower)
640     {
641         HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN | UART_CTL_SIRLP);
642     }
643     else
644     {
645         HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN);
646     }
647 }
648 
649 //*****************************************************************************
650 //
651 //! Disables SIR (IrDA) mode on the specified UART.
652 //!
653 //! \param ulBase is the base address of the UART port.
654 //!
655 //! This function clears the SIREN (IrDA) and SIRLP (Low Power) bits.  This
656 //! function only has an effect if the UART has not been enabled by a
657 //! call to UARTEnable().  The call UARTEnableSIR() must be made before
658 //! a call to UARTConfigSetExpClk() because the UARTConfigSetExpClk() function
659 //! calls the UARTEnable() function.  Another option is to call UARTDisable()
660 //! followed by UARTEnableSIR() and then enable the UART by calling
661 //! UARTEnable().
662 //!
663 //! \note The availability of SIR (IrDA) operation varies with the Stellaris
664 //! part in use.  Please consult the datasheet for the part you are using to
665 //! determine whether this support is available.
666 //!
667 //! \return None.
668 //
669 //*****************************************************************************
670 void
UARTDisableSIR(unsigned long ulBase)671 UARTDisableSIR(unsigned long ulBase)
672 {
673     //
674     // Check the arguments.
675     //
676     ASSERT(UARTBaseValid(ulBase));
677 
678     //
679     // Disable SIR and SIRLP (if appropriate).
680     //
681     HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_SIREN | UART_CTL_SIRLP);
682 }
683 
684 //*****************************************************************************
685 //
686 //! Enables ISO7816 smart card mode on the specified UART.
687 //!
688 //! \param ulBase is the base address of the UART port.
689 //!
690 //! This function enables the SMART control bit for the ISO7816 smart card mode
691 //! on the UART.  This call also sets 8-bit word length and even parity as
692 //! required by ISO7816.
693 //!
694 //! \note The availability of SIR (IrDA) operation varies with the Stellaris
695 //! part in use.  Please consult the datasheet for the part you are using to
696 //! determine whether this support is available.
697 //!
698 //! \return None.
699 //
700 //*****************************************************************************
701 void
UARTSmartCardEnable(unsigned long ulBase)702 UARTSmartCardEnable(unsigned long ulBase)
703 {
704     unsigned long ulVal;
705 
706     //
707     // Check the arguments.
708     //
709     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
710     ASSERT(UARTBaseValid(ulBase));
711 
712     //
713     // Set 8-bit word length, even parity, 2 stop bits (note that although the
714     // STP2 bit is ignored when in smartcard mode, this code lets the caller
715     // read back the actual setting in use).
716     //
717     ulVal = HWREG(ulBase + UART_O_LCRH);
718     ulVal &= ~(UART_LCRH_SPS | UART_LCRH_EPS | UART_LCRH_PEN |
719                UART_LCRH_WLEN_M);
720     ulVal |= UART_LCRH_WLEN_8 | UART_LCRH_PEN | UART_LCRH_EPS | UART_LCRH_STP2;
721     HWREG(ulBase + UART_O_LCRH) = ulVal;
722 
723     //
724     // Enable SMART mode.
725     //
726     HWREG(ulBase + UART_O_CTL) |= UART_CTL_SMART;
727 }
728 
729 //*****************************************************************************
730 //
731 //! Disables ISO7816 smart card mode on the specified UART.
732 //!
733 //! \param ulBase is the base address of the UART port.
734 //!
735 //! This function clears the SMART (ISO7816 smart card) bit in the UART
736 //! control register.
737 //!
738 //! \note The availability of ISO7816 smart card mode varies with the
739 //! Stellaris part in use.  Please consult the datasheet for the part you are
740 //! using to determine whether this support is available.
741 //!
742 //! \return None.
743 //
744 //*****************************************************************************
745 void
UARTSmartCardDisable(unsigned long ulBase)746 UARTSmartCardDisable(unsigned long ulBase)
747 {
748     //
749     // Check the arguments.
750     //
751     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
752     ASSERT(UARTBaseValid(ulBase));
753 
754     //
755     // Disable the SMART bit.
756     //
757     HWREG(ulBase + UART_O_CTL) &= ~UART_CTL_SMART;
758 }
759 
760 //*****************************************************************************
761 //
762 //! Sets the states of the DTR and/or RTS modem control signals.
763 //!
764 //! \param ulBase is the base address of the UART port.
765 //! \param ulControl is a bit-mapped flag indicating which modem control bits
766 //! should be set.
767 //!
768 //! This function configures the states of the DTR or RTS modem handshake
769 //! outputs from the UART.
770 //!
771 //! The \e ulControl parameter is the logical OR of any of the following:
772 //!
773 //! - \b UART_OUTPUT_DTR - The Modem Control DTR signal
774 //! - \b UART_OUTPUT_RTS - The Modem Control RTS signal
775 //!
776 //! \note The availability of ISO7816 smart card mode varies with the
777 //! Stellaris part in use.  Please consult the datasheet for the part you are
778 //! using to determine whether this support is available.
779 //!
780 //! \return None.
781 //
782 //*****************************************************************************
783 void
UARTModemControlSet(unsigned long ulBase,unsigned long ulControl)784 UARTModemControlSet(unsigned long ulBase, unsigned long ulControl)
785 {
786     unsigned long ulTemp;
787 
788     //
789     // Check the arguments.
790     //
791     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
792     ASSERT(ulBase == UART1_BASE);
793     ASSERT((ulControl & ~(UART_OUTPUT_RTS | UART_OUTPUT_DTR)) == 0);
794 
795     //
796     // Set the appropriate modem control output bits.
797     //
798     ulTemp = HWREG(ulBase + UART_O_CTL);
799     ulTemp |= (ulControl & (UART_OUTPUT_RTS | UART_OUTPUT_DTR));
800     HWREG(ulBase + UART_O_CTL) = ulTemp;
801 }
802 
803 //*****************************************************************************
804 //
805 //! Clears the states of the DTR and/or RTS modem control signals.
806 //!
807 //! \param ulBase is the base address of the UART port.
808 //! \param ulControl is a bit-mapped flag indicating which modem control bits
809 //! should be set.
810 //!
811 //! This function clears the states of the DTR or RTS modem handshake outputs
812 //! from the UART.
813 //!
814 //! The \e ulControl parameter is the logical OR of any of the following:
815 //!
816 //! - \b UART_OUTPUT_DTR - The Modem Control DTR signal
817 //! - \b UART_OUTPUT_RTS - The Modem Control RTS signal
818 //!
819 //! \note The availability of hardware modem handshake signals varies with the
820 //! Stellaris part and UART in use.  Please consult the datasheet for the part
821 //! you are using to determine whether this support is available.
822 //!
823 //! \return None.
824 //
825 //*****************************************************************************
826 void
UARTModemControlClear(unsigned long ulBase,unsigned long ulControl)827 UARTModemControlClear(unsigned long ulBase, unsigned long ulControl)
828 {
829     unsigned long ulTemp;
830 
831     //
832     // Check the arguments.
833     //
834     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
835     ASSERT(ulBase == UART1_BASE);
836     ASSERT((ulControl & ~(UART_OUTPUT_RTS | UART_OUTPUT_DTR)) == 0);
837 
838     //
839     // Set the appropriate modem control output bits.
840     //
841     ulTemp = HWREG(ulBase + UART_O_CTL);
842     ulTemp &= ~(ulControl & (UART_OUTPUT_RTS | UART_OUTPUT_DTR));
843     HWREG(ulBase + UART_O_CTL) = ulTemp;
844 }
845 
846 //*****************************************************************************
847 //
848 //! Gets the states of the DTR and RTS modem control signals.
849 //!
850 //! \param ulBase is the base address of the UART port.
851 //!
852 //! This function returns the current states of each of the two UART modem
853 //! control signals, DTR and RTS.
854 //!
855 //! \note The availability of hardware modem handshake signals varies with the
856 //! Stellaris part and UART in use.  Please consult the datasheet for the part
857 //! you are using to determine whether this support is available.
858 //!
859 //! \return Returns the states of the handshake output signals.  This value is
860 //! a logical OR combination of values \b UART_OUTPUT_RTS and
861 //! \b UART_OUTPUT_DTR where the presence of each flag indicates that the
862 //! associated signal is asserted.
863 //
864 //*****************************************************************************
865 unsigned long
UARTModemControlGet(unsigned long ulBase)866 UARTModemControlGet(unsigned long ulBase)
867 {
868     //
869     // Check the arguments.
870     //
871     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
872     ASSERT(ulBase == UART1_BASE);
873 
874     return(HWREG(ulBase + UART_O_CTL) & (UART_OUTPUT_RTS | UART_OUTPUT_DTR));
875 }
876 
877 //*****************************************************************************
878 //
879 //! Gets the states of the RI, DCD, DSR and CTS modem status signals.
880 //!
881 //! \param ulBase is the base address of the UART port.
882 //!
883 //! This function returns the current states of each of the four UART modem
884 //! status signals, RI, DCD, DSR and CTS.
885 //!
886 //! \note The availability of hardware modem handshake signals varies with the
887 //! Stellaris part and UART in use.  Please consult the datasheet for the part
888 //! you are using to determine whether this support is available.
889 //!
890 //! \return Returns the states of the handshake output signals.  This value
891 //! is a logical OR combination of values \b UART_INPUT_RI,
892 //! \b UART_INPUT_DCD, \b UART_INPUT_CTS and \b UART_INPUT_DSR where the
893 //! presence of each flag indicates that the associated signal is asserted.
894 //
895 //*****************************************************************************
896 unsigned long
UARTModemStatusGet(unsigned long ulBase)897 UARTModemStatusGet(unsigned long ulBase)
898 {
899     //
900     // Check the arguments.
901     //
902     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
903     ASSERT(ulBase == UART1_BASE);
904 
905     return(HWREG(ulBase + UART_O_FR) & (UART_INPUT_RI | UART_INPUT_DCD |
906            UART_INPUT_CTS | UART_INPUT_DSR));
907 }
908 
909 //*****************************************************************************
910 //
911 //! Sets the UART hardware flow control mode to be used.
912 //!
913 //! \param ulBase is the base address of the UART port.
914 //! \param ulMode indicates the flow control modes to be used.  This parameter
915 //! is a logical OR combination of values \b UART_FLOWCONTROL_TX and
916 //! \b UART_FLOWCONTROL_RX to enable hardware transmit (CTS) and receive (RTS)
917 //! flow control or \b UART_FLOWCONTROL_NONE to disable hardware flow control.
918 //!
919 //! This function configures the required hardware flow control modes.  If
920 //! \e ulMode contains flag \b UART_FLOWCONTROL_TX, data is only transmitted
921 //! if the incoming CTS signal is asserted. If \e ulMode contains flag
922 //! \b UART_FLOWCONTROL_RX, the RTS output is controlled by the hardware and is
923 //! asserted only when there is space available in the receive FIFO.  If no
924 //! hardware flow control is required, \b UART_FLOWCONTROL_NONE should be
925 //! passed.
926 //!
927 //! \note The availability of hardware flow control varies with the Stellaris
928 //! part and UART in use.  Please consult the datasheet for the part you are
929 //! using to determine whether this support is available.
930 //!
931 //! \return None.
932 //
933 //*****************************************************************************
934 void
UARTFlowControlSet(unsigned long ulBase,unsigned long ulMode)935 UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode)
936 {
937     //
938     // Check the arguments.
939     //
940     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
941     ASSERT(UARTBaseValid(ulBase));
942     ASSERT((ulMode & ~(UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)) == 0);
943 
944     //
945     // Set the flow control mode as requested.
946     //
947     HWREG(ulBase + UART_O_CTL) = ((HWREG(ulBase + UART_O_CTL) &
948                                  ~(UART_FLOWCONTROL_TX |
949                                    UART_FLOWCONTROL_RX)) | ulMode);
950 }
951 
952 //*****************************************************************************
953 //
954 //! Returns the UART hardware flow control mode currently in use.
955 //!
956 //! \param ulBase is the base address of the UART port.
957 //!
958 //! This function returns the current hardware flow control mode.
959 //!
960 //! \note The availability of hardware flow control varies with the Stellaris
961 //! part and UART in use.  Please consult the datasheet for the part you are
962 //! using to determine whether this support is available.
963 //!
964 //! \return Returns the current flow control mode in use.  This value is a
965 //! logical OR combination of values \b UART_FLOWCONTROL_TX if transmit
966 //! (CTS) flow control is enabled and \b UART_FLOWCONTROL_RX if receive (RTS)
967 //! flow control is in use.  If hardware flow control is disabled,
968 //! \b UART_FLOWCONTROL_NONE is returned.
969 //
970 //*****************************************************************************
971 unsigned long
UARTFlowControlGet(unsigned long ulBase)972 UARTFlowControlGet(unsigned long ulBase)
973 {
974     //
975     // Check the arguments.
976     //
977     ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
978     ASSERT(UARTBaseValid(ulBase));
979 
980     return(HWREG(ulBase + UART_O_CTL) & (UART_FLOWCONTROL_TX |
981                                          UART_FLOWCONTROL_RX));
982 }
983 
984 //*****************************************************************************
985 //
986 //! Sets the operating mode for the UART transmit interrupt.
987 //!
988 //! \param ulBase is the base address of the UART port.
989 //! \param ulMode is the operating mode for the transmit interrupt.  It may be
990 //! \b UART_TXINT_MODE_EOT to trigger interrupts when the transmitter is idle
991 //! or \b UART_TXINT_MODE_FIFO to trigger based on the current transmit FIFO
992 //! level.
993 //!
994 //! This function allows the mode of the UART transmit interrupt to be set.  By
995 //! default, the transmit interrupt is asserted when the FIFO level falls past
996 //! a threshold set via a call to UARTFIFOLevelSet().  Alternatively, if this
997 //! function is called with \e ulMode set to \b UART_TXINT_MODE_EOT, the
998 //! transmit interrupt is asserted once the transmitter is completely idle -
999 //! the transmit FIFO is empty and all bits, including any stop bits, have
1000 //! cleared the transmitter.
1001 //!
1002 //! \note The availability of end-of-transmission mode varies with the
1003 //! Stellaris part in use.  Please consult the datasheet for the part you are
1004 //! using to determine whether this support is available.
1005 //!
1006 //! \return None.
1007 //
1008 //*****************************************************************************
1009 void
UARTTxIntModeSet(unsigned long ulBase,unsigned long ulMode)1010 UARTTxIntModeSet(unsigned long ulBase, unsigned long ulMode)
1011 {
1012     //
1013     // Check the arguments.
1014     //
1015     ASSERT(UARTBaseValid(ulBase));
1016     ASSERT((ulMode == UART_TXINT_MODE_EOT) ||
1017            (ulMode == UART_TXINT_MODE_FIFO));
1018 
1019     //
1020     // Set or clear the EOT bit of the UART control register as appropriate.
1021     //
1022     HWREG(ulBase + UART_O_CTL) = ((HWREG(ulBase + UART_O_CTL) &
1023                                  ~(UART_TXINT_MODE_EOT |
1024                                    UART_TXINT_MODE_FIFO)) | ulMode);
1025 }
1026 
1027 //*****************************************************************************
1028 //
1029 //! Returns the current operating mode for the UART transmit interrupt.
1030 //!
1031 //! \param ulBase is the base address of the UART port.
1032 //!
1033 //! This function returns the current operating mode for the UART transmit
1034 //! interrupt.  The return value is \b UART_TXINT_MODE_EOT if the transmit
1035 //! interrupt is currently configured to be asserted once the transmitter is
1036 //! completely idle - the transmit FIFO is empty and all bits, including any
1037 //! stop bits, have cleared the transmitter.  The return value is
1038 //! \b UART_TXINT_MODE_FIFO if the interrupt is configured to be asserted based
1039 //! on the level of the transmit FIFO.
1040 //!
1041 //! \note The availability of end-of-transmission mode varies with the
1042 //! Stellaris part in use.  Please consult the datasheet for the part you are
1043 //! using to determine whether this support is available.
1044 //!
1045 //! \return Returns \b UART_TXINT_MODE_FIFO or \b UART_TXINT_MODE_EOT.
1046 //
1047 //*****************************************************************************
1048 unsigned long
UARTTxIntModeGet(unsigned long ulBase)1049 UARTTxIntModeGet(unsigned long ulBase)
1050 {
1051     //
1052     // Check the arguments.
1053     //
1054     ASSERT(UARTBaseValid(ulBase));
1055 
1056     //
1057     // Return the current transmit interrupt mode.
1058     //
1059     return(HWREG(ulBase + UART_O_CTL) & (UART_TXINT_MODE_EOT |
1060                                          UART_TXINT_MODE_FIFO));
1061 }
1062 
1063 //*****************************************************************************
1064 //
1065 //! Determines if there are any characters in the receive FIFO.
1066 //!
1067 //! \param ulBase is the base address of the UART port.
1068 //!
1069 //! This function returns a flag indicating whether or not there is data
1070 //! available in the receive FIFO.
1071 //!
1072 //! \return Returns \b true if there is data in the receive FIFO or \b false
1073 //! if there is no data in the receive FIFO.
1074 //
1075 //*****************************************************************************
1076 tBoolean
UARTCharsAvail(unsigned long ulBase)1077 UARTCharsAvail(unsigned long ulBase)
1078 {
1079     //
1080     // Check the arguments.
1081     //
1082     ASSERT(UARTBaseValid(ulBase));
1083 
1084     //
1085     // Return the availability of characters.
1086     //
1087     return((HWREG(ulBase + UART_O_FR) & UART_FR_RXFE) ? false : true);
1088 }
1089 
1090 //*****************************************************************************
1091 //
1092 //! Determines if there is any space in the transmit FIFO.
1093 //!
1094 //! \param ulBase is the base address of the UART port.
1095 //!
1096 //! This function returns a flag indicating whether or not there is space
1097 //! available in the transmit FIFO.
1098 //!
1099 //! \return Returns \b true if there is space available in the transmit FIFO
1100 //! or \b false if there is no space available in the transmit FIFO.
1101 //
1102 //*****************************************************************************
1103 tBoolean
UARTSpaceAvail(unsigned long ulBase)1104 UARTSpaceAvail(unsigned long ulBase)
1105 {
1106     //
1107     // Check the arguments.
1108     //
1109     ASSERT(UARTBaseValid(ulBase));
1110 
1111     //
1112     // Return the availability of space.
1113     //
1114     return((HWREG(ulBase + UART_O_FR) & UART_FR_TXFF) ? false : true);
1115 }
1116 
1117 //*****************************************************************************
1118 //
1119 //! Receives a character from the specified port.
1120 //!
1121 //! \param ulBase is the base address of the UART port.
1122 //!
1123 //! This function gets a character from the receive FIFO for the specified
1124 //! port.
1125 //!
1126 //! This function replaces the original UARTCharNonBlockingGet() API and
1127 //! performs the same actions.  A macro is provided in <tt>uart.h</tt> to map
1128 //! the original API to this API.
1129 //!
1130 //! \return Returns the character read from the specified port, cast as a
1131 //! \e long.  A \b -1 is returned if there are no characters present in the
1132 //! receive FIFO.  The UARTCharsAvail() function should be called before
1133 //! attempting to call this function.
1134 //
1135 //*****************************************************************************
1136 long
UARTCharGetNonBlocking(unsigned long ulBase)1137 UARTCharGetNonBlocking(unsigned long ulBase)
1138 {
1139     //
1140     // Check the arguments.
1141     //
1142     ASSERT(UARTBaseValid(ulBase));
1143 
1144     //
1145     // See if there are any characters in the receive FIFO.
1146     //
1147     if(!(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE))
1148     {
1149         //
1150         // Read and return the next character.
1151         //
1152         return(HWREG(ulBase + UART_O_DR));
1153     }
1154     else
1155     {
1156         //
1157         // There are no characters, so return a failure.
1158         //
1159         return(-1);
1160     }
1161 }
1162 
1163 //*****************************************************************************
1164 //
1165 //! Waits for a character from the specified port.
1166 //!
1167 //! \param ulBase is the base address of the UART port.
1168 //!
1169 //! This function gets a character from the receive FIFO for the specified
1170 //! port.  If there are no characters available, this function waits until a
1171 //! character is received before returning.
1172 //!
1173 //! \return Returns the character read from the specified port, cast as a
1174 //! \e long.
1175 //
1176 //*****************************************************************************
1177 long
UARTCharGet(unsigned long ulBase)1178 UARTCharGet(unsigned long ulBase)
1179 {
1180     //
1181     // Check the arguments.
1182     //
1183     ASSERT(UARTBaseValid(ulBase));
1184 
1185     //
1186     // Wait until a char is available.
1187     //
1188     while(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE)
1189     {
1190     }
1191 
1192     //
1193     // Now get the char.
1194     //
1195     return(HWREG(ulBase + UART_O_DR));
1196 }
1197 
1198 //*****************************************************************************
1199 //
1200 //! Sends a character to the specified port.
1201 //!
1202 //! \param ulBase is the base address of the UART port.
1203 //! \param ucData is the character to be transmitted.
1204 //!
1205 //! This function writes the character \e ucData to the transmit FIFO for the
1206 //! specified port.  This function does not block, so if there is no space
1207 //! available, then a \b false is returned and the application must retry the
1208 //! function later.
1209 //!
1210 //! This function replaces the original UARTCharNonBlockingPut() API and
1211 //! performs the same actions.  A macro is provided in <tt>uart.h</tt> to map
1212 //! the original API to this API.
1213 //!
1214 //! \return Returns \b true if the character was successfully placed in the
1215 //! transmit FIFO or \b false if there was no space available in the transmit
1216 //! FIFO.
1217 //
1218 //*****************************************************************************
1219 tBoolean
UARTCharPutNonBlocking(unsigned long ulBase,unsigned char ucData)1220 UARTCharPutNonBlocking(unsigned long ulBase, unsigned char ucData)
1221 {
1222     //
1223     // Check the arguments.
1224     //
1225     ASSERT(UARTBaseValid(ulBase));
1226 
1227     //
1228     // See if there is space in the transmit FIFO.
1229     //
1230     if(!(HWREG(ulBase + UART_O_FR) & UART_FR_TXFF))
1231     {
1232         //
1233         // Write this character to the transmit FIFO.
1234         //
1235         HWREG(ulBase + UART_O_DR) = ucData;
1236 
1237         //
1238         // Success.
1239         //
1240         return(true);
1241     }
1242     else
1243     {
1244         //
1245         // There is no space in the transmit FIFO, so return a failure.
1246         //
1247         return(false);
1248     }
1249 }
1250 
1251 //*****************************************************************************
1252 //
1253 //! Waits to send a character from the specified port.
1254 //!
1255 //! \param ulBase is the base address of the UART port.
1256 //! \param ucData is the character to be transmitted.
1257 //!
1258 //! This function sends the character \e ucData to the transmit FIFO for the
1259 //! specified port.  If there is no space available in the transmit FIFO, this
1260 //! function waits until there is space available before returning.
1261 //!
1262 //! \return None.
1263 //
1264 //*****************************************************************************
1265 void
UARTCharPut(unsigned long ulBase,unsigned char ucData)1266 UARTCharPut(unsigned long ulBase, unsigned char ucData)
1267 {
1268     //
1269     // Check the arguments.
1270     //
1271     ASSERT(UARTBaseValid(ulBase));
1272 
1273     //
1274     // Wait until space is available.
1275     //
1276     while(HWREG(ulBase + UART_O_FR) & UART_FR_TXFF)
1277     {
1278     }
1279 
1280     //
1281     // Send the char.
1282     //
1283     HWREG(ulBase + UART_O_DR) = ucData;
1284 }
1285 
1286 //*****************************************************************************
1287 //
1288 //! Causes a BREAK to be sent.
1289 //!
1290 //! \param ulBase is the base address of the UART port.
1291 //! \param bBreakState controls the output level.
1292 //!
1293 //! Calling this function with \e bBreakState set to \b true asserts a break
1294 //! condition on the UART.  Calling this function with \e bBreakState set to
1295 //! \b false removes the break condition.  For proper transmission of a break
1296 //! command, the break must be asserted for at least two complete frames.
1297 //!
1298 //! \return None.
1299 //
1300 //*****************************************************************************
1301 void
UARTBreakCtl(unsigned long ulBase,tBoolean bBreakState)1302 UARTBreakCtl(unsigned long ulBase, tBoolean bBreakState)
1303 {
1304     //
1305     // Check the arguments.
1306     //
1307     ASSERT(UARTBaseValid(ulBase));
1308 
1309     //
1310     // Set the break condition as requested.
1311     //
1312     HWREG(ulBase + UART_O_LCRH) =
1313         (bBreakState ?
1314          (HWREG(ulBase + UART_O_LCRH) | UART_LCRH_BRK) :
1315          (HWREG(ulBase + UART_O_LCRH) & ~(UART_LCRH_BRK)));
1316 }
1317 
1318 //*****************************************************************************
1319 //
1320 //! Determines whether the UART transmitter is busy or not.
1321 //!
1322 //! \param ulBase is the base address of the UART port.
1323 //!
1324 //! This function allows the caller to determine whether all transmitted bytes
1325 //! have cleared the transmitter hardware.  If \b false is returned, the
1326 //! transmit FIFO is empty and all bits of the last transmitted character,
1327 //! including all stop bits, have left the hardware shift register.
1328 //!
1329 //! \return Returns \b true if the UART is transmitting or \b false if all
1330 //! transmissions are complete.
1331 //
1332 //*****************************************************************************
1333 tBoolean
UARTBusy(unsigned long ulBase)1334 UARTBusy(unsigned long ulBase)
1335 {
1336     //
1337     // Check the argument.
1338     //
1339     ASSERT(UARTBaseValid(ulBase));
1340 
1341     //
1342     // Determine if the UART is busy.
1343     //
1344     return((HWREG(ulBase + UART_O_FR) & UART_FR_BUSY) ? true : false);
1345 }
1346 
1347 //*****************************************************************************
1348 //
1349 //! Registers an interrupt handler for a UART interrupt.
1350 //!
1351 //! \param ulBase is the base address of the UART port.
1352 //! \param pfnHandler is a pointer to the function to be called when the
1353 //! UART interrupt occurs.
1354 //!
1355 //! This function does the actual registering of the interrupt handler.  This
1356 //! function enables the global interrupt in the interrupt controller; specific
1357 //! UART interrupts must be enabled via UARTIntEnable().  It is the interrupt
1358 //! handler's responsibility to clear the interrupt source.
1359 //!
1360 //! \sa IntRegister() for important information about registering interrupt
1361 //! handlers.
1362 //!
1363 //! \return None.
1364 //
1365 //*****************************************************************************
1366 void
UARTIntRegister(unsigned long ulBase,void (* pfnHandler)(void))1367 UARTIntRegister(unsigned long ulBase, void (*pfnHandler)(void))
1368 {
1369     unsigned long ulInt;
1370 
1371     //
1372     // Check the arguments.
1373     //
1374     ASSERT(UARTBaseValid(ulBase));
1375 
1376     //
1377     // Determine the interrupt number based on the UART port.
1378     //
1379     ulInt = UARTIntNumberGet(ulBase);
1380 
1381     //
1382     // Register the interrupt handler.
1383     //
1384     IntRegister(ulInt, pfnHandler);
1385 
1386     //
1387     // Enable the UART interrupt.
1388     //
1389     IntEnable(ulInt);
1390 }
1391 
1392 //*****************************************************************************
1393 //
1394 //! Unregisters an interrupt handler for a UART interrupt.
1395 //!
1396 //! \param ulBase is the base address of the UART port.
1397 //!
1398 //! This function does the actual unregistering of the interrupt handler.  It
1399 //! clears the handler to be called when a UART interrupt occurs.  This
1400 //! function also masks off the interrupt in the interrupt controller so that
1401 //! the interrupt handler no longer is called.
1402 //!
1403 //! \sa IntRegister() for important information about registering interrupt
1404 //! handlers.
1405 //!
1406 //! \return None.
1407 //
1408 //*****************************************************************************
1409 void
UARTIntUnregister(unsigned long ulBase)1410 UARTIntUnregister(unsigned long ulBase)
1411 {
1412     unsigned long ulInt;
1413 
1414     //
1415     // Check the arguments.
1416     //
1417     ASSERT(UARTBaseValid(ulBase));
1418 
1419     //
1420     // Determine the interrupt number based on the UART port.
1421     //
1422     ulInt = UARTIntNumberGet(ulBase);
1423 
1424     //
1425     // Disable the interrupt.
1426     //
1427     IntDisable(ulInt);
1428 
1429     //
1430     // Unregister the interrupt handler.
1431     //
1432     IntUnregister(ulInt);
1433 }
1434 
1435 //*****************************************************************************
1436 //
1437 //! Enables individual UART interrupt sources.
1438 //!
1439 //! \param ulBase is the base address of the UART port.
1440 //! \param ulIntFlags is the bit mask of the interrupt sources to be enabled.
1441 //!
1442 //! This function enables the indicated UART interrupt sources.  Only the
1443 //! sources that are enabled can be reflected to the processor interrupt;
1444 //! disabled sources have no effect on the processor.
1445 //!
1446 //! The \e ulIntFlags parameter is the logical OR of any of the following:
1447 //!
1448 //! - \b UART_INT_9BIT - 9-bit Address Match interrupt
1449 //! - \b UART_INT_OE - Overrun Error interrupt
1450 //! - \b UART_INT_BE - Break Error interrupt
1451 //! - \b UART_INT_PE - Parity Error interrupt
1452 //! - \b UART_INT_FE - Framing Error interrupt
1453 //! - \b UART_INT_RT - Receive Timeout interrupt
1454 //! - \b UART_INT_TX - Transmit interrupt
1455 //! - \b UART_INT_RX - Receive interrupt
1456 //! - \b UART_INT_DSR - DSR interrupt
1457 //! - \b UART_INT_DCD - DCD interrupt
1458 //! - \b UART_INT_CTS - CTS interrupt
1459 //! - \b UART_INT_RI - RI interrupt
1460 //!
1461 //! \return None.
1462 //
1463 //*****************************************************************************
1464 void
UARTIntEnable(unsigned long ulBase,unsigned long ulIntFlags)1465 UARTIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
1466 {
1467     //
1468     // Check the arguments.
1469     //
1470     ASSERT(UARTBaseValid(ulBase));
1471 
1472     //
1473     // Enable the specified interrupts.
1474     //
1475     HWREG(ulBase + UART_O_IM) |= ulIntFlags;
1476 }
1477 
1478 //*****************************************************************************
1479 //
1480 //! Disables individual UART interrupt sources.
1481 //!
1482 //! \param ulBase is the base address of the UART port.
1483 //! \param ulIntFlags is the bit mask of the interrupt sources to be disabled.
1484 //!
1485 //! This function disables the indicated UART interrupt sources.  Only the
1486 //! sources that are enabled can be reflected to the processor interrupt;
1487 //! disabled sources have no effect on the processor.
1488 //!
1489 //! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags
1490 //! parameter to UARTIntEnable().
1491 //!
1492 //! \return None.
1493 //
1494 //*****************************************************************************
1495 void
UARTIntDisable(unsigned long ulBase,unsigned long ulIntFlags)1496 UARTIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
1497 {
1498     //
1499     // Check the arguments.
1500     //
1501     ASSERT(UARTBaseValid(ulBase));
1502 
1503     //
1504     // Disable the specified interrupts.
1505     //
1506     HWREG(ulBase + UART_O_IM) &= ~(ulIntFlags);
1507 }
1508 
1509 //*****************************************************************************
1510 //
1511 //! Gets the current interrupt status.
1512 //!
1513 //! \param ulBase is the base address of the UART port.
1514 //! \param bMasked is \b false if the raw interrupt status is required and
1515 //! \b true if the masked interrupt status is required.
1516 //!
1517 //! This function returns the interrupt status for the specified UART.  Either
1518 //! the raw interrupt status or the status of interrupts that are allowed to
1519 //! reflect to the processor can be returned.
1520 //!
1521 //! \return Returns the current interrupt status, enumerated as a bit field of
1522 //! values described in UARTIntEnable().
1523 //
1524 //*****************************************************************************
1525 unsigned long
UARTIntStatus(unsigned long ulBase,tBoolean bMasked)1526 UARTIntStatus(unsigned long ulBase, tBoolean bMasked)
1527 {
1528     //
1529     // Check the arguments.
1530     //
1531     ASSERT(UARTBaseValid(ulBase));
1532 
1533     //
1534     // Return either the interrupt status or the raw interrupt status as
1535     // requested.
1536     //
1537     if(bMasked)
1538     {
1539         return(HWREG(ulBase + UART_O_MIS));
1540     }
1541     else
1542     {
1543         return(HWREG(ulBase + UART_O_RIS));
1544     }
1545 }
1546 
1547 //*****************************************************************************
1548 //
1549 //! Clears UART interrupt sources.
1550 //!
1551 //! \param ulBase is the base address of the UART port.
1552 //! \param ulIntFlags is a bit mask of the interrupt sources to be cleared.
1553 //!
1554 //! The specified UART interrupt sources are cleared, so that they no longer
1555 //! assert.  This function must be called in the interrupt handler to keep the
1556 //! interrupt from being triggered again immediately upon exit.
1557 //!
1558 //! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags
1559 //! parameter to UARTIntEnable().
1560 //!
1561 //! \note Because there is a write buffer in the Cortex-M processor, it may
1562 //! take several clock cycles before the interrupt source is actually cleared.
1563 //! Therefore, it is recommended that the interrupt source be cleared early in
1564 //! the interrupt handler (as opposed to the very last action) to avoid
1565 //! returning from the interrupt handler before the interrupt source is
1566 //! actually cleared.  Failure to do so may result in the interrupt handler
1567 //! being immediately reentered (because the interrupt controller still sees
1568 //! the interrupt source asserted).
1569 //!
1570 //! \return None.
1571 //
1572 //*****************************************************************************
1573 void
UARTIntClear(unsigned long ulBase,unsigned long ulIntFlags)1574 UARTIntClear(unsigned long ulBase, unsigned long ulIntFlags)
1575 {
1576     //
1577     // Check the arguments.
1578     //
1579     ASSERT(UARTBaseValid(ulBase));
1580 
1581     //
1582     // Clear the requested interrupt sources.
1583     //
1584     HWREG(ulBase + UART_O_ICR) = ulIntFlags;
1585 }
1586 
1587 //*****************************************************************************
1588 //
1589 //! Enable UART DMA operation.
1590 //!
1591 //! \param ulBase is the base address of the UART port.
1592 //! \param ulDMAFlags is a bit mask of the DMA features to enable.
1593 //!
1594 //! The specified UART DMA features are enabled.  The UART can be
1595 //! configured to use DMA for transmit or receive and to disable
1596 //! receive if an error occurs.  The \e ulDMAFlags parameter is the
1597 //! logical OR of any of the following values:
1598 //!
1599 //! - UART_DMA_RX - enable DMA for receive
1600 //! - UART_DMA_TX - enable DMA for transmit
1601 //! - UART_DMA_ERR_RXSTOP - disable DMA receive on UART error
1602 //!
1603 //! \note The uDMA controller must also be set up before DMA can be used
1604 //! with the UART.
1605 //!
1606 //! \return None.
1607 //
1608 //*****************************************************************************
1609 void
UARTDMAEnable(unsigned long ulBase,unsigned long ulDMAFlags)1610 UARTDMAEnable(unsigned long ulBase, unsigned long ulDMAFlags)
1611 {
1612     //
1613     // Check the arguments.
1614     //
1615     ASSERT(UARTBaseValid(ulBase));
1616 
1617     //
1618     // Set the requested bits in the UART DMA control register.
1619     //
1620     HWREG(ulBase + UART_O_DMACTL) |= ulDMAFlags;
1621 }
1622 
1623 //*****************************************************************************
1624 //
1625 //! Disable UART DMA operation.
1626 //!
1627 //! \param ulBase is the base address of the UART port.
1628 //! \param ulDMAFlags is a bit mask of the DMA features to disable.
1629 //!
1630 //! This function is used to disable UART DMA features that were enabled
1631 //! by UARTDMAEnable().  The specified UART DMA features are disabled.  The
1632 //! \e ulDMAFlags parameter is the logical OR of any of the following values:
1633 //!
1634 //! - UART_DMA_RX - disable DMA for receive
1635 //! - UART_DMA_TX - disable DMA for transmit
1636 //! - UART_DMA_ERR_RXSTOP - do not disable DMA receive on UART error
1637 //!
1638 //! \return None.
1639 //
1640 //*****************************************************************************
1641 void
UARTDMADisable(unsigned long ulBase,unsigned long ulDMAFlags)1642 UARTDMADisable(unsigned long ulBase, unsigned long ulDMAFlags)
1643 {
1644     //
1645     // Check the arguments.
1646     //
1647     ASSERT(UARTBaseValid(ulBase));
1648 
1649     //
1650     // Clear the requested bits in the UART DMA control register.
1651     //
1652     HWREG(ulBase + UART_O_DMACTL) &= ~ulDMAFlags;
1653 }
1654 
1655 //*****************************************************************************
1656 //
1657 //! Gets current receiver errors.
1658 //!
1659 //! \param ulBase is the base address of the UART port.
1660 //!
1661 //! This function returns the current state of each of the 4 receiver error
1662 //! sources.  The returned errors are equivalent to the four error bits
1663 //! returned via the previous call to UARTCharGet() or UARTCharGetNonBlocking()
1664 //! with the exception that the overrun error is set immediately when the
1665 //! overrun occurs rather than when a character is next read.
1666 //!
1667 //! \return Returns a logical OR combination of the receiver error flags,
1668 //! \b UART_RXERROR_FRAMING, \b UART_RXERROR_PARITY, \b UART_RXERROR_BREAK
1669 //! and \b UART_RXERROR_OVERRUN.
1670 //
1671 //*****************************************************************************
1672 unsigned long
UARTRxErrorGet(unsigned long ulBase)1673 UARTRxErrorGet(unsigned long ulBase)
1674 {
1675     //
1676     // Check the arguments.
1677     //
1678     ASSERT(UARTBaseValid(ulBase));
1679 
1680     //
1681     // Return the current value of the receive status register.
1682     //
1683     return(HWREG(ulBase + UART_O_RSR) & 0x0000000F);
1684 }
1685 
1686 //*****************************************************************************
1687 //
1688 //! Clears all reported receiver errors.
1689 //!
1690 //! \param ulBase is the base address of the UART port.
1691 //!
1692 //! This function is used to clear all receiver error conditions reported via
1693 //! UARTRxErrorGet().  If using the overrun, framing error, parity error or
1694 //! break interrupts, this function must be called after clearing the interrupt
1695 //! to ensure that later errors of the same type trigger another interrupt.
1696 //!
1697 //! \return None.
1698 //
1699 //*****************************************************************************
1700 void
UARTRxErrorClear(unsigned long ulBase)1701 UARTRxErrorClear(unsigned long ulBase)
1702 {
1703     //
1704     // Check the arguments.
1705     //
1706     ASSERT(UARTBaseValid(ulBase));
1707 
1708     //
1709     // Any write to the Error Clear Register clears all bits which are
1710     // currently set.
1711     //
1712     HWREG(ulBase + UART_O_ECR) = 0;
1713 }
1714 
1715 //*****************************************************************************
1716 //
1717 //! Sets the baud clock source for the specified UART.
1718 //!
1719 //! \param ulBase is the base address of the UART port.
1720 //! \param ulSource is the baud clock source for the UART.
1721 //!
1722 //! This function allows the baud clock source for the UART to be selected.
1723 //! The possible clock source are the system clock (\b UART_CLOCK_SYSTEM) or
1724 //! the precision internal oscillator (\b UART_CLOCK_PIOSC).
1725 //!
1726 //! Changing the baud clock source changes the baud rate generated by the
1727 //! UART.  Therefore, the baud rate should be reconfigured after any change to
1728 //! the baud clock source.
1729 //!
1730 //! \note The ability to specify the UART baud clock source varies with the
1731 //! Stellaris part in use.  Please consult the datasheet for the part you are
1732 //! using to determine whether this support is available.
1733 //!
1734 //! \return None.
1735 //
1736 //*****************************************************************************
1737 void
UARTClockSourceSet(unsigned long ulBase,unsigned long ulSource)1738 UARTClockSourceSet(unsigned long ulBase, unsigned long ulSource)
1739 {
1740     //
1741     // Check the arguments.
1742     //
1743     ASSERT(UARTBaseValid(ulBase));
1744     ASSERT((ulSource == UART_CLOCK_SYSTEM) || (ulSource == UART_CLOCK_PIOSC));
1745 
1746     //
1747     // Set the UART clock source.
1748     //
1749     HWREG(ulBase + UART_O_CC) = ulSource;
1750 }
1751 
1752 //*****************************************************************************
1753 //
1754 //! Gets the baud clock source for the specified UART.
1755 //!
1756 //! \param ulBase is the base address of the UART port.
1757 //!
1758 //! This function returns the baud clock source for the specified UART.  The
1759 //! possible baud clock source are the system clock (\b UART_CLOCK_SYSTEM) or
1760 //! the precision internal oscillator (\b UART_CLOCK_PIOSC).
1761 //!
1762 //! \note The ability to specify the UART baud clock source varies with the
1763 //! Stellaris part in use.  Please consult the datasheet for the part you are
1764 //! using to determine whether this support is available.
1765 //!
1766 //! \return None.
1767 //
1768 //*****************************************************************************
1769 unsigned long
UARTClockSourceGet(unsigned long ulBase)1770 UARTClockSourceGet(unsigned long ulBase)
1771 {
1772     //
1773     // Check the arguments.
1774     //
1775     ASSERT(UARTBaseValid(ulBase));
1776 
1777     //
1778     // Return the UART clock source.
1779     //
1780     return(HWREG(ulBase + UART_O_CC));
1781 }
1782 
1783 //*****************************************************************************
1784 //
1785 //! Enables 9-bit mode on the specified UART.
1786 //!
1787 //! \param ulBase is the base address of the UART port.
1788 //!
1789 //! This function enables the 9-bit operational mode of the UART.
1790 //!
1791 //! \note The availability of 9-bit mode varies with the Stellaris part in use.
1792 //! Please consult the datasheet for the part you are using to determine
1793 //! whether this support is available.
1794 //!
1795 //! \return None.
1796 //
1797 //*****************************************************************************
1798 void
UART9BitEnable(unsigned long ulBase)1799 UART9BitEnable(unsigned long ulBase)
1800 {
1801     //
1802     // Check the arguments.
1803     //
1804     ASSERT(UARTBaseValid(ulBase));
1805 
1806     //
1807     // Enable 9-bit mode.
1808     //
1809     HWREG(ulBase + UART_O_9BITADDR) |= UART_9BITADDR_9BITEN;
1810 }
1811 
1812 //*****************************************************************************
1813 //
1814 //! Disables 9-bit mode on the specified UART.
1815 //!
1816 //! \param ulBase is the base address of the UART port.
1817 //!
1818 //! This function disables the 9-bit operational mode of the UART.
1819 //!
1820 //! \note The availability of 9-bit mode varies with the Stellaris part in use.
1821 //! Please consult the datasheet for the part you are using to determine
1822 //! whether this support is available.
1823 //!
1824 //! \return None.
1825 //
1826 //*****************************************************************************
1827 void
UART9BitDisable(unsigned long ulBase)1828 UART9BitDisable(unsigned long ulBase)
1829 {
1830     //
1831     // Check the arguments.
1832     //
1833     ASSERT(UARTBaseValid(ulBase));
1834 
1835     //
1836     // Disable 9-bit mode.
1837     //
1838     HWREG(ulBase + UART_O_9BITADDR) &= ~UART_9BITADDR_9BITEN;
1839 }
1840 
1841 //*****************************************************************************
1842 //
1843 //! Sets the device address(es) for 9-bit mode.
1844 //!
1845 //! \param ulBase is the base address of the UART port.
1846 //! \param ucAddr is the device address.
1847 //! \param ucMask is the device address mask.
1848 //!
1849 //! This function configures the device address or range of device addresses
1850 //! that respond to requests on the 9-bit UART port.  The received address is
1851 //! masked with the mask and then compared against the given address, allowing
1852 //! either a single address (if \b ucMask is 0xff) or a set of addresses to be
1853 //! matched.
1854 //!
1855 //! \note The availability of 9-bit mode varies with the Stellaris part in use.
1856 //! Please consult the datasheet for the part you are using to determine
1857 //! whether this support is available.
1858 //!
1859 //! \return None.
1860 //
1861 //*****************************************************************************
1862 void
UART9BitAddrSet(unsigned long ulBase,unsigned char ucAddr,unsigned char ucMask)1863 UART9BitAddrSet(unsigned long ulBase, unsigned char ucAddr,
1864                 unsigned char ucMask)
1865 {
1866     //
1867     // Check the arguments.
1868     //
1869     ASSERT(UARTBaseValid(ulBase));
1870 
1871     //
1872     // Set the address and mask.
1873     //
1874     HWREG(ulBase + UART_O_9BITADDR) = ucAddr << UART_9BITADDR_ADDR_S;
1875     HWREG(ulBase + UART_O_9BITAMASK) = ucMask << UART_9BITAMASK_MASK_S;
1876 }
1877 
1878 //*****************************************************************************
1879 //
1880 //! Sends an address character from the specified port when operating in 9-bit
1881 //! mode.
1882 //!
1883 //! \param ulBase is the base address of the UART port.
1884 //! \param ucAddr is the address to be transmitted.
1885 //!
1886 //! This function waits until all data has been sent from the specified port
1887 //! and then sends the given address as an address byte.  It then waits until
1888 //! the address byte has been transmitted before returning.
1889 //!
1890 //! The normal data functions (UARTCharPut(), UARTCharPutNonBlocking(),
1891 //! UARTCharGet(), and UARTCharGetNonBlocking()) are used to send and receive
1892 //! data characters in 9-bit mode.
1893 //!
1894 //! \note The availability of 9-bit mode varies with the Stellaris part in use.
1895 //! Please consult the datasheet for the part you are using to determine
1896 //! whether this support is available.
1897 //!
1898 //! \return None.
1899 //
1900 //*****************************************************************************
1901 void
UART9BitAddrSend(unsigned long ulBase,unsigned char ucAddr)1902 UART9BitAddrSend(unsigned long ulBase, unsigned char ucAddr)
1903 {
1904     unsigned long ulLCRH;
1905 
1906     //
1907     // Check the arguments.
1908     //
1909     ASSERT(UARTBaseValid(ulBase));
1910 
1911     //
1912     // Wait until the FIFO is empty and the UART is not busy.
1913     //
1914     while(HWREG(ulBase + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY))
1915     {
1916     }
1917 
1918     //
1919     // Force the address/data bit to 1 to indicate this is an address byte.
1920     //
1921     ulLCRH = HWREG(ulBase + UART_O_LCRH);
1922     HWREG(ulBase + UART_O_LCRH) = ((ulLCRH & ~UART_LCRH_EPS) | UART_LCRH_SPS |
1923                                    UART_LCRH_PEN);
1924 
1925     //
1926     // Send the address.
1927     //
1928     HWREG(ulBase + UART_O_DR) = ucAddr;
1929 
1930     //
1931     // Wait until the address has been sent.
1932     //
1933     while(HWREG(ulBase + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY))
1934     {
1935     }
1936 
1937     //
1938     // Restore the address/data setting.
1939     //
1940     HWREG(ulBase + UART_O_LCRH) = ulLCRH;
1941 }
1942 
1943 //*****************************************************************************
1944 //
1945 // Close the Doxygen group.
1946 //! @}
1947 //
1948 //*****************************************************************************
1949