//***************************************************************************** // // A simple application demonstrating use of the boot loader, // //***************************************************************************** int main(void) { tRectangle sRect; tContext sContext; unsigned long ulSysClock; // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); ulSysClock = ROM_SysCtlClockGet(); // // Initialize the peripherals that each of the boot loader flavors // supports. Since this example is intended for use with any of the // boot loaders and we don't know which is actually in use, we cover all // bases and initialize for serial, Ethernet and USB use here. // SetupForUART(); SetupForUSB(); // // Initialize the buttons driver. // ButtonsInit(); // // Initialize the display driver. // CFAL96x64x16Init(); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sCFAL96x64x16); // // Fill the top part of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1; sRect.sYMax = 9; GrContextForegroundSet(&sContext, ClrDarkBlue); GrRectFill(&sContext, &sRect); // // Change foreground for white text. // GrContextForegroundSet(&sContext, ClrWhite); // // Put the application name in the middle of the banner. // GrContextFontSet(&sContext, g_pFontFixed6x8); GrStringDrawCentered(&sContext, "boot-demo2", -1, GrContextDpyWidthGet(&sContext) / 2, 4, 0); GrStringDrawCentered(&sContext, "Press select", -1, GrContextDpyWidthGet(&sContext) / 2, 20, false); GrStringDrawCentered(&sContext, "button to", -1, GrContextDpyWidthGet(&sContext) / 2, 30, false); GrStringDrawCentered(&sContext, "update.", -1, GrContextDpyWidthGet(&sContext) / 2, 40, false); // // Wait for select button to be pressed. // while ((ButtonsPoll(0, 0) & SELECT_BUTTON) == 0) { ROM_SysCtlDelay(ulSysClock / 1000); } GrStringDrawCentered(&sContext, " ", -1, GrContextDpyWidthGet(&sContext) / 2, 20, true); GrStringDrawCentered(&sContext, " Updating... ", -1, GrContextDpyWidthGet(&sContext) / 2, 30, true); GrStringDrawCentered(&sContext, " ", -1, GrContextDpyWidthGet(&sContext) / 2, 40, true); // // Transfer control to the boot loader. // JumpToBootLoader(); // // The previous function never returns but we need to stick in a return // code here to keep the compiler from generating a warning. // return(0); }
//***************************************************************************** // // A simple application demonstrating use of the boot loader, // //***************************************************************************** int main(void) { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the system clock to run at 120MHz from the PLL // g_ui32SysClockFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Initialize the peripherals that each of the boot loader flavours // supports. Since this example is intended for use with any of the // boot loaders and we don't know which is actually in use, we cover all // bases and initialize for serial, Ethernet and USB use here. // SetupForUART(); SetupForUSB(); // // Enable Port J Pin 0 for exit to UART Boot loader when Pressed Low. // On the EK-TM4C1294 the weak pull up is enabled to detect button // press. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ))); GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0); HWREG(GPIO_PORTJ_BASE + GPIO_O_PUR) = GPIO_PIN_0; // // Configure Port N pin 0 as output. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))); GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0); // // If the Switch SW1 is not pressed then blink the LED D2 at 1 Hz rate // On switch SW press detection exit the blinking program and jump to // the flash boot loader. // while((GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_0) & GPIO_PIN_0) != 0x0) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0); SysCtlDelay(g_ui32SysClockFreq / 6); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0); SysCtlDelay(g_ui32SysClockFreq / 6); } // // Before passing control make sure that the LED is turned OFF. // GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0); // // Pass control to whichever flavour of boot loader the board is configured // with. // JumpToBootLoader(); // // The previous function never returns but we need to stick in a return // code here to keep the compiler from generating a warning. // return(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) { } }
//***************************************************************************** // // 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) { } }