Commit 444a93d0 authored by Martin Horauer's avatar Martin Horauer
Browse files

initial commit

parent f6c0e265
= XMC & UCOS3
This project holds the template and various applications using the XMC4500 RelaxKit along with uCOS3. The setup consists of the following folders/layers:
....
APP_XXX/ ...... UCOS3 configuration files and application code
APP_XXX/BSP/ .. application specific board support packages for UCOS3
UCOS3/ ........ the RTOS (Micrium)
XMCLIB/ ....... the low-level library for the XMC controller family (Infineon)
CMSIS/ ........ the Cortex-M4 Support packages (ARM) and the XMC register files (Infineon)
....
Copy an application APP_XXX - rename the copy and make it your active build project.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.400597100">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.400597100" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.cross.base.400597100" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.400597100.2045568897" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.821334686" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
<option id="cdt.managedbuild.option.gnu.cross.prefix.1464645660" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
<option id="cdt.managedbuild.option.gnu.cross.path.1562998456" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.183700338" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder id="cdt.managedbuild.builder.gnu.cross.986074320" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1760131985" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler"/>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.2098472615" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.358825994" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.2120001617" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1333033108" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1195320569" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1639150822;ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1639150822.714580877;ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.1429672790;ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.2023535251">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1639150822;ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.1639150822.714580877;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1522586350;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1319666945">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.190651504;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.190651504.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1247831956;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.501591281">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1460749328;ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1460749328.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.2028199771;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.675954119">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="XMC_UCOS3.null.1068867021" name="XMC_UCOS3"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BEL4_EZB_Template</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>
buildTools.path=/home/nfranz/bin/gcc-arm-none-eabi-4_9-2015q2/bin
eclipse.preferences.version=1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.400597100" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-605855620051873237" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
</project>
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 SEGGER Microcontroller GmbH & Co KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : RTT_Syscalls.c
Purpose : Low-level functions for using printf() via RTT in GCC
-------- END-OF-HEADER ---------------------------------------------
*/
#include <SEGGER_RTT.h>
#if JLINK_RTT
/*********************************************************************
*
* Function prototypes
*
**********************************************************************
*/
int _write (int file, char *ptr, int len);
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* _write()
*
* Function description
* Low-level write function.
* libc subroutines will use this system routine for output to all files,
* including stdout.
* Write data via RTT.
*/
int _write (int file, char *ptr, int len)
{
(void) file; /* Not used, avoid warning */
SEGGER_RTT_Write (0, ptr, len);
return len;
}
#endif
/*! EOF */
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014-2014 SEGGER Microcontroller GmbH & Co. KG *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : SEGGER_RTT.c
Date : 17 Dec 2014
Purpose : Implementation of SEGGER real-time terminal (RTT) which allows
real-time terminal communication on targets which support
debugger memory accesses while the CPU is running.
Type "int" is assumed to be 32-bits in size
H->T Host to target communication
T->H Target to host communication
RTT channel 0 is always present and reserved for Terminal usage.
Name is fixed to "Terminal"
---------------------------END-OF-HEADER------------------------------
*/
#include <SEGGER_RTT_Conf.h>
#include <SEGGER_RTT.h>
#include <string.h> // for memcpy
#if JLINK_RTT
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#ifndef BUFFER_SIZE_UP
// Size of the buffer for terminal output of target, up to host
#define BUFFER_SIZE_UP (1024)
#endif
#ifndef BUFFER_SIZE_DOWN
// Size of the buffer for terminal input to target from host (Usually
// keyboard input)
#define BUFFER_SIZE_DOWN (16)
#endif
#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
// Number of up-buffers (T->H) available on this target
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (1)
#endif
#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
// Number of down-buffers (H->T) available on this target
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (1)
#endif
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK()
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK()
#endif
#ifndef SEGGER_RTT_IN_RAM
#define SEGGER_RTT_IN_RAM (0)
#endif
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MEMCPY(a, b, c) memcpy((a),(b),(c))
// For some environments, NULL may not be defined until certain headers
// are included.
#ifndef NULL
#define NULL 0
#endif
/*********************************************************************
*
* Types
*
**********************************************************************
*/
//
// Description for a circular buffer (also called "ring buffer")
// which is used as up- (T->H) or down-buffer (H->T)
//
typedef struct {
// Optional name. Standard names so far are: "Terminal", "VCom"
const char* sName;
// Pointer to start of buffer
char* pBuffer;
// Buffer size in bytes. Note that one byte is lost, as this
// implementation does not fill up the buffer in order to avoid the
// problem of being unable to distinguish between full and empty.
int SizeOfBuffer;
// Position of next item to be written by either host (down-buffer)
// or target (up-buffer). Must be volatile since it may be modified
// by host (down-buffer)
volatile int WrOff;
// Position of next item to be read by target (down-buffer) or host
// (up-buffer). Must be volatile since it may be modified by host
// (up-buffer)
volatile int RdOff;
// Contains configuration flags
int Flags;
} RING_BUFFER;
// RTT control block which describes the number of buffers available
// as well as the configuration for each buffer
typedef struct {
// Initialized to "SEGGER RTT"
char acID[16];
// Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
int MaxNumUpBuffers;
// Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
int MaxNumDownBuffers;
// Up buffers, transferring information up from target via debug probe to host
RING_BUFFER aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS];
// Down buffers, transferring information down from host via debug probe
// to target
RING_BUFFER aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS];
} SEGGER_RTT_CB;
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
//
// Allocate buffers for channel 0
//
static char _acUpBuffer [BUFFER_SIZE_UP];
static char _acDownBuffer[BUFFER_SIZE_DOWN];
//
// Initialize SEGGER Real-time-Terminal control block (CB)
//
static SEGGER_RTT_CB _SEGGER_RTT = {
#if SEGGER_RTT_IN_RAM
"SEGGER RTTI",
#else
"SEGGER RTT",
#endif
SEGGER_RTT_MAX_NUM_UP_BUFFERS,
SEGGER_RTT_MAX_NUM_DOWN_BUFFERS,
{{ "Terminal", &_acUpBuffer[0],
sizeof (_acUpBuffer), 0, 0,
SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
{{ "Terminal", &_acDownBuffer[0],
sizeof (_acDownBuffer), 0, 0,
SEGGER_RTT_MODE_NO_BLOCK_SKIP }},
};
static char _ActiveTerminal;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _strlen
*
* Function description
* ANSI compatible function to determine the length of a string
*
* Return value
* Length of string in bytes.
*
* Parameters
* s Pointer to \0 terminated string.
*
* Notes
* (1) s needs to point to an \0 terminated string. Otherwise proper
* functionality of this function is not guaranteed.
*/
static int _strlen (const char* s)
{
int Len;
Len = 0;
if (s == NULL) {
return 0;
}
do {
if (*s == 0) {
break;
}
Len++;
s++;
} while (1);
return Len;
}
/*********************************************************************
*
* _Init
*
* Function description
* In case SEGGER_RTT_IN_RAM is defined,
* _Init() modifies the ID of the RTT CB to allow identifying the
* RTT Control Block Structure in the data segment.
*/
static void _Init (void)
{
#if SEGGER_RTT_IN_RAM
if (_SEGGER_RTT.acID[10] == 'I') {
_SEGGER_RTT.acID[10] = '\0';
}
#endif
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_RTT_Read
*
* Function description
* Reads characters from SEGGER real-time-terminal control block
* which have been previously stored by the host.
*
* Parameters
* BufferIndex Index of Down-buffer to be used. (e.g. 0 for "Terminal")
* pBuffer Pointer to buffer provided by target application, to copy
* characters from RTT-down-buffer to.
* BufferSize Size of the target application buffer
*
* Return values
* Number of bytes that have been read
*/
int SEGGER_RTT_Read (unsigned BufferIndex, char* pBuffer, unsigned BufferSize)
{
int NumBytesRem;
unsigned NumBytesRead;
int RdOff;
int WrOff;
SEGGER_RTT_LOCK();
_Init();
RdOff = _SEGGER_RTT.aDown[BufferIndex].RdOff;
WrOff = _SEGGER_RTT.aDown[BufferIndex].WrOff;
NumBytesRead = 0;
//
// Read from current read position to wrap-around of buffer, first
//
if (RdOff > WrOff) {
NumBytesRem = _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer - RdOff;
NumBytesRem = MIN (NumBytesRem, (int) BufferSize);
MEMCPY (pBuffer, _SEGGER_RTT.aDown[BufferIndex].pBuffer + RdOff,
NumBytesRem);
NumBytesRead += NumBytesRem;
pBuffer += NumBytesRem;
BufferSize -= NumBytesRem;
RdOff += NumBytesRem;
//
// Handle wrap-around of buffer
//
if (RdOff == _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer) {
RdOff = 0;
}
}
//
// Read remaining items of buffer
//
NumBytesRem = WrOff - RdOff;
NumBytesRem = MIN (NumBytesRem, (int) BufferSize);
if (NumBytesRem > 0) {
MEMCPY (pBuffer, _SEGGER_RTT.aDown[BufferIndex].pBuffer + RdOff,
NumBytesRem);
NumBytesRead += NumBytesRem;
pBuffer += NumBytesRem;
BufferSize -= NumBytesRem;
RdOff += NumBytesRem;
}
if (NumBytesRead) {
_SEGGER_RTT.aDown[BufferIndex].RdOff = RdOff;
}
SEGGER_RTT_UNLOCK();
return NumBytesRead;
}
/*********************************************************************
*
* SEGGER_RTT_Write
*
* Function description
* Stores a specified number of characters in SEGGER RTT
* control block which is then read by the host.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
* pBuffer Pointer to character array. Does not need to point to a \0
* terminated string.
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
*
* Return values
* Number of bytes which have been stored in the "Up"-buffer.
*
* Notes
* (1) If there is not enough space in the "Up"-buffer, remaining characters
* of pBuffer are dropped.
*/
int SEGGER_RTT_Write (unsigned BufferIndex, const char* pBuffer,
unsigned NumBytes)
{
int NumBytesToWrite;
unsigned NumBytesWritten;
int RdOff;
// Target is not allowed to perform other RTT operations while string still
// has not been stored completely.
// Otherwise we would probably end up with a mixed string in the buffer.
//
SEGGER_RTT_LOCK();
_Init();
// In case we are not in blocking mode,
// we need to calculate, how many bytes we can put into the buffer at all.
//
if ( (_SEGGER_RTT.aUp[BufferIndex].Flags & SEGGER_RTT_MODE_MASK) != SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) {
RdOff = _SEGGER_RTT.aUp[BufferIndex].RdOff;
NumBytesToWrite = RdOff - _SEGGER_RTT.aUp[BufferIndex].WrOff - 1;
if (NumBytesToWrite < 0) {
NumBytesToWrite += _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer;
}
// If the complete data does not fit in the buffer, check if we have to
// skip it completely or trim the data
//
if ( (int) NumBytes > NumBytesToWrite) {
if ( (_SEGGER_RTT.aUp[BufferIndex].Flags & SEGGER_RTT_MODE_MASK) ==
SEGGER_RTT_MODE_NO_BLOCK_SKIP) {
SEGGER_RTT_UNLOCK();
return 0;
} else {
NumBytes = NumBytesToWrite;
}
}
}
// Early out if nothing is to do
//
if (NumBytes == 0) {
SEGGER_RTT_UNLOCK();
return 0;
}
// Write data to buffer and handle wrap-around if necessary
//
NumBytesWritten = 0;
do {
// May be changed by host (debug probe) in the meantime
RdOff = _SEGGER_RTT.aUp[BufferIndex].RdOff;
NumBytesToWrite = RdOff - _SEGGER_RTT.aUp[BufferIndex].WrOff - 1;
if (NumBytesToWrite < 0) {
NumBytesToWrite += _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer;
}
// Number of bytes that can be written until buffer wrap-around
NumBytesToWrite = MIN (NumBytesToWrite,
(_SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer -
_SEGGER_RTT.aUp[BufferIndex].WrOff));
NumBytesToWrite = MIN (NumBytesToWrite, (int) NumBytes);
MEMCPY (_SEGGER_RTT.aUp[BufferIndex].pBuffer +
_SEGGER_RTT.aUp[BufferIndex].WrOff, pBuffer, NumBytesToWrite);
NumBytesWritten += NumBytesToWrite;
pBuffer += NumBytesToWrite;
NumBytes -= NumBytesToWrite;
_SEGGER_RTT.aUp[BufferIndex].WrOff += NumBytesToWrite;
if (_SEGGER_RTT.aUp[BufferIndex].WrOff ==
_SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer) {
_SEGGER_RTT.aUp[BufferIndex].WrOff = 0;
}
} while (NumBytes);
SEGGER_RTT_UNLOCK();
return NumBytesWritten;
}
/*********************************************************************
*
* SEGGER_RTT_WriteString
*
* Function description
* Stores string in SEGGER RTT control block.
* This data is read by the host.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal")
* s Pointer to string.
*
* Return values
* Number of bytes which have been stored in the "Up"-buffer.
*
* Notes
* (1) If there is not enough space in the "Up"-buffer, depending on
* configuration, remaining characters may be dropped or RTT module
* waits until there is more space in the buffer.
* (2) String passed to this function has to be \0 terminated
* (3) \0 termination character is *not* stored in RTT buffer
*/
int SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s)
{
int Len;
Len = _strlen (s);
return SEGGER_RTT_Write (BufferIndex, s, Len);
}
/*********************************************************************
*
* SEGGER_RTT_GetKey
*
* Function description