text: //*****************************************************************************
  //
  // uart_polled.c - Example demonstrating UART polled I/O.
  //
  // Copyright (c) 2010-2011 Texas Instruments Incorporated.  All rights reserved.
  // Software License Agreement
  // 
  // Texas Instruments (TI) is supplying this software for use solely and
  // exclusively on TI's microcontroller products. The software is owned by
  // TI and/or its suppliers, and is protected under applicable copyright
  // laws. You may not combine this software with "viral" open-source
  // software in order to form a larger program.
  // 
  // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  // DAMAGES, FOR ANY REASON WHATSOEVER.
  // 
  // This is part of revision 6852 of the Stellaris Firmware Development Package.
  //
  //*****************************************************************************
  
  #include "inc/hw_memmap.h"
  #include "inc/hw_types.h"
  #include "driverlib/sysctl.h"
  #include "driverlib/uart.h"
  #include "driverlib/gpio.h"
  
  //*****************************************************************************
  //
  //! \addtogroup uart_examples_list
  //! <h1>UART Polled I/O (uart_polled)</h1>
  //!
  //! This example shows how to set up the UART and use polled I/O methods
  //! for transmitting and receiving UART data.  The example receives characters
  //! from UART0 and retransmits the same character using UART0.  It can be
  //! tested by using a serial terminal program on a host computer.  This
  //! example will echo every character that is type until the return/enter key
  //! is pressed.
  //!
  //! This example uses the following peripherals and I/O signals.  You must
  //! review these and change as needed for your own board:
  //! - UART0 peripheral
  //! - GPIO Port A peripheral (for UART0 pins)
  //! - UART0RX - PA0
  //! - UART0TX - PA1
  //!
  //
  //*****************************************************************************
  
  //*****************************************************************************
  //
  // Configure the UART and perform reads and writes using polled I/O.
  //
  //*****************************************************************************
  int
  main(void)
  {
      char cThisChar;
  
      //
      // Set the clocking to run directly from the external crystal/oscillator.
      // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
      // crystal on your board.
      //
      SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                     SYSCTL_XTAL_16MHZ);
  
      //
      // Enable the peripherals used by this example.
      // The UART itself needs to be enabled, as well as the GPIO port
      // containing the pins that will be used.
      //
      SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
      SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  
      //
      // Configure the GPIO pin muxing for the UART function.
      // This is only necessary if your part supports GPIO pin function muxing.
      // Study the data sheet to see which functions are allocated per pin.
      // TODO: change this to select the port/pin you are using
      //
      GPIOPinConfigure(GPIO_PA0_U0RX);
      GPIOPinConfigure(GPIO_PA1_U0TX);
  
      //
      // Since GPIO A0 and A1 are used for the UART function, they must be
      // configured for use as a peripheral function (instead of GPIO).
      // TODO: change this to match the port/pin you are using
      //
      GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  
      //
      // Configure the UART for 115,200, 8-N-1 operation.
      // This function uses SysCtlClockGet() to get the system clock
      // frequency.  This could be also be a variable or hard coded value
      // instead of a function call.
      //
      UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
                          (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                           UART_CONFIG_PAR_NONE));
  
      //
      // Put a character to show start of example.  This will display on the
      // terminal.
      //
      UARTCharPut(UART0_BASE, '!');
  
      //
      // Enter a loop to read characters from the UART, and write them back
      // (echo).  When a line end is received, the loop terminates.
      //
      do
      {
          //
          // Read a character using the blocking read function.  This function
          // will not return until a character is available.
          //
          cThisChar = UARTCharGet(UART0_BASE);
  
          //
          // Write the same character using the blocking write function.  This
          // function will not return until there was space in the FIFO and
          // the character is written.
          //
          UARTCharPut(UART0_BASE, cThisChar);
  
      //
      // Stay in the loop until either a CR or LF is received.
      //
      } while((cThisChar != '\n') && (cThisChar != '\r'));
  
      //
      // Put a character to show the end of the example.  This will display on
      // the terminal.
      //
      UARTCharPut(UART0_BASE, '@');
  
      //
      // Return no errors
      //
      return(0);
  }
  
  