naserial: Serial Driver Example Application

This application is a simple serial test application that can be used
as the basis of serial applications.  It does the following:

1.  The development board is initialized and the POST tests
    are executed.
2.  The ThreadX kernel is loaded.
3.  The device drivers are loaded.
4.  The TCP/IP stack is loaded.
5.  The function applicationStart() is called.
6.  Two separate threads for the two serial ports of our development
    board are created.
7.  Data is sent from one serial port (TEST_COM0) to another serial port (TEST_COM1) of 
    the NET+OS development board.  The data is stored in data.c file.
8.  Make sure these TEST_COM0, TEST_COM1, TEST_GPIO_MUX_COM0, and TEST_GPIO_MUX_COM1 
    are setup correctly for the specific platform in myHeader.h. 
    If TEST_GPIO_MUX_COM0 or TEST_GPIO_MUX_COM1 is set to BSP_GPIO_MUX_SERIAL_2_WIRE_UART,
    no hardware handshake is used.
    
This example should work on all development boards with at least 2 serial ports avaiable.

BSP Setup
    1. Make sure BSP_CLI_SERIAL_ENABLE is set to FALSE in bsp\platforms\(platform)\bsp_cli.h file.
	2. Make sure BSP_SERIAL_UART_DRIVER is set for the serial ports defined in TEST_COM0 and TEST_COM1.
       If TEST_COM0 is set to "/com/0", make sure #define BSP_SERIAL_PORT_1 is set 
       to BSP_SERIAL_UART_DRIVER in bsp\platforms\(platform)\bsp_serial.h file.
	3. Set #define BSP_INCLUDE_UDP_DEBUG_DRIVER  TRUE in bsp\platforms\(platform)\bsp_drivers.h file.
	4. Set #define BSP_STDIO_PORT	"/udpdb/0" in bsp\platforms\(platform)\bsp_sys.h file.
	5. Recompile the BSP library for your board and application.

Development Board Setup

    For ns9750_a, connectme9210, connectwime9210 or connectwiem9210 platform,
        1. Make sure the following are set in myHeader.h:
           #define TEST_COM0           "/com/0" 
           #define TEST_COM1           "/com/2"
           #define TEST_GPIO_MUX_COM0  BSP_GPIO_MUX_SERIAL_A
           #define TEST_GPIO_MUX_COM1  BSP_GPIO_MUX_SERIAL_C
        2. Make sure BSP_GPIO_MUX_SERIAL_A & BSP_GPIO_MUX_SERIAL_C are set for SERIAL UART.

    For ns9360_a platform,
        1. Make sure the following are set in myHeader.h:
            #define TEST_COM0           "/com/0"
            #define TEST_COM1           "/com/3"
            #define TEST_GPIO_MUX_COM0  BSP_GPIO_MUX_SERIAL_A
            #define TEST_GPIO_MUX_COM1  BSP_GPIO_MUX_SERIAL_D
        2. Make sure JUMPER_2 is configured properly in gpio.h
        2. Make sure BSP_GPIO_MUX_SERIAL_A & BSP_GPIO_MUX_SERIAL_D are set for SERIAL UART.

    For  connectcore9p9215_a, connectwi9p9215_a or ns9210_a platform,
        1. Make sure the following are set in myHeader.h:
            #define TEST_COM0           "/com/1"
            #define TEST_COM1           "/com/3"
            #define TEST_GPIO_MUX_COM0  BSP_GPIO_MUX_SERIAL_B
            #define TEST_GPIO_MUX_COM1  BSP_GPIO_MUX_SERIAL_D
        2. Make sure JUMPER_2 is configured properly in gpio.h
        2. Make sure BSP_GPIO_MUX_SERIAL_B & BSP_GPIO_MUX_SERIAL_D are set for SERIAL UART.

    For other platforms,
        1. the following are default configuration in myHeader.h for other platforms. 
            #define TEST_COM0           "/com/0"
            #define TEST_COM1           "/com/1"
            #define TEST_GPIO_MUX_COM0  BSP_GPIO_MUX_SERIAL_A
            #define TEST_GPIO_MUX_COM1  BSP_GPIO_MUX_SERIAL_B

           Update TEST_COM0, TEST_COM1, TEST_GPIO_MUX_COM0, or TEST_GPIO_MUX_COM1
           to proper serial ports.

Running the Application:
	1. Use static IP address.
    2. Connect one end of the serial cable to TEST_COM0, another end to TEST_COM1.
	3. Use UDP debug to see the application output.
		> udpdb <IP address>
	
		
Note:

BE SURE TO HAVE A SERIAL CABLE THAT SUPPORTS HARDWARE HANDSHAKE TO TEST THE 
HARDWARE HANDSHAKE (tie DCD to something either locally, or crossed to DTR).

- For ns7520_a board, Jumper JP6 must be OUT.
- For ns7520_a board, the MAX baudrate is 230400.
- For ns9750_a board, make sure NS9750_DEV is defined in myHeader.h
- The ns9750_a board by default does not have hardware handshaking on
  all four ports, so this step is not necessary.

End note


One GNU make file is provided.  Build the target 'image' to
generate an image that can be debugged with gdb, and the file 
image.bin which can be written to flash if the bootloader is used.
Build the target 'rom.bin' to create the file rom.bin which 
can be written to ROM if the bootloader is not used.


The following files are provided in this template.

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c          contains the applicationStart() function
data.c          contains test settings
teststart.c     contains two functions: Serialone receives data
                continuously, while Serialtwo sends data continuously.
                To test the DMA operation, add "|O_DMA" in the
                open statements for com0 and com1 and be sure to use
                hardware handshaking when setting up the com port
                registers.  The simplest way to ensure that hardware
                handshaking is chosen is to replace all "SWserlTests"
                with "serTests" in the code.

In addition, the following files in the BSP directory are built
as part of this application.

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The application build file links in the following libraries.

libbsp.a           		contains the BSP code
libtcpip.a         		contains the Net+Works TCP/IP stack
libtx.a            		contains the ThreadX kernel
libfilesys.a       		contains the file system libraries
libposix.a         		contains the POSIX layer libraries
libflash.a         		contains the Flash driver API library
libtelnsvr.a       		contains the Telnet server library
libaddp.a		   		contains the ADDP Library
libssh.a		   		contains the SSH Library
libpppintf.a			contains the PPP Interface Library
libdnsclnt.a        	contains the DNS Client library

The application uses the following files located in the
netos\src\linkerScripts directory.  These files are generated
when the BSP is built.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script
