예제 #1
0
파일: main.c 프로젝트: suphammer/busware
void prvSetupHardware( void ) {

    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 )    {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }

    /* Set the clocking to run from the PLL at 50 MHz */
    SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pin for the LED (PF0).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);



    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    uart_init(0, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    spi_uart_init(4, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

}
예제 #2
0
파일: main.c 프로젝트: eeshanl/ee472
void prvSetupHardware( void )
{
  /*
  If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
  a workaround to allow the PLL to operate reliably.
  */

  if( DEVICE_IS_REVA2 )
  {
    SysCtlLDOSet( SYSCTL_LDO_2_75V );
  }

  // Set the clocking to run from the PLL at 50 MHz

  SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

  /*
  Enable Port F for Ethernet LEDs
  LED0        Bit 3   Output
  LED1        Bit 2   Output
  */

  SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF );
  GPIODirModeSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
  GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

}
예제 #3
0
파일: main.c 프로젝트: peterliu2/FreeRTOS
static void prvSetupHardware( void )
{
    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 ) {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }

    /* Set the clocking to run from the PLL at 50 MHz */
    SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );
}
예제 #4
0
int main(void)
{
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    if (REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    // Set the clocking to run at 50MHz from the PLL.
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    // Initialise the OLED display.
    RIT128x96x4Init(1000000);

    // Initialise the required peripherals.
    initStatusLight();
    initialisePortB();
    initialiseButtons();
    initialisePWM();
    initialiseADC();
    initialiseUART();

	/* Create the queue used by the OLED task.  Messages for display on the OLED
	are received via this queue. */
	xSendQueue = xQueueCreate( mainSEND_QUEUE_SIZE, sizeof( xQueueMessage ) );
	vCreateQueuesAndSemaphore();

    /*-------------------------------------------
         Create tasks and start scheduler
    -------------------------------------------*/

    /* Create the required tasks */
    xTaskCreate( vSendTask, "Send Task", 240, NULL, 1, NULL);
    xTaskCreate( vLedBlink, "LED Blink", configMINIMAL_STACK_SIZE, NULL, 4, NULL );
    vStartControlTasks( xSendQueue );

	// Enable interrupts to the processor.
	IntMasterEnable();

    /* Start the scheduler so our tasks start executing. */
    vTaskStartScheduler();

    /* If all is well we will never reach here as the scheduler will now be
    running.  If we do reach here then it is likely that there was insufficient
    heap available for the idle task to be created. */
    while (1)
    {
    }
}
예제 #5
0
파일: PNDirector.c 프로젝트: blickly/ptii
        void prvSetupHardware( void )
        {
                /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
                a workaround to allow the PLL to operate reliably. */
                if( DEVICE_IS_REVA2 )
                {
                        SysCtlLDOSet( SYSCTL_LDO_2_75V );
                }
                /* Set the clocking to run from the PLL at 50 MHz */
                //SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );
                SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |        SYSCTL_XTAL_8MHZ);

                /*         Enable Port F for Ethernet LEDs
                LED0        Bit 3   Output
                LED1        Bit 2   Output */
                // Enable the peripherals used by this example.
                SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);        //UART1
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);        //UART1 pins
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);        //Select button


                /* Enable peripherals */
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
                GPIODirModeSet( GPIO_PORTF_BASE, (LED | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
                GPIOPadConfigSet( GPIO_PORTF_BASE, (LED | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );
                // Enable the GPIO pin to read the select button.
                GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_DIR_MODE_IN);
                GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

                // Set GPIO D2 and D3 as UART pins.
                GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3);
                //GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);


                // Configure the UART for 57,600, 8-N-1 operation.
                UARTConfigSetExpClk(UART1_BASE, 8000000, 57600,
                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                UART_CONFIG_PAR_NONE));
                //Enable the UART interrupt.
                //UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
                UARTEnable(UART1_BASE);
                /* Configure push buttons as inputs */
                GPIOPadConfigSet(GPIO_PORTE_BASE, BUTTON, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
                GPIODirModeSet  (GPIO_PORTE_BASE, BUTTON, GPIO_DIR_MODE_IN);
        }
