Esempio n. 1
0
//............................................................................
void BSP_init(int argc, char *argv[]) {
    // set the system clock as specified in lm3s_config.h (20MHz from PLL)
    SystemInit();

    // enable clock to the peripherals used by the application
    SYSCTL->RCGC2 |= (1 <<  0) | (1 <<  2);      // enable clock to GPIOA & C
    __NOP();                                     // wait after enabling clocks
    __NOP();
    __NOP();

    // configure the LED and push button
    GPIOC->DIR |= USER_LED;                           // set direction: output
    GPIOC->DEN |= USER_LED;                                  // digital enable
    GPIOC->DATA_Bits[USER_LED] = 0;                   // turn the User LED off

    GPIOC->DIR &= ~PUSH_BUTTON;                       //  set direction: input
    GPIOC->DEN |= PUSH_BUTTON;                               // digital enable

    Display96x16x1Init(1);                      // initialize the OLED display
    Display96x16x1StringDraw("Dining Philos", 0, 0);
    Display96x16x1StringDraw("0 ,1 ,2 ,3 ,4", 0, 1);

    if (QS_INIT((void *)0) == 0) {       // initialize the QS software tracing
        Q_ERROR();
    }

    (void)argc;              // avoid compiler warning about unused parameters
    (void)argv;
}
Esempio n. 2
0
//............................................................................
void BSP_init(void) {
    // set the system clock as specified in lm3s_config.h (20MHz from PLL)
    SystemInit();

    // enable clock to the peripherals used by the application
    SYSCTL->RCGC2 |= 1U | (1U << 2);              // enable clock to GPIOA & C
    __NOP();                                     // wait after enabling clocks
    __NOP();
    __NOP();

    // configure the LED and push button
    GPIOC->DIR |= USER_LED;                           // set direction: output
    GPIOC->DEN |= USER_LED;                                  // digital enable
    GPIOC->DATA_Bits[USER_LED] = 0U;                  // turn the User LED off

    GPIOC->DIR &= ~PUSH_BUTTON;                       //  set direction: input
    GPIOC->DEN |= PUSH_BUTTON;                               // digital enable

    Display96x16x1Init(1U);                     // initialize the OLED display
    Display96x16x1StringDraw(&"Dining Philos"[0], 0U, 0U);
    Display96x16x1StringDraw(&"0 ,1 ,2 ,3 ,4"[0], 0U, 1U);

    Q_ALLEGE(QS_INIT(static_cast<void *>(0)));
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_GPIOPortA_IRQHandler);
    QS_USR_DICTIONARY(PHILO_STAT);
}
//*****************************************************************************
//
// Display the interrupt state on the LCD.  The currently active and pending
// interrupts are displayed.
//
//*****************************************************************************
void
DisplayIntStatus(void)
{
    unsigned long ulTemp;
    char pcBuffer[4];

    //
    // Display the currently active interrupts.
    //
    ulTemp = HWREG(NVIC_ACTIVE0);
    pcBuffer[0] = (ulTemp & 1) ? '1' : ' ';
    pcBuffer[1] = (ulTemp & 2) ? '2' : ' ';
    pcBuffer[2] = (ulTemp & 4) ? '3' : ' ';
    pcBuffer[3] = '\0';
    Display96x16x1StringDraw(pcBuffer, 24, 1);

    //
    // Display the currently pending interrupts.
    //
    ulTemp = HWREG(NVIC_PEND0);
    pcBuffer[0] = (ulTemp & 1) ? '1' : ' ';
    pcBuffer[1] = (ulTemp & 2) ? '2' : ' ';
    pcBuffer[2] = (ulTemp & 4) ? '3' : ' ';
    Display96x16x1StringDraw(pcBuffer, 78, 1);
}
Esempio n. 4
0
void Task_Display(  void *pvParameters ) {

	char				TimeString[24];
	int					Task1_Status;
	portTickType		TaskStartTime;

    //
    // Initialize the OLED display and write status.
    //
    Display96x16x1Init(true);
    Display96x16x1StringDraw( "Eduardo", 0,  0  );

    //
    //	Set up periodic execution
    //
    TaskStartTime = xTaskGetTickCount();

    while ( 1 ) {

		Task1_Status = sprintf( TimeString, "Time: %d", xPortSysTickCount );
		Task1_Status = Task1_Status;
		Display96x16x1StringDraw( TimeString, 0, 8 );

		// vTaskDelay( 500 );
		vTaskDelayUntil( &TaskStartTime, 500 );

	}

}
Esempio n. 5
0
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);

    //
    // Initialize the OLED display and write status.
    //
    Display96x16x1Init(false);
    Display96x16x1StringDraw("UART echo: UART0", 0, 0);
    Display96x16x1StringDraw("115,200, 8-N-1", 6, 1);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

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

    //
    // Set GPIO A0 and A1 as UART pins.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

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

    //
    // Enable the UART interrupt.
    //
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

    //
    // Prompt for text to be entered.
    //
    UARTSend((unsigned char *)"Enter text: ", 12);

    //
    // Loop forever echoing data through the UART.
    //
    while(1)
    {
    }
}
Esempio n. 6
0
//*****************************************************************************
//
// Print "Hello world!" to the LCD on the Stellaris evaluation board.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);

    //
    // Initialize the OLED display.
    //
    Display96x16x1Init(false);

    //
    // Hello!
    //
    Display96x16x1StringDraw("Hello World!", 0, 0);

    //
    // Finished.
    //
    while(1)
    {
    }
}
Esempio n. 7
0
//*****************************************************************************
//
// This example demonstrates the use of the watchdog timer.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);

    //
    // Initialize the OLED display and write status.
    //
    Display96x16x1Init(false);
    Display96x16x1StringDraw("Watchdog example", 0, 0);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

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

    //
    // Set GPIO C5 as an output.  This drives an LED on the board that will
    // toggle when a watchdog interrupt is processed.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5);

    //
    // Enable the watchdog interrupt.
    //
    IntEnable(INT_WATCHDOG);

    //
    // Set the period of the watchdog timer.
    //
    WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet());

    //
    // Enable reset generation from the watchdog timer.
    //
    WatchdogResetEnable(WATCHDOG0_BASE);

    //
    // Enable the watchdog timer.
    //
    WatchdogEnable(WATCHDOG0_BASE);

    //
    // Loop forever while the LED winks as watchdog interrupts are handled.
    //
    while(1)
    {
    }
}
Esempio n. 8
0
//............................................................................
void BSP_displyPhilStat(uint8_t n, char const *stat) {
    char str[2];
    str[0] = stat[0];
    str[1] = '\0';
    Display96x16x1StringDraw(str, (3*6*n + 6), 1);

    QS_BEGIN(PHILO_STAT, AO_Philo[n])     // application-specific record begin
        QS_U8(1, n);                                     // Philosopher number
        QS_STR(stat);                                    // Philosopher status
    QS_END()
}
Esempio n. 9
0
//............................................................................
void BSP_displayPhilStat(uint8_t const n, char_t const * const stat) {
    char_t str[2];
    str[0] = *stat;
    str[1] = '\0';
    Display96x16x1StringDraw(&str[0],
                             (3U*6U*static_cast<uint32_t>(n)) + 6U, 1U);

    QS_BEGIN(PHILO_STAT, AO_Philo[n])     // application-specific record begin
        QS_U8(1U, n);                                    // Philosopher number
        QS_STR(stat);                                    // Philosopher status
    QS_END()
}
Esempio n. 10
0
//............................................................................
void BSP_displayPaused(uint8_t const paused) {
    Display96x16x1StringDraw((paused != 0U) ? "P" : " ",
                             static_cast<uint32_t>(15U*6U), 0U);
}
//*****************************************************************************
//
// This is the main example program.  It checks to see that the interrupts are
// processed in the correct order when they have identical priorities,
// increasing priorities, and decreasing priorities.  This exercises interrupt
// preemption and tail chaining.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulError;

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    //
    // Initialize the OLED display and write status.
    //
    Display96x16x1Init(false);
    Display96x16x1StringDraw("Act:    Pend:   ", 0, 1);

    //
    // Configure the first three pins of GPIO port D to be outputs to indicate
    // entry/exit of one of the interrupt handlers.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,
                          GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2);
    GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, 0);

    //
    // Set up and enable the SysTick timer.  It will be used as a reference
    // for delay loops in the interrupt handlers.  The SysTick timer period
    // will be set up for one second.
    //
    SysTickPeriodSet(SysCtlClockGet());
    SysTickEnable();

    //
    // Reset the error indicator.
    //
    ulError = 0;

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

    //
    // Enable the interrupts.
    //
    IntEnable(INT_GPIOA);
    IntEnable(INT_GPIOB);
    IntEnable(INT_GPIOC);

    //
    // Indicate that the equal interrupt priority test is beginning.
    //
    Display96x16x1StringDraw("Equal Priority  ", 0, 0);

    //
    // Set the interrupt priorities so they are all equal.
    //
    IntPrioritySet(INT_GPIOA, 0x00);
    IntPrioritySet(INT_GPIOB, 0x00);
    IntPrioritySet(INT_GPIOC, 0x00);

    //
    // Reset the interrupt flags.
    //
    g_ulGPIOa = 0;
    g_ulGPIOb = 0;
    g_ulGPIOc = 0;
    g_ulIndex = 1;

    //
    // Trigger the interrupt for GPIO C.
    //
    HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;

    //
    // Put the current interrupt state on the LCD.
    //
    DisplayIntStatus();

    //
    // Verify that the interrupts were processed in the correct order.
    //
    if((g_ulGPIOa != 3) || (g_ulGPIOb != 2) || (g_ulGPIOc != 1))
    {
        ulError |= 1;
    }

    //
    // Wait two seconds.
    //
    Delay(2);

    //
    // Indicate that the decreasing interrupt priority test is beginning.
    //
    Display96x16x1StringDraw("Dec. Priority   ", 0, 0);

    //
    // Set the interrupt priorities so that they are decreasing (i.e. C > B >
    // A).
    //
    IntPrioritySet(INT_GPIOA, 0x80);
    IntPrioritySet(INT_GPIOB, 0x40);
    IntPrioritySet(INT_GPIOC, 0x00);

    //
    // Reset the interrupt flags.
    //
    g_ulGPIOa = 0;
    g_ulGPIOb = 0;
    g_ulGPIOc = 0;
    g_ulIndex = 1;

    //
    // Trigger the interrupt for GPIO C.
    //
    HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;

    //
    // Put the current interrupt state on the LCD.
    //
    DisplayIntStatus();

    //
    // Verify that the interrupts were processed in the correct order.
    //
    if((g_ulGPIOa != 3) || (g_ulGPIOb != 2) || (g_ulGPIOc != 1))
    {
        ulError |= 2;
    }

    //
    // Wait two seconds.
    //
    Delay(2);

    //
    // Indicate that the increasing interrupt priority test is beginning.
    //
    Display96x16x1StringDraw("Inc. Priority   ", 0, 0);

    //
    // Set the interrupt priorities so that they are increasing (i.e. C < B <
    // A).
    //
    IntPrioritySet(INT_GPIOA, 0x00);
    IntPrioritySet(INT_GPIOB, 0x40);
    IntPrioritySet(INT_GPIOC, 0x80);

    //
    // Reset the interrupt flags.
    //
    g_ulGPIOa = 0;
    g_ulGPIOb = 0;
    g_ulGPIOc = 0;
    g_ulIndex = 1;

    //
    // Trigger the interrupt for GPIO C.
    //
    HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;

    //
    // Put the current interrupt state on the LCD.
    //
    DisplayIntStatus();

    //
    // Verify that the interrupts were processed in the correct order.
    //
    if((g_ulGPIOa != 1) || (g_ulGPIOb != 2) || (g_ulGPIOc != 3))
    {
        ulError |= 4;
    }

    //
    // Wait two seconds.
    //
    Delay(2);

    //
    // Disable the interrupts.
    //
    IntDisable(INT_GPIOA);
    IntDisable(INT_GPIOB);
    IntDisable(INT_GPIOC);

    //
    // Disable interrupts to the processor.
    //
    IntMasterDisable();

    //
    // Print out the test results.
    //
    Display96x16x1StringDraw("Int Priority    ", 0, 0);
    if(ulError)
    {
        Display96x16x1StringDraw("=: P  >: P  <: P", 0, 1);
        if(ulError & 1)
        {
            Display96x16x1StringDraw("F", 18, 1);
        }
        if(ulError & 2)
        {
            Display96x16x1StringDraw("F", 54, 1);
        }
        if(ulError & 4)
        {
            Display96x16x1StringDraw("F", 90, 1);
        }
    }
    else
    {
        Display96x16x1StringDraw("Success.        ", 0, 1);
    }

    //
    // Finished.
    //
    while(1)
    {
    }
}
//*****************************************************************************
//
// This example demonstrates how to configure MPU regions for different levels
// of memory protection.  The following memory map is set up:
//
// 0000.0000 - 0000.1C00 - rgn 0: executable read-only, flash
// 0000.1C00 - 0000.2000 - rgn 0: no access, flash (disabled sub-region 7)
// 2000.0000 - 2000.1000 - rgn 1: read-write, RAM
// 2000.1000 - 2000.1400 - rgn 2: read-only, RAM (disabled sub-rgn 4 of rgn 1)
// 2000.1400 - 2000.2000 - rgn 1: read-write, RAM
// 4000.0000 - 4001.0000 - rgn 3: read-write, peripherals
// 4001.0000 - 4002.0000 - rgn 3: no access (disabled sub-region 1)
// 4002.0000 - 4006.0000 - rgn 3: read-write, peripherals
// 4006.0000 - 4008.0000 - rgn 3: no access (disabled sub-region 6, 7)
// E000.E000 - E000.F000 - rgn 4: read-write, NVIC
//
// The example code will attempt to perform the following operations and check
// the faulting behavior:
//
// - write to flash                         (should fault)
// - read from the disabled area of flash   (should fault)
// - read from the read-only area of RAM    (should not fault)
// - write to the read-only section of RAM  (should fault)
//
//*****************************************************************************
int
main(void)
{
    unsigned int bFail = 0;

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Initialize the OLED display and write status.
    //
    Display96x16x1Init(false);
    Display96x16x1StringDraw("MPU example", 12, 0);

    //
    // Configure an executable, read-only MPU region for flash.  It is an 8 KB
    // region with the last 1 KB disabled to result in a 7 KB executable
    // region.  This region is needed so that the program can execute from
    // flash.
    //
    MPURegionSet(0, FLASH_BASE,
                 MPU_RGN_SIZE_8K |
                 MPU_RGN_PERM_EXEC |
                 MPU_RGN_PERM_PRV_RO_USR_RO |
                 MPU_SUB_RGN_DISABLE_7 |
                 MPU_RGN_ENABLE);

    //
    // Configure a read-write MPU region for RAM.  It is an 8 KB region.  There
    // is a 1 KB sub-region in the middle that is disabled in order to open up
    // a hole in which different permissions can be applied.
    //
    MPURegionSet(1, SRAM_BASE,
                 MPU_RGN_SIZE_8K |
                 MPU_RGN_PERM_NOEXEC |
                 MPU_RGN_PERM_PRV_RW_USR_RW |
                 MPU_SUB_RGN_DISABLE_4 |
                 MPU_RGN_ENABLE);

    //
    // Configure a read-only MPU region for the 1 KB of RAM that is disabled in
    // the previous region.  This region is used for demonstrating read-only
    // permissions.
    //
    MPURegionSet(2, SRAM_BASE + 0x1000,
                 MPU_RGN_SIZE_1K |
                 MPU_RGN_PERM_NOEXEC |
                 MPU_RGN_PERM_PRV_RO_USR_RO |
                 MPU_RGN_ENABLE);

    //
    // Configure a read-write MPU region for peripherals.  The region is 512 KB
    // total size, with several sub-regions disabled to prevent access to areas
    // where there are no peripherals.  This region is needed because the
    // program needs access to some peripherals.
    //
    MPURegionSet(3, 0x40000000,
                 MPU_RGN_SIZE_512K |
                 MPU_RGN_PERM_NOEXEC |
                 MPU_RGN_PERM_PRV_RW_USR_RW |
                 MPU_SUB_RGN_DISABLE_1 |
                 MPU_SUB_RGN_DISABLE_6 |
                 MPU_SUB_RGN_DISABLE_7 |
                 MPU_RGN_ENABLE);

    //
    // Configure a read-write MPU region for access to the NVIC.  The region is
    // 4 KB in size.  This region is needed because NVIC registers are needed
    // in order to control the MPU.
    //
    MPURegionSet(4, NVIC_BASE,
                 MPU_RGN_SIZE_4K |
                 MPU_RGN_PERM_NOEXEC |
                 MPU_RGN_PERM_PRV_RW_USR_RW |
                 MPU_RGN_ENABLE);

    //
    // Need to clear the NVIC fault status register to make sure there is no
    // status hanging around from a previous program.
    //
    g_ulFaultStatus = HWREG(NVIC_FAULT_STAT);
    HWREG(NVIC_FAULT_STAT) = g_ulFaultStatus;

    //
    // Enable the MPU fault.
    //
    IntEnable(FAULT_MPU);

    //
    // Enable the MPU.  This will begin to enforce the memory protection
    // regions.  The MPU is configured so that when in the hard fault or NMI
    // exceptions, a default map will be used.  Neither of these should occur
    // in this example program.
    //
    MPUEnable(MPU_CONFIG_HARDFLT_NMI);

    //
    // Attempt to write to the flash.  This should cause a protection fault due
    // to the fact that this region is read-only.
    //
    g_ulMPUFaultCount = 0;
    HWREG(0x100) = 0x12345678;

    //
    // Verify that the fault occurred, at the expected address.
    //
    if(!((g_ulMPUFaultCount == 1) &&
         (g_ulFaultStatus == 0x82) &&
         (g_ulMMAR == 0x100)))
    {
        bFail = 1;
    }

    //
    // The MPU was disabled when the previous fault occurred, so it needs to be
    // re-enabled.
    //
    MPUEnable(MPU_CONFIG_HARDFLT_NMI);

    //
    // Attempt to read from the disabled section of flash, the upper 1 KB of
    // the 8 KB region.
    //
    g_ulMPUFaultCount = 0;
    g_ulValue = HWREG(0x1C10);

    //
    // Verify that the fault occurred, at the expected address.
    //
    if(!((g_ulMPUFaultCount == 1) &&
         (g_ulFaultStatus == 0x82) &&
         (g_ulMMAR == 0x1C10)))
    {
        bFail = 1;
    }

    //
    // The MPU was disabled when the previous fault occurred, so it needs to be
    // re-enabled.
    //
    MPUEnable(MPU_CONFIG_HARDFLT_NMI);

    //
    // Attempt to read from the read-only area of RAM, the middle 1 KB of the
    // 8 KB region.
    //
    g_ulMPUFaultCount = 0;
    g_ulValue = HWREG(0x20001040);

    //
    // Verify that the RAM read did not cause a fault.
    //
    if(g_ulMPUFaultCount != 0)
    {
        bFail = 1;
    }

    //
    // The MPU should not have been disabled since the last access was not
    // supposed to cause a fault.  But if it did cause a fault, then the MPU
    // will be disabled, so re-enable it here anyway, just in case.
    //
    MPUEnable(MPU_CONFIG_HARDFLT_NMI);

    //
    // Attempt to write to the read-only area of RAM, the middle 1 KB of the
    // 8 KB region.
    //
    g_ulMPUFaultCount = 0;
    HWREG(0x20001060) = 0xabcdef00;

    //
    // Verify that the RAM write caused a fault.
    //
    if(!((g_ulMPUFaultCount == 1) &&
         (g_ulFaultStatus == 0x82) &&
         (g_ulMMAR == 0x20001060)))
    {
        bFail = 1;
    }

    //
    // Display the results of the example program.
    //
    if(bFail)
    {
        Display96x16x1StringDraw("Failure!", 24, 1);
    }
    else
    {
        Display96x16x1StringDraw("Success!", 24, 1);
    }

    //
    // Disable the MPU, so there are no lingering side effects if another
    // program is run.
    //
    MPUDisable();

    //
    // Finished.
    //
    while(1)
    {
    }
}
Esempio n. 13
0
//*****************************************************************************
//
// This example demonstrates how to setup the PWM block to generate signals.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulPeriod;

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    //
    // Initialize the OLED display.
    //
    Display96x16x1Init(false);

    //
    // Clear the screen and thell the user what is happening.
    //
    Display96x16x1StringDraw("Generating PWM", 6, 0);
    Display96x16x1StringDraw("on PD0 and PD1", 6, 1);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    //
    // Set GPIO D0 and D1 as PWM pins.  They are used to output the PWM0 and
    // PWM1 signals.
    //
    GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Compute the PWM period based on the system clock.
    //
    ulPeriod = SysCtlClockGet() / 50000;

    //
    // Set the PWM period to 50 kHz.
    //
    PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
                    PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);

    //
    // Set PWM0 to a duty cycle of 25% and PWM1 to a duty cycle of 75%.
    //
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, ulPeriod / 4);
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, ulPeriod * 3 / 4);

    //
    // Enable the PWM0 and PWM1 output signals.
    //
    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);

    //
    // Enable the PWM generator.
    //
    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    //
    // Loop forever while the PWM signals are generated.
    //
    while(1)
    {
    }
}
//*****************************************************************************
//
// The main application.  It configures the board and then enters a loop
// to show messages on the display and blink the LEDs.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulPHYMR0;
    unsigned long ulNextTickLED = 0;
    unsigned long ulNextTickDisplay = 0;
    unsigned long ulDisplayState = 0;

    //
    // Set the clocking to directly from the crystal
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

    //
    // Since the Ethernet is not used, power down the PHY to save battery.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
    ulPHYMR0 = ROM_EthernetPHYRead(ETH_BASE, PHY_MR0);
    ROM_EthernetPHYWrite(ETH_BASE, PHY_MR0, ulPHYMR0 | PHY_MR0_PWRDN);

    //
    // Initialize the board display
    //
    Display96x16x1Init(true);

    //
    // Initialize the GPIO used for the LEDs, and then turn one LED on
    // and the other off
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, 0);
    ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5, GPIO_PIN_5);

    //
    // Set up and enable the SysTick timer to use as a time reference.
    // It will be set up for a 100 ms tick.
    //
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 10);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();

    //
    // Enter loop to run forever, blinking LEDs and printing messages to
    // the display
    //
    for(;;)
    {
        //
        // If LED blink period has timed out, then toggle LEDs.
        //
        if(g_ulTickCount >= ulNextTickLED)
        {
            //
            // Set next LED toggle timeout for 1 second
            //
            ulNextTickLED += 10;

            //
            // Toggle the state of each LED
            //
            ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_5,
                             ~ROM_GPIOPinRead(GPIO_PORTF_BASE,
                                              GPIO_PIN_4 | GPIO_PIN_5));
        }

        //
        // If display interval has elapsed, then update display state
        //
        if(g_ulTickCount >= ulNextTickDisplay)
        {
            //
            // Process the display state.  Each state, the display does
            // something different.
            //
            // Odd time intervals are used, like 5.3 seconds, to keep the
            // display updates out of sync with the LED blinking which is
            // happening on a 1 second interval.  This is just for cosmetic
            // effect, there is no technical reason it needs to be that way.
            //
            switch(ulDisplayState)
            {
                //
                // Initial state, show TEXAS INSTRUMENTS for 5.3 seconds
                //
                case 0:
                {
                    Display96x16x1StringDraw("TEXAS", 29, 0);
                    Display96x16x1StringDraw("INSTRUMENTS", 11, 1);
                    ulNextTickDisplay += 53;
                    ulDisplayState = 1;
                    break;
                }

                //
                // Next, clear display for 1.3 seconds
                //
                case 1:
                {
                    Display96x16x1Clear();
                    ulNextTickDisplay += 13;
                    ulDisplayState = 2;
                    break;
                }

                //
                // Show STELLARIS for 5.3 seconds
                //
                case 2:
                {
                    Display96x16x1StringDraw("STELLARIS", 21, 0);
                    ulNextTickDisplay += 53;
                    ulDisplayState = 3;
                    break;
                }

                //
                // Clear the previous message and then show EVALBOT on
                // the second line for 5.3 seconds
                //
                case 3:
                {
                    Display96x16x1Clear();
                    Display96x16x1StringDraw("EVALBOT", 27, 1);
                    ulNextTickDisplay += 53;
                    ulDisplayState = 4;
                    break;
                }

                //
                // Clear display for 1.3 seconds, then go back to start
                //
                case 4:
                {
                    Display96x16x1Clear();
                    ulNextTickDisplay += 13;
                    ulDisplayState = 0;
                    break;
                }

                //
                // Default state.  Should never get here, but if so just
                // go back to starting state.
                //
                default:
                {
                    ulDisplayState = 0;
                    break;
                }
            } // end switch
        } // end if
    } // end for(;;)
}
//*****************************************************************************
//
// Demonstrate the use of the boot loader.
//
//*****************************************************************************
int
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);

    //
    // Enable the UART and GPIO modules.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Make the UART pins be peripheral controlled.
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

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

    //
    // Initialize the OLED display.
    //
    Display96x16x1Init(false);

    //
    // Indicate what is happening.
    //
    Display96x16x1StringDraw("Boot Loader Two", 0, 0);
    Display96x16x1StringDraw("press select", 0, 1);

    //
    // Enable the GPIO pin to read the select button.
    //
    GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
    GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
                     GPIO_PIN_TYPE_STD_WPU);

    //
    // Wait until the select button has been pressed.
    //
    while(GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_4) != 0)
    {
    }

    //
    // Drain any data that may be in the UART fifo.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
        UARTCharGet(UART0_BASE);
    }

    //
    // Indicate that the boot loader is being called.
    //
    Display96x16x1StringDraw("awaiting update", 0, 1);

    //
    // Call the boot loader so that it will listen for an update on the UART.
    //
    (*((void (*)(void))(*(unsigned long *)0x2c)))();

    //
    // The boot loader should take control, so this should never be reached.
    // Just in case, loop forever.
    //
    while(1)
    {
    }
}
//*****************************************************************************
//
// This function is the display "task" that is called periodically by the
// Scheduler from the application main processing loop.
// This function displays a cycle of several messages on the display.
//
// Odd values are used for timeouts for some of the displayed messaged.  For
// example a message may be shown for 5.3 seconds.  This is done to keep the
// changes on the display out of sync with the LED blinking which occurs
// once per second.
//
//*****************************************************************************
void
DisplayTask(void *pvParam)
{
    static unsigned long ulState = 0;
    static unsigned long ulLastTick = 0;
    static unsigned long ulTimeout = 0;

    //
    // Check to see if the timeout has expired and it is time to change the
    // display.
    //
    if(SchedulerElapsedTicksGet(ulLastTick) > ulTimeout)
    {
        //
        // Save the current tick value to use for comparison next time through
        //
        ulLastTick = SchedulerTickCountGet();

        //
        // Switch based on the display task state
        //
        switch(ulState)
        {
            //
            // In this state, the scrolling TI logo is initialized, and the
            // state changed to next state.  A short timeout is used so that
            // the scrolling image will start next time through this task.
            //
            case 0:
            {
                ScrollImage(g_pucTILogo, sizeof(g_pucTILogo) / 2);
                ulTimeout = 1;
                ulState = 1;
                break;
            }

            //
            // In this state the TI logo is scrolled across the screen with
            // a scroll rate of this task period (each time this task is
            // called by the scheduler it advances the scroll by one pixel
            // column).
            //
            case 1:
            {
                if(ScrollImage(g_pucTILogo, 0))
                {
                    //
                    // If the scrolling is done, then advance the state and
                    // set the timeout for 1.3 seconds (next state will start
                    // in 1.3 seconds).
                    //
                    ulTimeout = 130;
                    ulState = 2;
                }
                break;
            }

            //
            // This state shows the text "STELLARIS" on the display for 5.3
            // seconds.
            //
            case 2:
            {
                Display96x16x1StringDraw("STELLARIS", 21, 0);
                ulTimeout = 530;
                ulState = 3;
                break;
            }

            //
            // This state clears the screen for 1.3 seconds.
            //
            case 3:
            {
                Display96x16x1Clear();
                ulTimeout = 130;
                ulState = 4;
                break;
            }

            //
            // This state shows "EVALBOT" for 5.3 seconds.
            //
            case 4:
            {
                Display96x16x1StringDraw("EVALBOT", 27, 0);
                ulTimeout = 530;
                ulState = 5;
                break;
            }

            //
            // This state clears the screen for 1.3 seconds.
            //
            case 5:
            {
                Display96x16x1Clear();
                ulTimeout = 130;
                ulState = 0;
                break;
            }

            //
            // The default state should not occur, but if it does, then reset
            // back to the beginning state.
            //
            default:
            {
                ulTimeout = 130;
                ulState = 0;
                break;
            }
        }
    }
}