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/dk-tm4c129x/uart_echo/uart_echo.c | 207 +++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 boards/dk-tm4c129x/uart_echo/uart_echo.c (limited to 'boards/dk-tm4c129x/uart_echo/uart_echo.c') diff --git a/boards/dk-tm4c129x/uart_echo/uart_echo.c b/boards/dk-tm4c129x/uart_echo/uart_echo.c new file mode 100644 index 0000000..83d1507 --- /dev/null +++ b/boards/dk-tm4c129x/uart_echo/uart_echo.c @@ -0,0 +1,207 @@ +//***************************************************************************** +// +// uart_echo.c - Example for reading data from and writing data to the UART in +// an interrupt driven fashion. +// +// 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 DK-TM4C129X Firmware Package. +// +//***************************************************************************** + +#include +#include +#include "inc/hw_ints.h" +#include "inc/hw_memmap.h" +#include "inc/hw_types.h" +#include "driverlib/debug.h" +#include "driverlib/gpio.h" +#include "driverlib/interrupt.h" +#include "driverlib/sysctl.h" +#include "driverlib/uart.h" +#include "driverlib/rom.h" +#include "driverlib/rom_map.h" +#include "grlib/grlib.h" +#include "drivers/kentec320x240x16_ssd2119.h" +#include "drivers/frame.h" +#include "drivers/pinout.h" + +//***************************************************************************** +// +//! \addtogroup example_list +//!

UART Echo (uart_echo)

+//! +//! This example application utilizes the UART to echo text. The first UART +//! (connected to the FTDI virtual serial port on the evaluation board) will be +//! configured in 115,200 baud, 8-n-1 mode. All characters received on the +//! UART are transmitted back to the UART. +// +//***************************************************************************** + +//***************************************************************************** +// +// The error routine that is called if the driver library encounters an error. +// +//***************************************************************************** +#ifdef DEBUG +void +__error__(char *pcFilename, uint32_t ui32Line) +{ +} +#endif + +//***************************************************************************** +// +// The UART interrupt handler. +// +//***************************************************************************** +void +UARTIntHandler(void) +{ + uint32_t ui32Status; + + // + // Get the interrrupt status. + // + ui32Status = ROM_UARTIntStatus(UART0_BASE, true); + + // + // Clear the asserted interrupts. + // + ROM_UARTIntClear(UART0_BASE, ui32Status); + + // + // Loop while there are characters in the receive FIFO. + // + while(ROM_UARTCharsAvail(UART0_BASE)) + { + // + // Read the next character from the UART and write it back to the UART. + // + ROM_UARTCharPutNonBlocking(UART0_BASE, + UARTCharGetNonBlocking(UART0_BASE)); + } +} + +//***************************************************************************** +// +// Send a string to the UART. +// +//***************************************************************************** +void +UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count) +{ + // + // Loop while there are more characters to send. + // + while(ui32Count--) + { + // + // Write the next character to the UART. + // + ROM_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++); + } +} + +//***************************************************************************** +// +// This example demonstrates how to send a string of data to the UART. +// +//***************************************************************************** +int +main(void) +{ + uint32_t ui32SysClock; + tContext sContext; + + // + // Run from the PLL at 120 MHz. + // + ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | + SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | + SYSCTL_CFG_VCO_480), 120000000); + + // + // Configure the device pins. + // + PinoutSet(); + + // + // Initialize the display driver. + // + Kentec320x240x16_SSD2119Init(ui32SysClock); + + // + // Initialize the graphics context. + // + GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); + + // + // Draw the application frame. + // + FrameDraw(&sContext, "uart-echo"); + + // + // Display UART configuration on the display. + // + GrStringDraw(&sContext, "Port:", -1, 70, 70, 0); + GrStringDraw(&sContext, "Baud:", -1, 70, 95, 0); + GrStringDraw(&sContext, "Data:", -1, 70, 120, 0); + GrStringDraw(&sContext, "Parity:", -1, 70, 145, 0); + GrStringDraw(&sContext, "Stop:", -1, 70, 170, 0); + GrStringDraw(&sContext, "Uart 0", -1, 150, 70, 0); + GrStringDraw(&sContext, "115,200 bps", -1, 150, 95, 0); + GrStringDraw(&sContext, "8 Bit", -1, 150, 120, 0); + GrStringDraw(&sContext, "None", -1, 150, 145, 0); + GrStringDraw(&sContext, "1 Bit", -1, 150, 170, 0); + + // + // Enable the (non-GPIO) peripherals used by this example. PinoutSet() + // already enabled GPIO Port A. + // + ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); + + // + // Enable processor interrupts. + // + IntMasterEnable(); + + // + // Configure the UART for 115,200, 8-N-1 operation. + // + ROM_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200, + (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | + UART_CONFIG_PAR_NONE)); + + // + // Enable the UART interrupt. + // + ROM_IntEnable(INT_UART0); + ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); + + // + // Prompt for text to be entered. + // + UARTSend((uint8_t *)"Enter text: ", 12); + + // + // Loop forever echoing data through the UART. + // + while(1) + { + } +} -- cgit v1.3.1