示例#1
0
/**  
 * \brief  This API  enables the USB Module clock
 *	       registers
 * \param  Base address 
 * \return None
 */
void USBModuleClkEnable(unsigned int ulIndex, unsigned int ulBase)
{
	//
	//Call the clock enabel API
	//
	USB0ModuleClkConfig();	
}
示例#2
0
/**  
 * \brief  This API  enables the USB Module clock
 *	       registers
 * \param  Base address 
 * \return None
 */
 void USBModuleClkEnable(unsigned int ulIndex, unsigned int ulBase)
{
	//
	//Disable the module clock
	//
	USB0ModuleClkConfig();	
}
示例#3
0
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{

  
#ifdef DMA_MODE
  
    MMUConfigAndEnable();

    /* Enable Data Cache */
    CacheEnable(CACHE_DCACHE);

#endif  

	//
	//USB module clock enable
	//	
	USB0ModuleClkConfig();

	//
	//USB Interrupt enable
	//
	USBInterruptEnable();

	//
	//Delay timer setup
	//
	DelayTimerSetup();
	
	//
	// Initialize the idle timeout and reset all flags.
	//
	//g_ulIdleTimeout = 0;
	g_ulFlags = 0;

	//
	// Initialize the state to idle.
	//
	g_eMSCState = MSC_DEV_IDLE;

	USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice);	
	
#ifdef DMA_MODE
	Cppi41DmaInit(USB_INSTANCE, epInfo, NUMBER_OF_ENDPOINTS);

	for(;g_bufferIndex < NUM_OF_RX_BDs; g_bufferIndex++)
	{		
		dataBuffer = (unsigned char *)cppiDmaAllocBuffer();
		doDmaRxTransfer(USB_INSTANCE, USB_MSC_BUFER_SIZE, dataBuffer, 
							g_sMSCDevice.psPrivateData->ucOUTEndpoint);		
	}
#endif
    //
    // Drop into the main loop.
    //
    
   while(1);
 
}
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
    unsigned int i;
    unsigned char *src, *dest;

   /* MMU needs to be turned on to provide HW support unaligned 
       access to USB structures */ 
    MMUConfigAndEnable();
  
    /* Enable Data Cache */
    CacheEnable(CACHE_ALL);
 
    //
    //USB module clock enable
    //
    USB0ModuleClkConfig();

    //
    //USB Interrupt enable
    //
    USBInterruptEnable();

    //
    //Delay timer setup
    //
    DelayTimerSetup();

    CacheDataCleanInvalidateAll();

    USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice);

#ifdef DMA_MODE
    Cppi41DmaInit(USB_INSTANCE, epInfo, NUMBER_OF_ENDPOINTS);

    for(;g_bufferIndex < NUM_OF_RX_BDs; g_bufferIndex++)
    {
        dataBuffer = (unsigned char *)cppiDmaAllocBuffer();
        doDmaRxTransfer(USB_INSTANCE, USB_MSC_BUFER_SIZE, dataBuffer,
                            g_sMSCDevice.psPrivateData->ucOUTEndpoint);
    }