예제 #6
0
파일: main2.c 프로젝트: yguo89/RTOS
// Main Function
int main (void)
{
    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
       a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 )
    {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }
	
	/* Set the clocking to run from the PLL at 50 MHz */
	SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
	                SYSCTL_XTAL_8MHZ );	
                    
	// Initialize the CS pins for every sensor port, and set them high. This is necessary for the
	// project to be used on an MCU that has all sensor ports, such as our prototype node.
	// If a different pin is used for CS, intialize and set it high also.
	GPIO_Init( SensorPort1.rom_cs_port, SensorPort1.rom_cs_pin, GPIO_DIR_MODE_OUT, 
		           GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );    		   
	GPIO_Init( SensorPort2.rom_cs_port, SensorPort2.rom_cs_pin, GPIO_DIR_MODE_OUT, 
		           GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );    
	GPIO_Init( SensorPort3.rom_cs_port, SensorPort3.rom_cs_pin, GPIO_DIR_MODE_OUT, 
		           GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );    
	GPIO_Init( SensorPort4.rom_cs_port, SensorPort4.rom_cs_pin, GPIO_DIR_MODE_OUT, 
		           GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );    
	GPIO_Init( CS_PORT, CS_PIN, GPIO_DIR_MODE_OUT, 
		           GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );    
	GPIO_Set( SensorPort1.rom_cs_port, SensorPort1.rom_cs_pin );
	GPIO_Set( SensorPort2.rom_cs_port, SensorPort2.rom_cs_pin );
	GPIO_Set( SensorPort3.rom_cs_port, SensorPort3.rom_cs_pin );
	GPIO_Set( SensorPort4.rom_cs_port, SensorPort4.rom_cs_pin );
	GPIO_Set( CS_PORT, CS_PIN ); 

    // Add the DriverEEPROM Task
    xTaskCreate(DriverEEPROM, (signed portCHAR*)"DriverEEPROM", MAIN_STACK_SIZE, NULL, MAIN_PRIORITY, NULL);
    
    // Start scheduler
    vTaskStartScheduler();
    
    // Will only get here if insufficient mem to create idle task
    return 0;
}
예제 #7
0
파일: bsp.c 프로젝트: navinars/etz-main
/* ------------------------------------------------------------------------------------------------------
 *									BSP_Init()
 *
 * Description : MCU sysctl init function.
 *
 * Argument(s) : none.
 *
 */
void BSP_Init(void)
{
	/* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 )
    {
		SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }
	
	//
    // Set the clocking to run directly from the crystal.
    //
	
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);
	
	//
    // Enable the LED.
    //
	BSP_LedInit();
	
	
    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	
    //
    // Set GPIO A0 and A1 as UART.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	
    //
    // Initialize the UART as a console for text I/O.
    //
    UARTStdioInit(0);
	
	UARTprintf("BSP initialise\n");
}
예제 #8
0
파일: main.c 프로젝트: yguo89/RTOS
// *************** SetupHardware *************** 
// Configures the necessary hardware for the board 
// Inputs: none
// Outputs: none
void SetupHardware( void )
{
    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
       a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 )
    {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }
	
	/* Set the clocking to run from the PLL at 50 MHz */
	SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
	                SYSCTL_XTAL_8MHZ );								
					
    // Initialize GPIO driver
	GPIO_InitTasks();

    // Initialize uartstdio for UART0, which is used for communicating over USB and
	// debugging. UART0 uses port A pins 0-1.
	#if ENABLE_UART_PRINTF	 	
	UART_Init();
	#endif	
	
	// Initialize SPI0 for sensor ports
	// SPI1 is initialized by transceiver code
	// XXX What does EEPROM_Init() do besides SPI_Init(0)?
	EEPROM_Init();
			 	 
	// Enable Buttons and/or LEDs depending on target board
#if EVAL_BOARD == 1 
	GPIO_Init( BUTTON_PORT, UP_BUTTON|DOWN_BUTTON|LEFT_BUTTON|RIGHT_BUTTON|SEL_BUTTON,
			   GPIO_DIR_MODE_IN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU ); 
	LED_Init(DEBUG_LED);
#else				
	LED_Init(LED1);
	LED_Init(LED2);	
	LED_Init(LED3);	
	LED_Init(LED4);	
