From c3e4c9a25c2910d2d66d52215b3406b13d5b23d5 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sun, 29 Jun 2014 12:34:32 +0300 Subject: Add more board models --- boards/ek-lm4f232/hello/hello.c | 183 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 boards/ek-lm4f232/hello/hello.c (limited to 'boards/ek-lm4f232/hello/hello.c') diff --git a/boards/ek-lm4f232/hello/hello.c b/boards/ek-lm4f232/hello/hello.c new file mode 100644 index 0000000..f0709d5 --- /dev/null +++ b/boards/ek-lm4f232/hello/hello.c @@ -0,0 +1,183 @@ +//***************************************************************************** +// +// hello.c - Simple hello world example. +// +// Copyright (c) 2011-2014 Texas Instruments Incorporated. All rights reserved. +// Software License Agreement +// +// Texas Instruments (TI) is supplying this software for use solely and +// exclusively on TI's microcontroller products. The software is owned by +// TI and/or its suppliers, and is protected under applicable copyright +// laws. You may not combine this software with "viral" open-source +// software in order to form a larger program. +// +// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +// DAMAGES, FOR ANY REASON WHATSOEVER. +// +// This is part of revision 2.1.0.12573 of the EK-LM4F232 Firmware Package. +// +//***************************************************************************** + +#include +#include +#include "inc/hw_memmap.h" +#include "driverlib/fpu.h" +#include "driverlib/sysctl.h" +#include "driverlib/rom.h" +#include "driverlib/pin_map.h" +#include "driverlib/uart.h" +#include "grlib/grlib.h" +#include "drivers/cfal96x64x16.h" +#include "utils/uartstdio.h" +#include "driverlib/gpio.h" + +//***************************************************************************** +// +//! \addtogroup example_list +//!

Hello World (hello)

+//! +//! A very simple ``hello world'' example. It simply displays ``Hello World!'' +//! on the display and is a starting point for more complicated applications. +//! This example uses calls to the TivaWare Graphics Library graphics +//! primitives functions to update the display. For a similar example using +//! widgets, please see ``hello_widget''. +// +//***************************************************************************** + +//***************************************************************************** +// +// The error routine that is called if the driver library encounters an error. +// +//***************************************************************************** +#ifdef DEBUG +void +__error__(char *pcFilename, uint32_t ui32Line) +{ +} +#endif + +//***************************************************************************** +// +// Configure the UART and its pins. This must be called before UARTprintf(). +// +//***************************************************************************** +void +ConfigureUART(void) +{ + // + // Enable the GPIO Peripheral used by the UART. + // + ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); + + // + // Enable UART0 + // + ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); + + // + // Configure GPIO Pins for UART mode. + // + ROM_GPIOPinConfigure(GPIO_PA0_U0RX); + ROM_GPIOPinConfigure(GPIO_PA1_U0TX); + ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); + + // + // Use the internal 16MHz oscillator as the UART clock source. + // + UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); + + // + // Initialize the UART for console I/O. + // + UARTStdioConfig(0, 115200, 16000000); +} + +//***************************************************************************** +// +// Print "Hello World!" to the display. +// +//***************************************************************************** +int +main(void) +{ + tContext sContext; + tRectangle sRect; + + // + // 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 clocking to run directly from the crystal. + // + ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | + SYSCTL_OSC_MAIN); + + // + // Initialize the UART. + // + ConfigureUART(); + + UARTprintf("Hello, world!\n"); + + // + // Initialize the display driver. + // + CFAL96x64x16Init(); + + // + // Initialize the graphics context. + // + GrContextInit(&sContext, &g_sCFAL96x64x16); + + // + // Fill the top 24 rows of the screen with blue to create the banner. + // + sRect.i16XMin = 0; + sRect.i16YMin = 0; + sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1; + sRect.i16YMax = 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_psFontCm12); + GrStringDrawCentered(&sContext, "hello", -1, + GrContextDpyWidthGet(&sContext) / 2, 10, 0); + + // + // Say hello using the Computer Modern 40 point font. + // + GrContextFontSet(&sContext, g_psFontCm12/*g_psFontFixed6x8*/); + GrStringDrawCentered(&sContext, "Hello World!", -1, + GrContextDpyWidthGet(&sContext) / 2, + ((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24, + 0); + + // + // Flush any cached drawing operations. + // + GrFlush(&sContext); + + // + // We are finished. Hang around doing nothing. + // + while(1) + { + } +} -- cgit v1.3.1