summaryrefslogtreecommitdiff
path: root/boards/ek-tm4c1294xl/hello/hello.c
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2014-03-16 14:31:22 +0200
committerYuval Adam <yuv.adm@gmail.com>2014-03-16 14:31:22 +0200
commitac4fd8e8340886f455add8cf92ee1c8458b8ae19 (patch)
treefdeb96af9d57573855405fb5099468244772cd49 /boards/ek-tm4c1294xl/hello/hello.c
parent821e3405f23958760f7c27e8934940abfed3d5cb (diff)
Add ek-tm4c1294xl example projects
Diffstat (limited to 'boards/ek-tm4c1294xl/hello/hello.c')
-rw-r--r--boards/ek-tm4c1294xl/hello/hello.c160
1 files changed, 160 insertions, 0 deletions
diff --git a/boards/ek-tm4c1294xl/hello/hello.c b/boards/ek-tm4c1294xl/hello/hello.c
new file mode 100644
index 0000000..4bd4c04
--- /dev/null
+++ b/boards/ek-tm4c1294xl/hello/hello.c
@@ -0,0 +1,160 @@
+//*****************************************************************************
+//
+// hello.c - Simple hello world example.
+//
+// Copyright (c) 2013-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-TM4C1294XL Firmware Package.
+//
+//*****************************************************************************
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "driverlib/gpio.h"
+#include "drivers/pinout.h"
+#include "driverlib/pin_map.h"
+#include "driverlib/rom.h"
+#include "driverlib/rom_map.h"
+#include "driverlib/sysctl.h"
+#include "driverlib/uart.h"
+#include "utils/uartstdio.h"
+
+//*****************************************************************************
+//
+//! \addtogroup example_list
+//! <h1>Hello World (hello)</h1>
+//!
+//! A very simple ``hello world'' example. It simply displays ``Hello World!''
+//! on the UART and is a starting point for more complicated applications.
+//!
+//! Open a terminal with 115,200 8-N-1 to see the output for this demo.
+//
+//*****************************************************************************
+
+//*****************************************************************************
+//
+// System clock rate in Hz.
+//
+//*****************************************************************************
+uint32_t g_ui32SysClock;
+
+//*****************************************************************************
+//
+// 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);
+
+ //
+ // Initialize the UART for console I/O.
+ //
+ UARTStdioConfig(0, 115200, g_ui32SysClock);
+}
+
+//*****************************************************************************
+//
+// Print "Hello World!" to the UART on the Intelligent UART Module.
+//
+//*****************************************************************************
+int
+main(void)
+{
+ //
+ // Run from the PLL at 120 MHz.
+ //
+ g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
+ SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
+ SYSCTL_CFG_VCO_480), 120000000);
+
+ //
+ // Configure the device pins.
+ //
+ PinoutSet(false, false);
+
+ //
+ // Enable the GPIO pins for the LED D1 (PN1).
+ //
+ ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);
+
+ //
+ // Initialize the UART.
+ //
+ ConfigureUART();
+
+ //
+ // Hello!
+ //
+ UARTprintf("Hello, world!\n");
+
+ //
+ // We are finished. Hang around flashing D1.
+ //
+ while(1)
+ {
+ //
+ // Turn on D1.
+ //
+ LEDWrite(CLP_D1, 1);
+
+ //
+ // Delay for a bit.
+ //
+ SysCtlDelay(g_ui32SysClock / 10 / 3);
+
+ //
+ // Turn off D1.
+ //
+ LEDWrite(CLP_D1, 0);
+
+ //
+ // Delay for a bit.
+ //
+ SysCtlDelay(g_ui32SysClock / 10 / 3);
+ }
+}