#endif
}
//*****************************************************************************
//
// This is the main loop for the application.
//
//*****************************************************************************
int
main(void)
{
    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run directly from the PLL at 25MHz.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Enable the pull-ups on the JTAG signals.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    GPIOPadConfigSet(GPIO_PORTC_BASE,
                     GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3,
                     GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Configure CAN 0 Pins.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure GPIO Pins used for the Buttons.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1,
                     GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Configure GPIO Pin used for the LED.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Turn off the LED.
    //
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

    //
    // Enable the CAN controller.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);

    //
    // Reset the state of all the message object and the state of the CAN
    // module to a known state.
    //
    CANInit(CAN0_BASE);

    //
    // Configure the bit rate for the CAN device, the clock rate to the CAN
    // controller is fixed at 8MHz for this class of device and the bit rate is
    // set to 250000.
    //
    CANBitRateSet(CAN0_BASE, 8000000, 250000);

    //
    // Take the CAN0 device out of INIT state.
    //
    CANEnable(CAN0_BASE);

    //
    // Enable interrups from CAN controller.
    //
    CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR);

    //
    // Set up the message object that will receive all messages on the CAN
    // bus.
    //
    CANConfigureNetwork();

    //
    // Enable interrupts for the CAN in the NVIC.
    //
    IntEnable(INT_CAN0);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // Configure SysTick for a 10ms interrupt.
    //
    SysTickPeriodSet(SysCtlClockGet() / 100);
    SysTickEnable();
    SysTickIntEnable();

    //
    // Initialize the button status.
    //
    g_ucButtonStatus = GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Forground handling of interrupts.
        //
        ProcessInterrupts();

        //
        // Handle any incoming commands.
        //
        ProcessCmd();
    }
}
//*****************************************************************************
//
// The main code for the application.  It sets up the peripherals, displays the
// splash screens, and then manages the interaction between the game and the
// screen saver.
//
//*****************************************************************************
int
main(void)
{
    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run at 50MHz from the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_8);

    //
    // Get the system clock speed.
    //
    g_ulSystemClock = SysCtlClockGet();

    //
    // Enable the peripherals used by the application.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure the GPIOs used to read the state of the on-board push buttons.
    //
    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE,
                         GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
    GPIOPadConfigSet(GPIO_PORTE_BASE,
                     GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3,
                     GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
                     GPIO_PIN_TYPE_STD_WPU);

    //
    // Configure the LED, speaker, and UART GPIOs as required.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_1);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);

    //
    // Intialize the Ethernet Controller and TCP/IP Stack.
    //
    EnetInit();

    //
    // Configure the first UART for 115,200, 8-N-1 operation.
    //
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_PAR_NONE));
    UARTEnable(UART0_BASE);

    //
    // Send a welcome message to the UART.
    //
    UARTCharPut(UART0_BASE, 'W');
    UARTCharPut(UART0_BASE, 'e');
    UARTCharPut(UART0_BASE, 'l');
    UARTCharPut(UART0_BASE, 'c');
    UARTCharPut(UART0_BASE, 'o');
    UARTCharPut(UART0_BASE, 'm');
    UARTCharPut(UART0_BASE, 'e');
    UARTCharPut(UART0_BASE, '\r');
    UARTCharPut(UART0_BASE, '\n');

    //
    // Initialize the OSRAM OLED display.
    //
    RIT128x96x4Init(3500000);

    //
    // Initialize the PWM for generating music and sound effects.
    //
    AudioOn();

    //
    // Configure SysTick to periodically interrupt.
    //
    SysTickPeriodSet(g_ulSystemClock / CLOCK_RATE);
    SysTickIntEnable();
    SysTickEnable();

    //
    // Delay for a bit to allow the initial display flash to subside.
    //
    Delay(CLOCK_RATE / 4);

    //
    // Play the intro music.
    //
    AudioPlaySong(g_pusIntro, sizeof(g_pusIntro) / 2);

    //
    // Display the Texas Instruments logo for five seconds (or twelve seconds
    // if built using gcc).
    //
#if defined(gcc)
    DisplayLogo(g_pucTILogo, 120, 42, 12 * CLOCK_RATE);
#else
    DisplayLogo(g_pucTILogo, 120, 42, 5 * CLOCK_RATE);
#endif

    //
    // Display the Code Composer Studio logo for five seconds.
    //
#if defined(ccs)
    DisplayLogo(g_pucCodeComposer, 128, 34, 5 * CLOCK_RATE);
#endif

    //
    // Display the Keil/ARM logo for five seconds.
    //
#if defined(rvmdk) || defined(__ARMCC_VERSION)
    DisplayLogo(g_pucKeilLogo, 128, 40, 5 * CLOCK_RATE);
#endif

    //
    // Display the IAR logo for five seconds.
    //
#if defined(ewarm)
    DisplayLogo(g_pucIarLogo, 102, 61, 5 * CLOCK_RATE);
#endif

    //
    // Display the CodeSourcery logo for five seconds.
    //
#if defined(sourcerygxx)
    DisplayLogo(g_pucCodeSourceryLogo, 128, 34, 5 * CLOCK_RATE);
#endif

    //
    // Display the CodeRed logo for five seconds.
    //
#if defined(codered)
    DisplayLogo(g_pucCodeRedLogo, 128, 32, 5 * CLOCK_RATE);
#endif

    //
    // Throw away any button presses that may have occurred while the splash
    // screens were being displayed.
    //
    HWREGBITW(&g_ulFlags, FLAG_BUTTON_PRESS) = 0;

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Display the main screen.
        //
        if(MainScreen())
        {
            //
            // The button was pressed, so start the game.
            //
            PlayGame();
        }
        else
        {
            //
            // The button was not pressed during the timeout period, so start
            // the screen saver.
            //
            ScreenSaver();
        }
    }
}
예제 #11
0
파일: main.c 프로젝트: drthth/busware
void prvSetupHardware( void ){
	tBoolean found;
    long lEEPROMRetStatus;
    unsigned short data,data2;
	unsigned long uart_speed;
		
    /* If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    a workaround to allow the PLL to operate reliably. */
    if( DEVICE_IS_REVA2 )    {
        SysCtlLDOSet( SYSCTL_LDO_2_75V );
    }

	/* Set the clocking to run from the PLL at 50 MHz */
	SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

	/* 	Enable Port F for Ethernet LEDs
		LED0        Bit 3   Output
		LED1        Bit 2   Output */
	SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF );
	GPIODirModeSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3), GPIO_DIR_MODE_HW );
	GPIOPadConfigSet( GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3 ), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

    //
    // Enable the GPIO pin for the LED (PF0).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    if(SoftEEPROMInit(0x1F000, 0x20000, 0x800) != 0)  {
		LWIPDebug("SoftEEPROM initialisation failed.");
    }


    lEEPROMRetStatus = SoftEEPROMRead(UART0_SPEED_HIGH_ID, &data, &found);
	if(lEEPROMRetStatus == 0 && found) {
	    SoftEEPROMRead(UART0_SPEED_LOW_ID, &data2, &found);
		uart_speed = (data << 16 & 0xFFFF0000) | (data2 & 0x0000FFFF);
	    SoftEEPROMRead(UART0_CONFIG_ID, &data, &found);
	} else {
		uart_speed=115200;
		data = (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
	}

	uart_init(0, uart_speed, data);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
	
	IntPriorityGroupingSet(4);

	IntPrioritySet(INT_WATCHDOG,SET_SYSCALL_INTERRUPT_PRIORITY(5));
    IntEnable(INT_WATCHDOG); // Enable the watchdog interrupt.
    WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet());
    WatchdogResetEnable(WATCHDOG0_BASE);
    WatchdogEnable(WATCHDOG0_BASE);


	rtc_init();
	modules_init();

}
int main(void)
{
    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    
    // Set the clocking to run directly from the PLL at 25MHz.
    SysCtlClockSet(SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

    
    // Configure CAN 0 Pins.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    // Enable the CAN controller.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);

    //
    // Reset the state of all the message object and the state of the CAN
    // module to a known state.
    //
    CANInit(CAN0_BASE);

    //
    // Configure the bit rate for the CAN device, the clock rate to the CAN
    // controller is fixed at 8MHz for this class of device and the bit rate is
    // set to 250000.
    //
    CANBitRateSet(CAN0_BASE, 8000000, 1000000);

    //
    // Take the CAN0 device out of INIT state.
    //
    CANEnable(CAN0_BASE);

    //
    // Enable interrups from CAN controller.
    //
    CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR);


    // Enable interrupts for the CAN in the NVIC.
    IntEnable(INT_CAN0);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // Configure SysTick for a 10ms interrupt.
    //
    //    1 = 1s - 
    //   10 = 100ms
    //  100 = 10ms
    //  200 = 5ms
    //  500 = 2ms
    // 1000 = 1ms
    //10000 = 100us
    //20000 = 50us  - this is about the time a max CAN packet (50bytes) needs to be sent at max bit rate of 1Mbps
    SysTickPeriodSet(SysCtlClockGet() / 10);
    SysTickEnable();
    SysTickIntEnable();


    //
    // Loop forever.
    //
    while(1)
    {
       
    }
}
//*****************************************************************************
//
// This is the main loop for the application.
//
//*****************************************************************************
int
main(void)
{
    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run directly from the PLL at 50MHz.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Configure CAN 0 Pins.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure LED pin.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Configure GPIO Pin used for the LED.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Turn off the LED.
    //
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

    //
    // Enable the CAN controller.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);

    //
    // Reset the state of all the message object and the state of the CAN
    // module to a known state.
    //
    CANInit(CAN0_BASE);

    //
    // Configure the bit rate for the CAN device, the clock rate to the CAN
    // controller is fixed at 8MHz for this class of device and the bit rate is
    // set to CAN_BITRATE.
    //
    CANBitRateSet(CAN0_BASE, 8000000, CAN_BITRATE);

    //
    // Take the CAN0 device out of INIT state.
    //
    CANEnable(CAN0_BASE);

    //
    // Enable interrupts from CAN controller.
    //
    CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR);

    //
    // Enable interrupts for the CAN in the NVIC.
    //
    IntEnable(INT_CAN0);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // Set the initial state to wait for data.
    //
    g_sCAN.eState = CAN_WAIT_RX;

    //
    // Reset the buffer pointer.
    //
    g_sCAN.MsgObjectRx.pucMsgData = g_sCAN.pucBuffer;

    //
    // Set the total number of bytes expected.
    //
    g_sCAN.ulBytesRemaining = CAN_FIFO_SIZE;

    //
    // Configure the receive message FIFO.
    //
    CANReceiveFIFO(g_sCAN.pucBuffer, CAN_FIFO_SIZE);

    //
    // Initialized the LED toggle count.
    //
    g_ulLEDCount = 0;

    //
    // Loop forever.
    //
    while(1)
    {
        switch(g_sCAN.eState)
        {
            case CAN_IDLE:
            {
                //
                // Switch to sending state.
                //
                g_sCAN.eState = CAN_SENDING;

                //
                // Initialize the transmit count to zero.
                //
                g_sCAN.ulBytesTransmitted = 0;

                //
                // Schedule all of the CAN transmissions.
                //
                CANTransmitFIFO(g_sCAN.pucBuffer, CAN_FIFO_SIZE);

                break;
            }
            case CAN_SENDING:
            {
                //
                // Wait for all bytes to go out.
                //
                if(g_sCAN.ulBytesTransmitted == CAN_FIFO_SIZE)
                {
                    //
                    // Switch to wait for RX state.
                    //
                    g_sCAN.eState = CAN_WAIT_RX;
                }

                break;
            }
            case CAN_WAIT_RX:
            {
                //
                // Wait for all new data to be received.
                //
                if(g_sCAN.ulBytesRemaining == 0)
                {
                    //
                    // Switch to wait for Process data state.
                    //
                    g_sCAN.eState = CAN_PROCESS;

                    //
                    // Reset the buffer pointer.
                    //
                    g_sCAN.MsgObjectRx.pucMsgData = g_sCAN.pucBuffer;

                    //
                    // Reset the number of bytes expected.
                    //
                    g_sCAN.ulBytesRemaining = CAN_FIFO_SIZE;
                }
                break;
            }
            case CAN_PROCESS:
            {
                //
                // Handle the LED toggle.
                //
                ToggleLED();

                //
                // Return to the idle state.
                //
                g_sCAN.eState = CAN_IDLE;

                break;
            }
            default:
            {
                break;
            }
        }
    }
}
예제 #14
0
//*****************************************************************************
//
// The main loop for the user interface.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulPanel;

    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run at 50MHz from the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Set the priority of the interrupts.
    //
    IntPrioritySet(INT_CAN0, 0x00);
    IntPrioritySet(FAULT_SYSTICK, 0x20);

    //
    // Configure SysTick to generate an interrupt every millisecond.
    //
    SysTickPeriodSet(SysCtlClockGet() / 1000);
    SysTickIntEnable();
    SysTickEnable();

    //
    // Initialize the push button driver.
    //
    ButtonsInit();

    //
    // Initialize the CAN communication channel.
    //
    CANCommInit();

    //
    // Initialize the UART used to perform a "firmware update".
    //
    UpdateUARTInit();

    //
    // Initialize the display.
    //
    RIT128x96x4Init(3500000);

    //
    // Add the screen-clearing widget to the widget tree.  As the first widget
    // in the tree, this will always be drawn first, resulting in a blank
    // screen before anything else is drawn.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);

    //
    // Display the splash screen.
    //
    DisplaySplash();

    //
    // Set the CAN device ID to one.
    //
    CANSetID(1);

    //
    // The "Voltage Control Mode" panel should be displayed first.
    //
    ulPanel = PANEL_VOLTAGE;

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Determine which panel to display.
        //
        switch(ulPanel)
        {
            //
            // The "Voltage Control Mode" panel should be displayed.
            //
            case PANEL_VOLTAGE:
            {
                ulPanel = DisplayVoltage();
                break;
            }

            //
            // The "VComp Control Mode" panel should be displayed.
            //
            case PANEL_VCOMP:
            {
                ulPanel = DisplayVComp();
                break;
            }

            //
            // The "Current Control Mode" panel should be displayed.
            //
            case PANEL_CURRENT:
            {
                ulPanel = DisplayCurrent();
                break;
            }

            //
            // The "Speed Control Mode" panel should be displayed.
            //
            case PANEL_SPEED:
            {
                ulPanel = DisplaySpeed();
                break;
            }

            //
            // The "Position Control Mode" panel should be displayed.
            //
            case PANEL_POSITION:
            {
                ulPanel = DisplayPosition();
                break;
            }

            //
            // The "Configuration" panel should be displayed.
            //
            case PANEL_CONFIGURATION:
            {
                ulPanel = DisplayConfig();
                break;
            }

            //
            // The "Device List" panel should be displayed.
            //
            case PANEL_DEV_LIST:
            {
                ulPanel = DisplayDevList();
                break;
            }

            //
            // The "Firmware Update" panel should be displayed.
            //
            case PANEL_UPDATE:
            {
                ulPanel = DisplayUpdate();
                break;
            }

            //
            // The "Help" panel should be displayed.
            //
            case PANEL_HELP:
            {
                ulPanel = DisplayHelp();
                break;
            }

            //
            // The "About" panel should be displayed.
            //
            case PANEL_ABOUT:
            {
                ulPanel = DisplayAbout();
                break;
            }
        }
    }
}
예제 #15
0
//*****************************************************************************
//
// This example demonstrates the use of PWM for playing audio.
//
//*****************************************************************************
int
main(void)
{
    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    //
    // Enable the peripherals used by the application.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

    //
    // Configure the GPIOs used to read the state of the on-board push buttons.
    //
    GPIOPinTypeGPIOInput(GPIO_PORTG_BASE,
                         (GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |
                          GPIO_PIN_7));
    GPIOPadConfigSet(GPIO_PORTG_BASE,
                     (GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |
                      GPIO_PIN_7), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Initialize the OLED display and print out the directions.
    //
    RIT128x96x4Init(1000000);
    RIT128x96x4StringDraw("Audio Playback via", 10, 16, 15);
    RIT128x96x4StringDraw("Class-D Amplifier", 12, 24, 15);
    RIT128x96x4StringDraw("Press Up for Vol+", 12, 40, 15);
    RIT128x96x4StringDraw("Press Down for Vol-", 6, 48, 15);
    RIT128x96x4StringDraw("Press Left for PCM", 10, 56, 15);
    RIT128x96x4StringDraw("Press Right for ADPCM", 0, 64, 15);
    RIT128x96x4StringDraw("Press Select to stop", 4, 72, 15);

    //
    // Initialize the Class-D amplifier driver.
    //
    ClassDInit(SysCtlClockGet());

    //
    // Wait until the Class-D amplifier driver is done starting up.
    //
    while(ClassDBusy())
    {
    }

    //
    // Start playback of the PCM stream.
    //
    ClassDPlayPCM(g_pucPCMData, sizeof(g_pucPCMData));

    //
    // Set up and enable SysTick.
    //
    SysTickPeriodSet(SysCtlClockGet() / 200);
    SysTickEnable();
    SysTickIntEnable();

    //
    // Loop forever.
    //
    while(1)
    {
    }
}
예제 #16
0
// *****************************************************************************
// InitialiseHW
// Setup the processor
// *****************************************************************************
void InitialiseHW ( void )
{
	// If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
	// a workaround to allow the PLL to operate reliably.
	//
	if(REVISION_IS_A2)
	{
		SysCtlLDOSet(SYSCTL_LDO_2_75V);
	}

	// 50 MHz
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	// Enable Peripherals
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

	// Set interrupt priority levels
	IntPrioritySet(INT_ETH, 0x20);
	IntPrioritySet(FAULT_SYSTICK, 0x40);

	//
	// Enable the peripherals that should continue to run when the processor
	// is sleeping.
	//
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOG);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOH);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART1);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ETH);

	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER0);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER1);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER2);

    //
    // Enable peripheral clock gating.  Note that this is required in order to
    // measure the the processor usage.
    //
    SysCtlPeripheralClockGating(true);

	// Grab the Config from Flash
	SysConfigInit();

	AdcInit();
	pwmInit();
	RelayInit();

	//usrand(0x23482937);

	// Note (From the DriverLib) :
	// It takes five clock cycles after the write to enable a peripheral
	// before the the peripheral is actually enabled.  During this time, attempts
	// to access the peripheral result in a bus fault.  Care should be taken
	// to ensure that the peripheral is not accessed during this brief time
	// period.

	#ifdef SERIAL_ENABLED
		Serial_Init();
	#endif

	#ifdef UPNP_ENABLED
		UPnPInit();
	#endif

	Ethernet_Init();

	#ifdef LOGIC_ENABLED
		LogicStartStop(true);
	#endif

	#ifdef SOLDERBRIDGES_ENABLED
		SB_Init();
		ExtGpio_Init();

		SolderBridge_StartScan();
		ExtGpio_Scan();
	#endif

	#ifdef SPLASHPIXEL_ENABLED
		SP_Init();
	#endif

	// Set up the GPIO as specified by the user
	UserGpioInit();

	// Most, if not all M3's have a SysTick which you can use for scheduling your code
	SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
	SysTickEnable();
	SysTickIntEnable();
}
예제 #17
0
파일: main.c 프로젝트: gvb/quickstart
/**
 * Initialize the processor hardware.
 *
 * \req \req_init The \program \shall initialize the hardware.
 */
