Commit fd763846 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

TI Tiva TM4C129 support and example project

PUBLISHED_FROM=c3d59657adff247f565bf0be59192e32d5d0bbf6
parent f4f310cf
......@@ -3,7 +3,7 @@
# `wildcard ./*/` works in both linux and linux/wine, while `wildcard */` enumerates nothing under wine
SUBDIRS = $(sort $(dir $(wildcard ./*/)))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./MSP432/ ./NXP_LPC4088/ ./NXP_K64/ ./PIC32/ ./STM32F4_CC3100/ ./mbed/ ./nRF51/ ./nRF52/ ./WinCE/, $(SUBDIRS))
SUBDIRS:=$(filter-out ./ ./CC3200/ ./ESP8266_RTOS/ ./mbed/ ./MSP432/ ./nRF51/ ./nRF52/ ./NXP_K64/ ./NXP_LPC4088/ ./PIC32/ ./STM32F4_CC3100/ ./TM4C129/ ./WinCE/, $(SUBDIRS))
ifeq ($(OS), Windows_NT)
SUBDIRS:=$(filter-out ./netcat/ ./raspberry_pi_mjpeg_led/ ./captive_dns_server/, $(SUBDIRS))
......
clean:
rm -rf */Debug */Release */.launches */.settings */.xdchelp */drivers */utils
<?xml version="1.0" encoding="UTF-8" ?>
<?ccsproject version="1.0"?>
<projectOptions>
<deviceVariant value="Cortex M.TM4C129ENCPDT"/>
<deviceFamily value="TMS470"/>
<deviceEndianness value="little"/>
<codegenToolVersion value="5.2.8"/>
<isElfFormat value="true"/>
<rts value="libc.a"/>
<createSlaveProjects value=""/>
<isTargetManual value="true"/>
</projectOptions>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Mongoose_TM4C129_BM</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.ti.ccstudio.core.ccsNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>drivers/pinout.c</name>
<type>1</type>
<locationURI>SDK_ROOT/examples/boards/ek-tm4c129exl/drivers/pinout.c</locationURI>
</link>
<link>
<name>utils/lwiplib.c</name>
<type>1</type>
<locationURI>SDK_ROOT/utils/lwiplib.c</locationURI>
</link>
<link>
<name>utils/uartstdio.c</name>
<type>1</type>
<locationURI>SDK_ROOT/utils/uartstdio.c</locationURI>
</link>
<link>
<name>utils/ustdlib.c</name>
<type>1</type>
<locationURI>SDK_ROOT/utils/ustdlib.c</locationURI>
</link>
<link>
<name>mongoose.c</name>
<type>1</type>
<locationURI>MG_ROOT/mongoose.c</locationURI>
</link>
<link>
<name>mongoose.h</name>
<type>1</type>
<locationURI>MG_ROOT/mongoose.h</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SDK_ROOT</name>
<value>$%7BTI_PRODUCTS_DIR%7D/TivaWare_C_Series-2.1.3.156</value>
</variable>
<variable>
<name>MG_ROOT</name>
<value>$%7BPARENT-4-PROJECT_LOC%7D</value>
</variable>
</variableList>
</projectDescription>
/******************************************************************************
*
* Mongoose_TM4C129_BM.cmd - CCS linker configuration file for Mongoose_TM4C129_BM.
*
* Copyright (c) 2013-2016 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.3.156 of the EK-TM4C129EXL Firmware Package.
*
*****************************************************************************/
--retain=g_pfnVectors
/* The following command line options are set as part of the CCS project. */
/* If you are building using the command line, or for some reason want to */
/* define them here, you can uncomment and modify these lines as needed. */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone. */
/* */
/* --heap_size=0 */
/* --stack_size=256 */
/* --library=rtsv7M3_T_le_eabi.lib */
/* The starting address of the application. Normally the interrupt vectors */
/* must be located at the beginning of the application. */
#define APP_BASE 0x00000000
#define RAM_BASE 0x20000000
/* System memory map */
MEMORY
{
/* Application stored in and executes from internal flash */
FLASH (RX) : origin = APP_BASE, length = 0x00100000
/* Application uses internal RAM for data */
SRAM (RWX) : origin = 0x20000000, length = 0x00040000
}
/* Section allocation in memory */
SECTIONS
{
.intvecs: > APP_BASE
.text : > FLASH
.const : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.vtable : > RAM_BASE
.data : > SRAM
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM
}
__STACK_TOP = __stack + 2048;
This diff is collapsed.
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*
*
* This example sets up a simple HTTP server using the Mongoose multi-protocol
* networking library.
*
* It assumes TivaWare is installed under
* ${TI_PRODUCTS_DIR}/TivaWare_C_Series-2.1.3.156. ${TI_PRODUCTS_DIR} is usually
* C:\ti on Windows, ~/ti on Linux.
*
* If you have a different version installed, please edit the SDK_ROOT path
* variable under Project -> Properties -> Resource -> Linked Resources.
*/
#include <stdbool.h>
#include <stdint.h>
#include "mongoose.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/flash.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "utils/lwiplib.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.h"
#include "drivers/pinout.h"
#define SYSTICKHZ 100
#define SYSTICKMS (1000 / SYSTICKHZ)
struct mg_mgr g_mgr;
// The main Mongoose event handler.
void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
static int led_value = 0;
if (ev == MG_EV_POLL) return;
// UARTprintf("%p: ev %d\r\n", nc, ev);
switch (ev) {
case MG_EV_ACCEPT: {
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
UARTprintf("%p: Connection from %s\r\n", nc, addr);
break;
}
case MG_EV_HTTP_REQUEST: {
struct http_message *hm = (struct http_message *) ev_data;
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
UARTprintf("%p: HTTP request\r\n", nc);
mg_send_response_line(nc, 200,
"Content-Type: text/html\r\n"
"Connection: close");
mg_printf(nc,
"\r\n<h1>Hello, %s!</h1>\r\n"
"You asked for %.*s\r\n",
addr, (int) hm->uri.len, hm->uri.p);
nc->flags |= MG_F_SEND_AND_CLOSE;
led_value ^= CLP_D1;
LEDWrite(CLP_D1, led_value);
break;
}
case MG_EV_CLOSE: {
UARTprintf("%p: Connection closed\r\n", nc);
break;
}
}
}
int gettimeofday(struct timeval *tv, void *tzvp) {
tv->tv_sec = time(NULL);
tv->tv_usec = 0;
return 0;
}
void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr) {
}
// Special IP address values that lwiplib uses.
#define IP_LINK_DOWN (0xffffffffU)
#define IP_LINK_UP (0)
// Invoked by lwiplib every HOST_TMR_INTERVAL ms (defined in lwipopts.h).
void lwIPHostTimerHandler(void) {
static uint32_t old_ip = IP_LINK_DOWN;
uint32_t ip = lwIPLocalIPAddrGet();
if (ip != old_ip) {
switch (ip) {
case IP_LINK_DOWN: {
UARTprintf("Link down.\r\n");
LEDWrite(CLP_D2, 0);
break;
}
case IP_LINK_UP: {
UARTprintf("Link up.\r\n");
LEDWrite(CLP_D2, 0);
break;
}
default: {
UARTprintf("IP: http://%s/\r\n", ipaddr_ntoa((const ip_addr_t *) &ip));
LEDWrite(CLP_D2, CLP_D2);
break;
}
}
old_ip = ip;
}
mg_mgr_poll(&g_mgr, 0);
}
void SysTickIntHandler(void) {
// Call the lwIP timer handler.
lwIPTimer(SYSTICKMS);
}
int main(void) {
//
// Make sure the main oscillator is enabled because this is required by
// the PHY. The system must have a 25MHz crystal attached to the OSC
// pins. The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
// frequency is 10MHz or higher.
//
SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
// Run from the PLL at 120 MHz.
uint32_t sys_clk =
MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
120000000);
// Configure the device pins.
PinoutSet(true, false);
// Configure UART.
UARTStdioConfig(0, 115200, sys_clk);
UARTprintf("Mongoose example\n\n");
// Configure board's LEDs: D2 is on when IP has been acquired,
// D1 is toggled on every HTTP request.
MAP_GPIOPinTypeGPIOOutput(CLP_D1_PORT, CLP_D1_PIN);
MAP_GPIOPinTypeGPIOOutput(CLP_D2_PORT, CLP_D2_PIN);
LEDWrite(CLP_D1, 0);
LEDWrite(CLP_D2, 0);
//
// Configure the hardware MAC address for Ethernet Controller filtering of
// incoming packets. The MAC address will be stored in the non-volatile
// USER0 and USER1 registers.
//
uint32_t u0, u1;
MAP_FlashUserGet(&u0, &u1);
uint8_t mac[6];
mac[0] = ((u0 >> 0) & 0xff);
mac[1] = ((u0 >> 8) & 0xff);
mac[2] = ((u0 >> 16) & 0xff);
mac[3] = ((u1 >> 0) & 0xff);
mac[4] = ((u1 >> 8) & 0xff);
mac[5] = ((u1 >> 16) & 0xff);
// Initialize the lwIP library, using DHCP.
lwIPInit(sys_clk, mac, 0, 0, 0, IPADDR_USE_DHCP);
// Configure Mongoose, create an HTTP listener.
mg_mgr_init(&g_mgr, NULL);
const char *err;
struct mg_bind_opts opts = {};
opts.error_string = &err;
struct mg_connection *nc = mg_bind_opt(&g_mgr, "80", ev_handler, opts);
if (nc == NULL) {
UARTprintf("Failed to create listener: %s\r\n", err);
return 1;
}
mg_set_protocol_http_websocket(nc);
// Configure SysTick for a periodic interrupt.
MAP_SysTickPeriodSet(sys_clk / SYSTICKHZ);
MAP_SysTickEnable();
MAP_SysTickIntEnable();
// Loop forever. All the work is done in interrupt handlers.
while (true) {
}
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations XML_version="1.2" id="configurations_0">
<configuration XML_version="1.2" id="Stellaris In-Circuit Debug Interface_0">
<instance XML_version="1.2" desc="Stellaris In-Circuit Debug Interface_0" href="connections/Stellaris_ICDI_Connection.xml" id="Stellaris In-Circuit Debug Interface_0" xml="Stellaris_ICDI_Connection.xml" xmlpath="connections"/>
<connection XML_version="1.2" id="Stellaris In-Circuit Debug Interface_0">
<instance XML_version="1.2" href="drivers/stellaris_cs_dap.xml" id="drivers" xml="stellaris_cs_dap.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/stellaris_cortex_m4.xml" id="drivers" xml="stellaris_cortex_m4.xml" xmlpath="drivers"/>
<platform XML_version="1.2" id="platform_0">
<instance XML_version="1.2" desc="Stellaris TM4C129ENCPDT_0" href="devices/tm4c129encpdt.xml" id="Stellaris TM4C129ENCPDT_0" xml="tm4c129encpdt.xml" xmlpath="devices"/>
</platform>
</connection>
</configuration>
</configurations>
TI Tiva TM4C129 example
=======================
This directory contains a Mongoose example CCS project for Tiva TM4C129.
It targets the [Crypto Connected LaunchPad](http://www.ti.com/tool/ek-tm4c129exl) dev board.
You will need CCS 6+ with Tiva support and TivaWare SDK installed.
TivaWare should be installed under `${TI_PRODUCTS_DIR}/TivaWare_C_Series-2.1.3.156`,
which is usually `C:\TI\TivaWare_C_Series-2.1.3.156` on Windows.
If you have a different version installed, please edit the `SDK_ROOT` path
variable under `Project -> Properties -> Resource -> Linked Resources`.
......@@ -725,10 +725,9 @@ typedef int cs_dirent_dummy;
/*
* There is no sys/time.h on ARMCC.
*/
#if !(defined(__ARMCC_VERSION) || defined(__ICCARM__)) && \
(!defined(CS_PLATFORM) || \
(CS_PLATFORM != CS_P_CC3200 && CS_PLATFORM != CS_P_MSP432 && \
CS_PLATFORM != CS_P_NXP_LPC))
#if !(defined(__ARMCC_VERSION) || defined(__ICCARM__)) && \
!defined(__TI_COMPILER_VERSION__) && \
(!defined(CS_PLATFORM) || CS_PLATFORM != CS_P_NXP_LPC)
#include <sys/time.h>
#endif
#else
......
......@@ -48,6 +48,7 @@
#define CS_P_CC3200 4
#define CS_P_MSP432 5
#define CS_P_CC3100 6
#define CS_P_TM4C129 14
#define CS_P_MBED 7
#define CS_P_WINCE 8
#define CS_P_NXP_LPC 13
......@@ -55,6 +56,7 @@
#define CS_P_NRF51 12
#define CS_P_NRF52 10
#define CS_P_PIC32_HARMONY 11
/* Next id: 15 */
/* If not specified explicitly, we guess platform by defines. */
#ifndef CS_PLATFORM
......@@ -79,6 +81,9 @@
#define CS_PLATFORM CS_P_PIC32_HARMONY
#elif defined(ICACHE_FLASH)
#define CS_PLATFORM CS_P_ESP8266
#elif defined(TARGET_IS_TM4C129_RA0) || defined(TARGET_IS_TM4C129_RA1) || \
defined(TARGET_IS_TM4C129_RA2)
#define CS_PLATFORM CS_P_TM4C129
#endif
#ifndef CS_PLATFORM
......@@ -774,6 +779,66 @@ int _stat(const char *pathname, struct stat *st);
#endif /* CS_PLATFORM == CS_P_MSP432 */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_ */
#ifdef MG_MODULE_LINES
#line 1 "common/platforms/platform_tm4c129.h"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_COMMON_PLATFORMS_PLATFORM_TM4C129_H_
#define CS_COMMON_PLATFORMS_PLATFORM_TM4C129_H_
#if CS_PLATFORM == CS_P_TM4C129
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#ifndef __TI_COMPILER_VERSION__
#include <fcntl.h>
#include <sys/time.h>
#endif
#define SIZE_T_FMT "u"
typedef struct stat cs_stat_t;
#define DIRSEP '/'
#define to64(x) strtoll(x, NULL, 10)
#define INT64_FMT PRId64
#define INT64_X_FMT PRIx64
#define __cdecl
#ifndef MG_NET_IF
# include <lwip/opt.h>
# if LWIP_SOCKET
# define MG_NET_IF MG_NET_IF_SOCKET
# else
# define MG_NET_IF MG_NET_IF_LWIP_LOW_LEVEL
# endif
# define MG_LWIP 1
#elif MG_NET_IF == MG_NET_IF_SIMPLELINK
# include "common/platforms/simplelink/cs_simplelink.h"
#endif
#ifndef CS_ENABLE_STDIO
#define CS_ENABLE_STDIO 1
#endif
#ifdef __TI_COMPILER_VERSION__
/* As of 5.2.8, TI compiler does not support va_copy() yet. */
#define va_copy(apc, ap) ((apc) = (ap))
#endif /* __TI_COMPILER_VERSION__ */
#ifdef __cplusplus
}
#endif
#endif /* CS_PLATFORM == CS_P_TM4C129 */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_TM4C129_H_ */
#ifdef MG_MODULE_LINES
#line 1 "common/platforms/platform_mbed.h"
#endif
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment