nausbdev_app: USB Device Example 

The example is to show user how to develop an USB device using NET+OS USB Device 
Driver APIs.

This example is written for USB Printer Device Class and using USB Device Driver APIs 
in "usbDevApi.h".

printer.c contains all USB descriptors for printer device and functions to handle 
printer device class requests.

In printer.c, it initializes a printer device class driver with two endpoints for OUT and IN requests. 
The IN request is not really being used since this printer device is unidirectional device. 

To run this example, please follow the following steps:

1a. For ns9360_a platform

   - Set BSP_GPIO_MUX_USB_DEVICE to BSP_GPIO_MUX_USB_BIDIRECTIONAL_PHY in gpio.h

   - The example will configure GPIO pins for the USB enum signal. 
     The GPIO pins for the USB enum signal is defined PRINTER_ENUM_GPIO_PIN in printer.c.


   - Set the JUMPER_2 definition to JMP2_SERA_USB in gpio.h.

   For customizing the NS9360 Dev board, see the 9360 Jumpers and Components 
   guide, or use the following setup on JUMPER_2:

                A  B  C
            1   ====  o
            2   ====  o
            3   ====  o
            4   ====  o
            5   ====  o
            6   o  ====
            7   o  ====
            8   o  ====

1b. For connectcore9p9360_a platform

   - Set BSP_GPIO_MUX_USB_DEVICE to BSP_GPIO_MUX_USB_BIDIRECTIONAL_PHY in gpio.h

   - The example will configure GPIO pins for the USB enum signal. 
     The GPIO pins for the USB enum signal is defined PRINTER_ENUM_GPIO_PIN in printer.c.

1c. For ns9750 platform
   - This requires NS9750 development board that is configured for USB device (in hardware).

   - The example will configure GPIO pins for the USB enum signal. 
     The GPIO pins for the USB enum signal is defined PRINTER_ENUM_GPIO_PIN in printer.c.

1c. For ConnectCore 9P9215_a and Digi Connect ME 9210 development platforms
    This application requires external hardware to interconnect to 
    your Digi JumpStart Kit Development board.  This readme provides instructions 
    based on the Digi FIM Application Kit (Digi P/N DG-ACC-FIM).

    Please note it is not mandatory to use the FIM Application kit to successfully 
    run this application; prototype hardware can be built up in its place.  
    However, the FIM Application Kit provides a standard reference design platform 
    with all the hardware components and accessory items necessary for immediate 
    prototyping of NET+OS applications with FIM-based I/O capabilities.

    The FIM Application Kit (Digi P/N DG-ACC-FIM) supports the ConnectCore 9P  9215, 
    Digi Connect ME 9210, and NS9210/9215 chip development platforms.  
    Complete documentation and schematics for the FIM Application Kit are available 
    in the "Application Kit" section on the Digi technical support website at 
    www.digi.com/support.

    Please also visit the www.digiembedded.com for additional information and purchase options.


    Connecting and configuring your FIM Application Kit board
    -----------------------------------------------------------------------
    The application requires FIM0 to be configured as USB and connected to 
    the USB section of the FIM Application board.

    Please refer to the FIM Application Kit Quick Start Guide and the Hardware Reference
    Manual (HRM) for guidance on how connect and configure your FIM Application Kit board.

    BSP Configuration
    ------------------
    - Make sure GPIO pins are set for USB device signals (VP, VM, RCV, & OE_L).
      USB device signals are set up in bsp_iop.h:
            #define BSP_IOP_FIM_USB_VP           BSP_IOP_GEN_IO_0
            #define BSP_IOP_FIM_USB_VM           BSP_IOP_GEN_IO_1
            #define BSP_IOP_FIM_USB_RCV          BSP_IOP_GEN_IO_2
            #define BSP_IOP_FIM_USB_OE_L         BSP_IOP_GEN_IO_3

    - Make sure FIM0 is used for USB device in bsp_iop.h:
           #define BSP_IOP_FIM_USB_PROCESSOR          NA_IOP_PROCESSOR_PIC0

    - By default, the USB device clock is defined in bsp_iop.h:
           #define BSP_IOP_FIM_USB_DEVICE_CLOCK    300

    - The application will configure GPIO pins for the USB enum and suspend signals. 
      The GPIO pins for the USB enum and suspend signals are defined 
      PRINTER_ENUM_GPIO_PIN and PRINTER_SUSPEND_GPIO_PIN in printer.c.

    - For connectcore9p9215_a development board
      -----------------------------------------
      
        1. In gpio.h set up USB device signals by setting 
              BSP_GPIO_MUX_IOP_0_GEN_IO_0 to BSP_GPIO_MUX_USE_2ND_ALTERNATE_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_1 to BSP_GPIO_MUX_USE_2ND_ALTERNATE_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_2 to BSP_GPIO_MUX_USE_2ND_ALTERNATE_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_3 to BSP_GPIO_MUX_USE_2ND_ALTERNATE_PATH.

    - For connectme9210 development board
      -----------------------------------

        1. Disable PORT1 "/com/0" by setting
           BSP_SERIAL_PORT_1 to BSP_SERIAL_NO_DRIVER in bsp_serial.h since
           GPIO pins are shared between the PORT1 and USB device on FIM0.

        2. Use "/com/2" for dialog and stdio. In bsp_sys.h, make sure
           BSP_STDIO_PORT and BSP_DIALOG_PORT are set to "/com/2".
           
        3. In gpio.h, set up GPIO pins for FIM 0 by setting 
              BSP_GPIO_MUX_IOP_0_GEN_IO_0 to BSP_GPIO_MUX_USE_PRIMARY_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_1 to BSP_GPIO_MUX_USE_PRIMARY_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_2 to BSP_GPIO_MUX_USE_PRIMARY_PATH.
              BSP_GPIO_MUX_IOP_0_GEN_IO_3 to BSP_GPIO_MUX_USE_PRIMARY_PATH.


        4. Make sure P5 jumper is set to disable RS232.


2. Install a Generic Text Only printer driver from Windows 2000 or Windows XP
   (any unidirectional device printer driver).

3. Connect the development board and the PC using a USB cable.

4. Run this example.

5. Be sure that the PC screen shows that a USB printer is found.

6. Skip the driver installation by closing all the pop up windows regarding

7. to adding a new printer.

8. Open the printer property window and go to the "Ports" 
   dialog and select the Virtual printer port for USB.

9. Open a document using any Windows editor and print to the selected printer.

10. You should see data transfer shown in the serial port terminal.

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 with this example:

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c            contains applicationStart() function to setup different time
printer.c         contains a simple USB Printer Device application.

In addition, the following files in the BSP directory are built as part of this 
example:

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


The build file links in the following libraries:

libbsp.a               contains the BSP library
libaddp.a			   contains the ADDP Library
libtcpip.a             contains the TCP/IP stack library
libpppintf.a		   contains the PPP Interface Library
libtx.a                contains the ThreadX kernel
libfilesys.a           contains the Native File System library
libposix.a             contains the POSIX layer library
libflash.a             contains the Flash driver API library
libssh.a			   contains the SSH Library
libtelnsvr.a           contains the Telnet Server library
libdnsclnt.a           contains the DNS Client library
libusbmassstorage.a    contains the USB Mass Storage library
libusbhost.a           contains the USB Host library
libsntp.a			   contains the SNTP API 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