void prvSetupHardware(void)
{
	/*
	 * If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.
	 * This is a workaround to allow the PLL to operate reliably.
	 */
	if( REVISION_IS_A2 ) {
		SysCtlLDOSet( SYSCTL_LDO_2_75V );
	}

	/**
	 * Set the clocking to run from the PLL at 50 MHz
	 */
#if (PART == LM3S8962)

	SysCtlClockSet(
		SYSCTL_SYSDIV_4
		| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

#elif (PART == LM3S9B96)

	SysCtlClockSet(
		SYSCTL_SYSDIV_4
		| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ );

	/* 80MHz operation, change FreeRTOSConfig.h too */
 /* 	SysCtlClockSet(
		SYSCTL_SYSDIV_2_5
		| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ );
*/

#elif (PART == LM3S2110)
	//
	// Set the clocking to run directly from the PLL at 25MHz.
	//
	SysCtlClockSet(SYSCTL_SYSDIV_8 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
		       SYSCTL_XTAL_8MHZ);
#endif

	/*
	 * Initialize the ARM peripherals that are used.  All the GPIOs
	 * are initialized because the processor I/O page references
	 * all of them.
	 */
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);

#if (PART != LM3S2110)
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
#endif

#if (PART==LM3S8962)
	/*
	 * Configure the GPIOs used to read the on-board buttons.
	 */
	GPIOPinTypeGPIOInput(GPIO_PORTE_BASE,
		GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
	GPIOPadConfigSet(GPIO_PORTE_BASE,
		GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3,
		GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
		GPIO_PIN_TYPE_STD_WPU);

	/*
	 * Configure the LED and speaker GPIOs.
	 */
	GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0);
#endif

	/*
	 * UART0 is our debug ("spew") I/O.  Configure it for 115200,
	 * 8-N-1 operation.
	 */
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
		( UART_CONFIG_WLEN_8
		| UART_CONFIG_STOP_ONE
		| UART_CONFIG_PAR_NONE ));
}
예제 #18
0
//*****************************************************************************
//
// A simple demonstration of the features of the Stellaris Graphics Library.
//
//*****************************************************************************
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run from the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Initialize the display driver.
    //
    Kitronix320x240x16_SSD2119Init();

    //
    // Turn on the backlight.
    //
    Kitronix320x240x16_SSD2119BacklightOn(255);

    //
    // Set graphics library text rendering defaults.
    //
    GrLibInit(&GRLIB_INIT_STRUCT);

    //
    // Set the string table and the default language.
    //
    GrStringTableSet(STRING_TABLE);

    //
    // Set the default language.
    //
    ChangeLanguage(GrLangEnUS);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119);

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

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

    //
    // Load the static strings from the string table.  These strings are
    // independent of the language in use but we store them in the string
    // table nonetheless since (a) we may be using codepage remapping in
    // which case it would be difficult to hardcode them into the app source
    // anyway (ASCII or ISO8859-1 text would not render properly with the
    // remapped custom font) and (b) even if we're not using codepage remapping,
    // we may have generated a custom font from the string table output and
    // we want to make sure that all glyphs required by the application are
    // present in that font.  If we hardcode some text in the application
    // source and don't put it in the string table, we run the risk of having
    // characters missing in the font.
    //
    GrStringGet(STR_ENGLISH, g_pcEnglish, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_DEUTSCH, g_pcDeutsch, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_ESPANOL, g_pcEspanol, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_ITALIANO, g_pcItaliano, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_CHINESE, g_pcChinese, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_KOREAN, g_pcKorean, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_JAPANESE, g_pcJapanese, MAX_LANGUAGE_NAME_LEN);
    GrStringGet(STR_PLUS, g_pcPlus, 2);
    GrStringGet(STR_MINUS, g_pcMinus, 2);

    //
    // Put the application name in the middle of the banner.
    //
    GrStringGet(STR_APPNAME, g_pcBuffer, SCOMP_MAX_STRLEN);
    GrContextFontSet(&sContext, FONT_20PT);
    GrStringDrawCentered(&sContext, g_pcBuffer, -1,
                         GrContextDpyWidthGet(&sContext) / 2, 10, 0);

    //
    // Initialize the sound driver.
    //
    SoundInit();

    //
    // Initialize the touch screen driver and have it route its messages to the
    // widget tree.
    //
    TouchScreenInit();
    TouchScreenCallbackSet(WidgetPointerMessage);

    //
    // Add the title block and the previous and next buttons to the widget
    // tree.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);

    //
    // Add the first panel to the widget tree.
    //
    g_ulPanel = 0;
    WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);

    //
    // Set the string for the title.
    //
    CanvasTextSet(&g_sTitle, g_pcTitle);

    //
    // Initialize the pointer to the button text.
    //
    PushButtonTextSet(&g_sFirmwareUpdateBtn, g_pcUpdateButton);

    //
    // Issue the initial paint request to the widgets.
    //
    WidgetPaint(WIDGET_ROOT);

    //
    // Loop forever unless we receive a signal that a firmware update has been
    // requested.
    //
    while(!g_bFirmwareUpdate)
    {
        //
        // Process any messages in the widget message queue.
        //
        WidgetMessageQueueProcess();
    }

    //
    // If we drop out, a firmware update request has been made.  We call
    // WidgetMessageQueueProcess once more to ensure that any final messages
    // are processed then jump into the bootloader.
    //
    WidgetMessageQueueProcess();

    //
    // Wait a while for the last keyboard click sound to finish.  This is about
    // 500mS since the delay loop is 3 cycles long.
    //
    SysCtlDelay(SysCtlClockGet() / 6);

    //
    // Pass control to the bootloader.
    //
    JumpToBootLoader();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }
}
예제 #19
0
//*****************************************************************************
//
// A simple demonstration of the features of the Stellaris Graphics Library.
//
//*****************************************************************************
int
main(void)
{
    tContext sContext;
    tRectangle sRect;

    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run from the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Initialize the display driver.
    //
    Kitronix320x240x16_SSD2119Init();

    //
    // Turn on the backlight.
    //
    Kitronix320x240x16_SSD2119BacklightOn(255);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sKitronix320x240x16_SSD2119);

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

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

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&sContext, g_pFontCm20);
    GrStringDrawCentered(&sContext, "grlib demo", -1,
                         GrContextDpyWidthGet(&sContext) / 2, 11, 0);

    //
    // Initialize the sound driver.
    //
    SoundInit();

    //
    // Initialize the touch screen driver and have it route its messages to the
    // widget tree.
    //
    TouchScreenInit();
    TouchScreenCallbackSet(WidgetPointerMessage);

    //
    // Add the title block and the previous and next buttons to the widget
    // tree.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);

    //
    // Add the first panel to the widget tree.
    //
    g_ulPanel = 0;
    WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);
    CanvasTextSet(&g_sTitle, g_pcPanelNames[0]);

    //
    // Issue the initial paint request to the widgets.
    //
    WidgetPaint(WIDGET_ROOT);

    //
    // Loop forever unless we receive a signal that a firmware update has been
    // requested.
    //
    while(!g_bFirmwareUpdate)
    {
        //
        // Process any messages in the widget message queue.
        //
        WidgetMessageQueueProcess();
    }

    //
    // If we drop out, a firmware update request has been made.  We call
    // WidgetMessageQueueProcess once more to ensure that any final messages
    // are processed then jump into the bootloader.
    //
    WidgetMessageQueueProcess();

    //
    // Wait a while for the last keyboard click sound to finish.  This is about
    // 500mS since the delay loop is 3 cycles long.
    //
    SysCtlDelay(SysCtlClockGet() / 6);

    //
    // Pass control to the bootloader.
    //
    JumpToBootLoader();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }
}