Commit 80ffcf1c authored by Matthias Wenzl's avatar Matthias Wenzl
Browse files

added application template example, introduced BUILD_EXAMPLES define

parent 2c8f4fd2
......@@ -7,6 +7,8 @@
/*
* ======== StartBIOS.c ========
*/
#include <stdbool.h> /*in TI-RTOS always include first*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
......@@ -16,30 +18,9 @@
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Mailbox.h>
#include <ti/sysbios/knl/Event.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Timer.h>
#include <ti/sysbios/knl/Event.h>
/* Drivers Header files*/
#include <ti/drivers/GPIO.h>
/*Board Header files */
/*Board specific header files*/
#include <Board.h>
#include <EK_TM4C1294XL.h>
/*application header files*/
#include <ctype.h>
#include <string.h>
#include <uip.h>
#include <uip_arp.h>
#include <network_events.h>
#include <clock-arch.h>
#include <server.h>
#include <client.h>
#include <UIP_Task.h>
......
......@@ -62,7 +62,7 @@ static Semaphore_Handle _emac_rx_lock;
#endif
//enough space to hold a complete ethernet frame (excluding jumbo frames)
#define RX_BUFFER_SIZE 1536
#define RX_BUFFER_SIZE MAX_ETH_FRAME_SIZE
static void InitDescriptors(uint32_t ui32Base) {
......
......@@ -9,9 +9,12 @@
/*
* ======== UIP_Task.c ========
*/
#include <stdbool.h> /*in TI-RTOS always include first*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/cfg/global.h> /*access statically created symbols from cfg file*/
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Memory.h>
......@@ -28,27 +31,29 @@
/* Drivers Header files*/
#include <ti/drivers/GPIO.h>
#include <driverlib/emac.h>
/*Board Header files */
#include <Board.h>
/*Board specific header files */
#include <inc/hw_memmap.h>
#include <EK_TM4C1294XL.h>
/*application header files*/
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <uip-conf.h>/*application configuration data*/
#include <uip.h>
#include <uip_arp.h>
#include <network_events.h>
#include <clock-arch.h>
#if BUILD_EXAMPLES
#include <server.h>
#include <client.h>
#else
#include <config.h>
#endif
#include <driverlib/emac.h>
/*access statically created symbols from cfg file*/
#include <xdc/cfg/global.h>
#if ETH_USE_SEM
......@@ -117,13 +122,13 @@ void NetFxn(UArg arg0, UArg arg1)
#if ETH_USE_SEM
my_emac_rx_sem = EK_TM4C1294XL_initEMAC(sysclock,NULL);
if(my_emac_rx_sem == NULL) {
System_abort("Could not initialize EMAC");
System_abort("Could not initialize EMAC - supply mac address from backside of your board manuall");
}
#endif
#if ETH_USE_EVENT
my_network_events = EK_TM4C1294XL_initEMAC(sysclock,NULL/*use built in mac*/);
if(my_network_events == NULL) {
System_abort("Could not initialize EMAC");
System_abort("Could not initialize EMAC - supply mac address from backside of your board manually");
}
#endif
......@@ -140,6 +145,9 @@ void NetFxn(UArg arg0, UArg arg1)
#endif
#if IS_CLIENT
uip_ipaddr(sIPAddr, 192, 168, 5, 4);
#endif
#if !BUILD_EXAMPLES /*default dummy - change as you like*/
uip_ipaddr(sIPAddr, 192, 168, 5, 5);
#endif
uip_sethostaddr(sIPAddr);
/*set netmask*/
......@@ -153,8 +161,9 @@ void NetFxn(UArg arg0, UArg arg1)
EK_TM4C1294XL_startEMAC();
//get memory from global heap
//get memory from dedicated heap block
Error_init(&eb);
//NOTE:the "cfg_netHeap" error will be resolved after building.
uip_buf = (uint8_t *)Memory_alloc((xdc_runtime_IHeap_Handle)cfg_netHeap, UIP_BUFSIZE, 0, &eb);
if (uip_buf == NULL) {
System_abort("Memory allocation for global uip_buf failed");
......@@ -196,15 +205,15 @@ void NetFxn(UArg arg0, UArg arg1)
//
if(event_mask & EMAC_RX_EVENT)
{
// Get the packet and set uip_len for uIP stack usage.
//
buf_handle = PacketReceive((int32_t *)(&uip_len));
if(uip_len > UIP_BUFSIZE)
uip_len = UIP_BUFSIZE;//truncate received packet length if necessary
/* This is necessary as uip operates on uip_buf only
* Moreover, we must free the receiver buffer
* Moreover, we must free the receiver dma buffer
* immediately for other frames to come*/
memcpy(uip_buf,buf_handle,uip_len);
FreeEmacRxBuf();
......
......@@ -44,12 +44,6 @@ BIOS.libType = BIOS.LibType_Custom;
BIOS.logsEnabled = false;
BIOS.assertsEnabled = false;
/*** Network stack memory pool - fixed size head ***/
var heapBufParams = new HeapBuf.Params();
heapBufParams.blockSize = 1536;
heapBufParams.numBlocks = 8;
Program.global.cfg_netHeap = HeapBuf.create(heapBufParams);
/* ================ Driver configuration ================ */
/*
......@@ -68,3 +62,9 @@ driversConfig.libType = driversConfig.LibType_NonInstrumented;
Task.idleTaskStackSize = 512;
BIOS.heapSize = (1024*10*2);/*system heap - used for task stacks for example*/
var cfg_NetHeap_params = new HeapBuf.Params();
cfg_NetHeap_params.instance.name = "cfg_netHeap";
cfg_NetHeap_params.blockSize = 1528;
cfg_NetHeap_params.numBlocks = 8;
cfg_NetHeap_params.align = 8;
Program.global.cfg_netHeap = HeapBuf.create(cfg_NetHeap_params);
......@@ -67,9 +67,11 @@ extern "C" {
/*EMAC specifics*/
#define MAX_ETH_FRAME_SIZE 1526
/*transmitter, receiver descriptor amount - 3 is the absolute minimum (see datahseet).
* increase with respect to available memory*/
/*However, due to internal uip stack operation concepts, only one 1536 byte long
/*However, due to internal uip stack operation concepts, only one 1526 byte long
* buffer will be used for transmission purposes*/
#define NUM_TX_DESCRIPTORS 3
#define NUM_RX_DESCRIPTORS 5
......
/*! \file config.h
\brief Application configuration file.
\brief Application configuration file included from uip-conf.h.
\author Matthias Wenzl
*/
......@@ -10,6 +10,30 @@
#ifndef CONFIG_H_
#define CONFIG_H_
/*!
* \def BUILD_EXAMPLES
*
* Set to 1 to build the examples, set to 0 to clean the project for your implementation
*
*/
#define BUILD_EXAMPLES 0
#if !BUILD_EXAMPLES
/* uip_tcp_appstate_t structure is mandatory in EVERY uip tcp enabled project */
typedef struct app_state {
/*arbitrary state information*/
char inputbuffer[80];/*local input buffer*/
} uip_tcp_appstate_t;
#define UIP_APPCALL your_appcall
#endif
#if BUILD_EXAMPLES
/*!
\def IS_SERVER
Set to 1 if this application shall act as a server
......@@ -129,5 +153,6 @@ typedef struct server_state {
} uip_tcp_appstate_t;
#endif
#endif /* BUILD_EXAMPLES */
#endif /* CONFIG_H_ */
......@@ -12,6 +12,7 @@
#include <uip-conf.h>/*application configuration data*/
#if HAS_LED_SERVER && IS_SERVER
#include <uip.h>
......
......@@ -89,7 +89,7 @@ typedef unsigned short uip_stats_t;
//
// uIP buffer size.
//
#define UIP_CONF_BUFFER_SIZE 1536
#define UIP_CONF_BUFFER_SIZE 1526 /*max eth frame size*/
//
// uIP buffer is defined in the application.
......
/*
* your_application.c
*
* Created on: Aug 17, 2016
* Author: wenzl
*/
#include <uip-conf.h>/*application configuration data*/
void you_app_init(void) {
/*add initializations here*/
}
void your_appcall (void) {
/*test if your applicationis meant*/
/*add your application logic here*/
}
Supports Markdown
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