#endif

   while(1)
    {

    }
}
void _usb_mouse_host_init(unsigned int instance)
{
	MouseXPosition = 0;
	MouseYPosition = 0;
    if(instance == 0)
    {
		//g_eMouseState0 = STATE_MOUSE_NO_DEVICE;
		//g_eMouseUIState0 = STATE_MOUSE_NO_DEVICE;
	    //
	    // Enable Clocking to the USB controller.
	    //
	    USB0ModuleClkConfig();
    }
    else
    {
		//g_eMouseState1 = STATE_MOUSE_NO_DEVICE;
		//g_eMouseUIState1 = STATE_MOUSE_NO_DEVICE;
    }
    //
    //Setup the AINT Controller
    //
    USBInterruptEnable(instance);
	//
    // Register the host class drivers.
    //
    USBHCDRegisterDrivers(USB_INSTANCE_Host_Mouse, g_ppHostClassDrivers, g_ulNumHostClassDrivers);
    //
    // Open an instance of the mouse driver.  The mouse does not need
    // to be present at this time, this just saves a place for it and allows
    // the applications to be notified when a mouse is present.
    //
    g_ulMouseInstance = USBHMouseOpen(USB_INSTANCE_Host_Mouse, MouseCallback, g_pucMouseBuffer, MOUSE_MEMORY_SIZE);

    //
    // Initialize the power configuration. This sets the power enable signal
    // to be active high and does not enable the power fault.
    //
    USBHCDPowerConfigInit(USB_INSTANCE_Host_Mouse, USBHCD_VBUS_AUTO_HIGH);

    //
    // Initialize the host controller stack.
    //
    USBHCDInit(USB_INSTANCE_Host_Mouse, g_pHCDPool, MOUSE_MEMORY_SIZE);
    //
    // Call the main loop for the Host controller driver.
    //
    USBHCDMain(USB_INSTANCE_Host_Mouse, g_ulMouseInstance);
}
示例#6
0
/* Initialise the USB bulk device */
void usb_init()
{
	/* Zero status variables */
	USBConfigured = 0;
	USBDataAvail = 0;

	/* USB module clock enable */
    USB0ModuleClkConfig();

    /* Registering the Interrupt Service Routine (ISR) */
    IntRegister(SYS_INT_USB0, USB0DeviceIntHandler);

    /* Setting the priority for the system interrupt in AINTC - set it high to allow USB to be prempted */
    IntPrioritySet(SYS_INT_USB0, 127, AINTC_HOSTINT_ROUTE_IRQ);

    /* Enabling the system interrupt in AINTC */
    IntSystemEnable(SYS_INT_USB0);

    /* Enable the delay timer */
    DelayTimerSetup();

    /* Initialize the transmit and receive buffers */
    USBBufferInit((tUSBBuffer *)&g_sTxBulkBuffer);
    USBBufferInit((tUSBBuffer *)&g_sRxBulkBuffer);
    USBBufferInit((tUSBBuffer *)&g_sTxCDCBuffer);
    USBBufferInit((tUSBBuffer *)&g_sRxCDCBuffer);

    /* Register the two instances */
    g_psCompDevices[0].pvInstance =
        USBDBulkCompositeInit(0, (tUSBDBulkDevice *)&g_sBulkDevice);
    g_psCompDevices[1].pvInstance =
        USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice);

    /* Register our device and place it on the bus */
    USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE,
                      g_pucDescriptorData);
}
示例#7
0
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    unsigned int ulTxCount;
    unsigned int ulRxCount;
	tRectangle sRect;
	char pcBuffer[16];
	unsigned int i;
	unsigned char *src, *dest;
	
    MMUConfigAndEnable();	
	
	//
	// USB module clock enable
	//
	USB0ModuleClkConfig();

	//
	//USB interrupt enable
	//	
	USBInterruptEnable();

	//
	//LCD back light enable
	//
	LCDBackLightEnable();

	// UPD Pin setup
	//
	//
	UPDNPinControl();

	//
	//Delay timer setup
	//
	DelayTimerSetup();

	//
	//Configures raster to display image 
	//
	SetUpLCD();

	
    RasterDMAFBConfig(SOC_LCDC_0_REGS, 
					  (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
					  (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
					  PALETTE_OFFSET, FRAME_BUFFER_0);

	RasterDMAFBConfig(SOC_LCDC_0_REGS, 
					  (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
					  (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - 
					  PALETTE_OFFSET, FRAME_BUFFER_1);

	src = (unsigned char *) palette_32b;
	dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);

	// Copy palette info into buffer
	for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++)
	{
		*dest++ = *src++;
	}
		
	GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
	
	// Initialize a drawing context.
	GrContextInit(&g_sContext, &g_s35_800x480x24Display);

	/* enable End of frame interrupt */
	RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

	/* enable raster */
	RasterEnable(SOC_LCDC_0_REGS);
	
	 //
    // Fill the top 15 rows of the screen with blue to create the banner.
    //
  	sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = 23;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
  	GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, &g_sFontCm20);
    GrStringDrawCentered(&g_sContext, "usb-dev-bulk", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);

    //
    // Show the various static text elements on the color STN display.
    //
  	GrContextFontSet(&g_sContext, TEXT_FONT);
    GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 100, false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 130, false);

  
    //
    // Tell the user what we are up to.
    //
  	 DisplayStatus(&g_sContext, " Configuring USB... ");
	
    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit((tUSBBuffer *)&g_sTxBuffer);
    USBBufferInit((tUSBBuffer *)&g_sRxBuffer);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice);

    //
    // Wait for initial configuration to complete.
    //
   	DisplayStatus(&g_sContext, "Waiting for host...");

    //
    // Clear our local byte counters.
    //
    ulRxCount = 0;
    ulTxCount = 0;

    //
    // Main application loop.
    //
    while(1)
    {

        //
        // Have we been asked to update the status display?
        //
        if(g_ulFlags & COMMAND_STATUS_UPDATE)
        {
            //
            // Clear the command flag
            //
            g_ulFlags &= ~COMMAND_STATUS_UPDATE;
           	DisplayStatus(&g_sContext, g_pcStatus);
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ulTxCount != g_ulTxCount)
        {
            //
            // Take a snapshot of the latest transmit count.
            //
            ulTxCount = g_ulTxCount;

            //
            // Update the display of bytes transmitted by the UART.
            //
            usnprintf(pcBuffer, 16, " %d ", ulTxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 120, 100, true);
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ulRxCount != g_ulRxCount)
        {
            //
            // Take a snapshot of the latest receive count.
            //
            ulRxCount = g_ulRxCount;

			//
			// Update the display of bytes received by the UART.
			//
			usnprintf(pcBuffer, 16, " %d ", ulRxCount);
			GrStringDraw(&g_sContext, pcBuffer, -1, 120, 130, true);
        }
    }
}
示例#8
0
/*****************************************************************************
* 
*  This is the main loop that runs the application.
* 
*****************************************************************************/
int main(void)
{
    tRectangle sRect;

    MMUConfigAndEnable();
    
	/* Enable USB module clock */
	
	USB0ModuleClkConfig();

	/* configures arm interrupt controller to generate raster interrupt  */
	
	USBInterruptEnable();

	/* LCD Back light setup */
	
	LCDBackLightEnable();

	/* UPD Pin setup */
	
	UPDNPinControl();

	/* Delay timer setup */
	
	DelayTimerSetup();

	/* Configures raster to display image  */
	
	SetUpLCD();		
	/* Configures raster to display image  and Copy palette info into buffer */	
	LCDInit();

	GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
	
	/* Initialize a drawing context. */
	GrContextInit(&g_sContext, &g_s35_800x480x24Display);

	/* enable End of frame interrupt */
	RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

	/* enable raster */
	RasterEnable(SOC_LCDC_0_REGS);	
		
	/* Fill the top 24 rows of the screen with blue to create the banner. */

	sRect.sXMin = 0;
	sRect.sYMin = 0;
	sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
	sRect.sYMax = (MAX_ROW_NUM - 1);
	GrContextForegroundSet(&g_sContext, ClrDarkBlue);
	GrRectFill(&g_sContext, &sRect);


	/* Put a white box around the banner. */
	GrContextForegroundSet(&g_sContext, ClrWhite);
	GrRectDraw(&g_sContext, &sRect);

	/* Put the application name in the middle of the banner. */
	GrContextFontSet(&g_sContext, &g_sFontCm20);
	GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1,
						 GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);

		
     /* Show the various static text elements on the color STN display. */
     
     GrContextFontSet(&g_sContext, TEXT_FONT);
 	 GrContextForegroundSet(&g_sContext, ClrViolet);
     GrStringDraw(&g_sContext, "CDC Serial 1 :-", -1, CDC1_STR_X_POSITION,
                   CDC1_STR_Y_POSITION, false);
     GrStringDraw(&g_sContext, "CDC Serial 2 :-", -1, CDC2_STR_X_POSITION,
                   CDC1_STR_Y_POSITION, false);
 	 GrContextForegroundSet(&g_sContext, ClrWhite);

 	 GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC1_STR_X_POSITION,
 	              (CDC1_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
     GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC1_STR_X_POSITION,
                  (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false);
     GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC1_STR_X_POSITION, 
                  (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
     GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC1_STR_X_POSITION, 
                  (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false);
     DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, CDC1_BUF_METER_Y_POS);
     DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS,
                     (CDC1_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF));

 	 GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC2_STR_X_POSITION, 
 	              (CDC2_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
     GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC2_STR_X_POSITION,
                  (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false);
     GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC2_STR_X_POSITION, 
                  (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
     GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC2_STR_X_POSITION, 
                  (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false);
     DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, CDC2_BUF_METER_Y_POS);
     DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, 
                     (CDC2_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF));

     DisplayStatus(&g_sContext, " Waiting for host... ");

    /* Pass the USB library our device information, initialize the USB
       controller and connect the device to the bus.
    */ 

    g_psCompDevices[0].pvInstance =
        USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice1);
    g_psCompDevices[1].pvInstance =
        USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice2);        

    /*
      Pass the device information to the USB library and place the device
      on the bus.
    */
    USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE,
                      g_pucDescriptorData);

    
    /* Initialize the serial devices. */
    SerialInit();

    
    /* Drop into the main loop. */
    while(1)
    {
        
        /* Allow the main serial routine to run. */
        SerialMain();
    }
}
示例#9
0
int main(void)
{
    tRectangle sRect;
    unsigned int i = 0;
    unsigned char *src = (unsigned char *) palette_32b;
    unsigned char *dest = (unsigned char *) (g_pucBuffer+4);

    MMUConfigAndEnable();

    //
    //Enable USB module clock
    //
    USB0ModuleClkConfig();
    //
    //Enable DM timer 3 module clock
    //
    DMTimer3ModuleClkConfig();
    //
    //Enbale touch screen module colock
    //
    TSCADCModuleClkConfig();
    //
    //Enable touch screen ADC pinmux
    //
    TSCADCPinMuxSetUp();
    //
    //Enbale USB interrupts
    //
    USBInterruptEnable();
    //
    //Switch ON LCD back light
    //
    LCDBackLightEnable();
    //
    //UDP Pin control
    //
    UPDNPinControl();

    //
    //Delay timer setup
    //
    DelayTimerSetup();

    //
    //Configures raster to display image
    //
    SetUpLCD();
    //
    //Register touch scren interrupt
    //
    TouchIntRegister();

    IntSystemEnable(SYS_INT_TINT3);
    IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_ADC_TSC_GENINT);
    IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ);

    RasterDMAFBConfig(SOC_LCDC_0_REGS,
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
                      PALETTE_OFFSET, FRAME_BUFFER_0);

    RasterDMAFBConfig(SOC_LCDC_0_REGS,
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
                      PALETTE_OFFSET, FRAME_BUFFER_1);

    src = (unsigned char *) palette_32b;
    dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);

    // Copy palette info into buffer
    for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++)
    {
        *dest++ = *src++;
    }

    GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);

    // Initialize a drawing context.
    GrContextInit(&g_sContext, &g_s35_480x272x24Display);

    /* enable End of frame interrupt */
    RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

    /* enable raster */
    RasterEnable(SOC_LCDC_0_REGS);

    //
    // Fill the top 24 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = 23;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, &g_sFontCm20);
    GrStringDrawCentered(&g_sContext, "usb-dev-mouse", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);

    //
    // Fill the top 24 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 25;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2;
    GrContextForegroundSet(&g_sContext, ClrDarkGray);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrRed);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Draw the buttons in their initial (unpressed)state.
    //
    UpdateDisplay(g_ucButtons, true);

    //
    //Initialize touch screen
    //
    TouchInit();
    //
    //Touch screen Interrupt enbale
    //
    TouchIntEnable();
    //
    //Touch Screen Enable
    //
    TouchEnable();
    //
    // Initialize the mouse
    //
    USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);

    //
    // Drop into the main loop.
    //
    while(1)
    {
        //
        // Wait for USB configuration to complete.
        //
        while(!bConnected)
        {
        }

        //
        //Wait till someone touches the screen
        //
        while(!g_iTouch)
        {
            g_iTouch = TouchDetect();
        }

        //
        //Loop here as long as someone moving the finger/stylus on the touch screen
        //
        do
        {
            //
            //If so, read the x and Y vlaue and give it to touch handler
            //
            TouchCoOrdGet(&g_lScreenX, &g_lScreenY);
            //
            //Call touch handler
            //
            TouchHandler();

        }while(TouchDetect());
        //
        //Touch is released
        //
        g_released = 1;
        //
        //Reset the button status
        //
        g_ucButtons = 0;
        //
        //Call the touch handler to update the release status
        //
        TouchHandler();
        //
        //Reset the touch flag
        //
        g_iTouch = 0;
    }

}
示例#10
0
/*****************************************************************************
* 
*  This is the main loop that runs the application.
* 
*****************************************************************************/
int
main(void)
{
    tRectangle sRect;
	
    MMUConfigAndEnable();
    
	/* Enable USB module clock */
	
	USB0ModuleClkConfig();
	
	/* Enable DM timer 3 module clock */
	
	DMTimer3ModuleClkConfig();
	
	/* Enbale touch screen module colock */
	
	TSCADCModuleClkConfig();
	
	/* Enable touch screen ADC pinmux */
	
	TSCADCPinMuxSetUp();    

	/* configures arm interrupt controller to generate raster interrupt  */
	
	USBInterruptEnable();        
	
	/* LCD Back light setup  */
	
	LCDBackLightEnable();	
	
	/* UPD Pin setup */
	
	UPDNPinControl();

	/* Delay timer setup */
	
	DelayTimerSetup();

	/* Configures raster to display image  */
	
	SetUpLCD();		

	/* Register touch scren interrupt */
	
	TouchIntRegister();

	IntSystemEnable(SYS_INT_TINT3);
    IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ);
	IntSystemEnable(SYS_INT_ADC_TSC_GENINT);
	IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
		
    
	/* Configures raster to display image  and Copy palette info into buffer */	
	LCDInit();
	
	GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
	
	/* Initialize a drawing context. */
	GrContextInit(&g_sContext, &g_s35_480x272x24Display);

	/* enable End of frame interrupt */
	RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

	/* enable raster */
	RasterEnable(SOC_LCDC_0_REGS);

	
	/* Fill the top 24 rows of the screen with blue to create the banner. */
	
	sRect.sXMin = 0;
	sRect.sYMin = 0;
	sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
	sRect.sYMax = (MAX_ROW_NUM - 1);
	GrContextForegroundSet(&g_sContext, ClrDarkBlue);
	GrRectFill(&g_sContext, &sRect);

	/* Put a white box around the banner. */
	
	GrContextForegroundSet(&g_sContext, ClrWhite);
	GrRectDraw(&g_sContext, &sRect);

	
	/* Put the application name in the middle of the banner. */
	
	GrContextFontSet(&g_sContext, &g_sFontCm20);
	GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1,
						 GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);
    
    sRect.sXMin = 0;
    sRect.sYMin = (MAX_ROW_NUM + 1);
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2;
    GrContextForegroundSet(&g_sContext, ClrBlack);
    GrRectFill(&g_sContext, &sRect);


    
    /* Put a white box around the banner. */
    
    GrContextForegroundSet(&g_sContext, ClrRed);
    GrRectDraw(&g_sContext, &sRect);
	
    
    /* Draw the buttons in their initial (unpressed)state. */
    
    UpdateDisplay(g_ucButtons, true);	
		
    /*  Show the various static text elements on the color STN display. */
     
    GrContextFontSet(&g_sContext, TEXT_FONT);
    GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC_STR_X_POSITION,
                  CDC_STR_Y_POSITION, false);
    GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC_STR_X_POSITION,
                 (CDC_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC_STR_X_POSITION,
                  (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 3)), false);
    GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC_STR_X_POSITION,
                  (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
    DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, BUFFER_METER_Y_POS);
    DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, 
                    (BUFFER_METER_Y_POS + CDC_BUF_METER_Y_DIFF));

    /* Tell the user what we are up to. */
     
    DisplayStatus(&g_sContext, " Waiting for host... ");

	/* Initialize touch screen */
	 
	TouchInit();

	/* Touch screen Interrupt enbale */
	
	TouchIntEnable();
	
	/* Touch Screen Enable */
	
	TouchEnable();	
	
	  
    /* Pass the USB library our device information, initialize the USB
       controller and connect the device to the bus.
    */
    
    g_psCompDevices[0].pvInstance =
        USBDHIDMouseCompositeInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice);
    g_psCompDevices[1].pvInstance =
        USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice);

    
    /* Pass the device information to the USB library and place the device
       on the bus.
    */
    
    USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE,
                      g_pucDescriptorData);

    
    /* Initialize the mouse and serial devices. */
    SerialInit();
    
    /* Drop into the main loop. */
    
    while(1)
    {
        
        /* Allow the main serial routine to run. */
        
        SerialMain();
        
        /* Allow the main mouse routine to run. */
        
        MouseMain();
    }
}