\ ---------------------------------------------------------------------
\ DATE:        9/26/2005
\ VERSION:     1.4, for QED4 or Panel-Touch Controller with WildCard Carrier Board
\ ---------------------------------------------------------------------
\ This is the driver code for the Dual UART Module.
\ Please see the UART Module User Guide for more details.
\ The accompanying file named UModDemo.4th presents a demonstration program.
\ This code provides an interface to the hardware serial ports
\ available on the UART Module.  Each UART is supported by 16-character
\ input and output FIFO (First-in/First-Out) buffers.
\ After connecting an appropriate communications cable from to the module,
\ communications can be established using a few simple commands.
\ The communications interface supports 5 to 8 bits per char; odd, even, fixed or
\ no parity; 1 to 2 stop bits, and up to 56 KBaud transfers.
\ For detailed specifications on control of the communications port, refer
\ to the UART data sheet (Texas Instruments Part# TL16C552A).
\
\ After loading this file, you can load UModDemo.4th.
\ This is an illustrative demonstration program that
\ shows how to initialize the uarts for RS232 operation and run dual
\ QED monitor tasks using the two UART Module serial ports.
\ NOTE: MAKE SURE THAT THE UART_MODULE_NUM CONSTANT IN UModDemo.4th
\     MATCHES YOUR HARDWARE JUMPER SETTINGS!!

\ Rev history:
\ Rev 1.4 9/26/2005 mgd: added Flush_UART called by RS485_Rcv_UART
\ to solve temperature-dependent loading of garbage into receive fifo
\ when RS485 receiver is off/tristated.  We flush the fifo before going
\ to transmit mode.
\ Starting at Rev 1.4, we're synchronizing rev numbers of queued and non-queued.
\ Any changes unique to one or the other source code fork will be
\ given minor rev numbers (e.g., Rev 1.41).

\ Rev 1.3 4/05/2005 mgd: added queued serial receiver support for 1 module only.
\ Source code was forked at this rev to queued and non-queued (standard) drivers.

\ Rev 1.2 11/10/04 jlw: Moved the line setting the base for the constants
\ to the inline section.  Previously, the library.4th file lacked the
\ base setting line. Now, the base is set within the inline section.
\ This bug fix doesn't effect the binary as the base is set below; it
\ just wasn't making it into the library.4th file.
\
\ Rev 1.1 8/13/02: added Loop_Until_Xmit_Done which is similar to
\       Wait_Until_Xmit_Done but does not PAUSE while waiting.
\       This is useful for avoiding a task switch while sending a
\       terminating command character over an RS485 link so that an immediate
\       switch to receive mode can be made after the character is transmitted.
\       Note that the user may have to disable interrupts to ensure that
\       no task switch occurs if the timeslicer is enabled.

\ ---------------------------------------------------------------------
\ Important user constants:
\ CHANNEL1 CHANNEL2
\ RS232  RS422  RS485 NOT_USED
\ NO_PARITY EVEN_PARITY ODD_PARITY LOW_PARITY HIGH_PARITY
\
\ Important user functions:
\ Set_Data_Format ( numbits\numStopBits\parity_code\channel_num\module_num -- )
\ Set_Baud ( baud\channel_num\module_num -- )
\ Set_Protocols ( Ch1_modem_support\Ch1_protocol\Ch2_protocol\module_num -- error? )
\ Send_Break  ( channel_num\module_num -- )
\ End_Break ( channel_num\module_num -- )
\ Wait_Until_Xmit_Done  ( channel_num\module_num -- )
\ Loop_Until_Xmit_Done  ( channel_num\module_num -- )
\ RS485_Xmit_UART ( channel_num\module_num -- )
\ RS485_Rcv_When_Xmit_Done  ( channel_num\module_num -- )
\ Emit_UART ( char\channel_num\module_num -- )
\ Ask_Key_UART ( channel_num\module_num -- flag )
\ Key_UART ( channel_num\module_num -- char )
\ Note: additional modem control functions are provided in this file.
\
\ Helpful demonstration functions (in the UModDemo.4th file):
\ UART_MODULE_NUM \ MUST match hardware jumper settings!
\ Default_UART_Init ( module_num -- result ) \ demonstrates how to initialize module
\ CH1_EMIT  ( char -- )     CH2_EMIT ( char -- )
\ CH1_Ask_KEY ( -- flag )   CH2_Ask_KEY ( -- flag )
\ CH1_KEY ( -- char )     CH2_KEY ( -- char )
\ RUN_DEMO    ( -- )

\ ---------------------------------------------------------------------
\ Notes:
\
\ Disclaimer: THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
\             ANY WARRANTIES OR REPRESENTATIONS EXPRESS OR IMPLIED,
\             INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES
\             OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
\
\ *********************************************************************

