//****************************************************************************
//
// This is the main loop that runs the application.
//
//****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run from the PLL at 50MHz.
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

    //
    // Set the system tick to fire 100 times per second.
    //
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    //
    // 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);

    //
    // Set the USB stack mode to Device mode with VBUS monitoring.
    //
    USBStackModeSet(0, USB_MODE_DEVICE, 0);

    //
    // 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.
    //
    MouseInit();
    SerialInit();

    //
    // Drop into the main loop.
    //
    while(1)
    {
        //
        // Allow the main mouse routine to run.
        //
        MouseMain();

        //
        // Allow the main serial routine to run.
        //
        SerialMain();
    }
}
Пример #2
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();
    }
}