Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jung2015-06-05 07:47:24 +0000
committerThomas Jung2015-06-05 07:47:24 +0000
commita5a626f88c7ab708d88f3f682f49f86c8e98319b (patch)
tree62bf3372624d930354a8cbf2fa745dd3556c9793 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parenta1293a6ed5ae7dda30af22180a6e3cb2a8d5c727 (diff)
downloadorg.eclipse.etrice-a5a626f88c7ab708d88f3f682f49f86c8e98319b.tar.gz
org.eclipse.etrice-a5a626f88c7ab708d88f3f682f49f86c8e98319b.tar.xz
org.eclipse.etrice-a5a626f88c7ab708d88f3f682f49f86c8e98319b.zip
runtime.c 32Bit FreeRtos Generic added
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etDatatypes.h98
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etLogger.c100
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/etMultiThreadedFreeRTOSProjectSpecific_XMC_Dave.c56
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/readme.txt8
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMutex.c47
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.c22
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.h12
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatformLifecycle.c38
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etSema.c54
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etThread.c83
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTime.c44
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTimer.c75
12 files changed, 637 insertions, 0 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etDatatypes.h
new file mode 100644
index 000000000..e0b270816
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etDatatypes.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution), Thomas Jung
+ *
+ *******************************************************************************/
+
+#ifndef _ETDATATYPES_H_
+#define _ETDATATYPES_H_
+
+/*
+ * typedefs for FreeRTOS on a 32Bit environment
+ *
+ * */
+
+#include <stdio.h>
+#include <FreeRTOS.h>
+#include <task.h>
+#include <timers.h>
+#include <semphr.h>
+
+/* unsigned integer datatypes */
+typedef unsigned char uint8;
+typedef unsigned short int uint16;
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+
+/* signed integer datatypes */
+typedef char int8;
+typedef short int int16;
+typedef int int32;
+typedef long long int64;
+
+
+/* float datatypes */
+typedef float float32;
+/* typedef double float64; */ /* not available on this platform */
+
+/* boolean datatypes and values */
+//typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+//typedef bool boolean;
+typedef char boolean;
+
+#ifndef ET_TRUE
+ #define ET_TRUE 1
+#endif
+#ifndef ET_FALSE
+ #define ET_FALSE 0
+#endif
+
+/*
+ * typedefs for eTrice Runtime and Testing
+ *
+ * */
+
+typedef int8 etInt8;
+typedef int16 etInt16;
+typedef int32 etInt32;
+
+typedef uint8 etUInt8;
+typedef uint16 etUInt16;
+typedef uint32 etUInt32;
+
+//typedef bool etBool;
+typedef char etBool;
+
+#define ALIGNMENT 4 /* power of 2 and >= sizeof(int) ! */
+
+typedef float32 etFloat32;
+typedef float32 etFloat64;
+
+/* string datatypes */
+typedef char* charPtr;
+
+
+typedef FILE* etFileHandle;
+
+typedef int8 etAddressId;
+
+
+/*
+ * typedefs for OS-specific types
+ */
+typedef xSemaphoreHandle etOSMutexData;
+typedef xSemaphoreHandle etOSSemaData;
+
+typedef xTaskHandle etOSThreadData;
+typedef uint16 etOSThreadId;
+
+typedef xTimerHandle etOSTimerData;
+typedef uint16 etOSTimerId;
+
+#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etLogger.c
new file mode 100644
index 000000000..fb114d302
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etLogger.c
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+/*
+ * etLogger.c
+ *
+ * Created on: 16.01.2012
+ * Author: tschuetz
+ */
+
+
+#include "debugging/etLogger.h"
+
+#include <stdarg.h>
+
+
+void etLogger_logError(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("ERROR: %s\n", message);
+#endif
+}
+
+void etLogger_logWarning(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("WARNING: %s\n", message);
+#endif
+}
+
+void etLogger_logInfo(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("INFO: %s\n", message);
+#endif
+}
+
+void etLogger_logErrorF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("ERROR: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+#endif
+}
+
+void etLogger_logWarningF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("WARNING: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+#endif
+}
+
+void etLogger_logInfoF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
+ printf("INFO: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+#endif
+}
+
+etFileHandle etLogger_fopen(const char* filename, const char* mode){
+#ifdef ET_LOGGER_ACTIVATE
+ return( fopen(filename, mode) );
+#else
+ return (0);
+#endif
+}
+
+int etLogger_fclose(etFileHandle file){
+#ifdef ET_LOGGER_ACTIVATE
+ return( fclose(file) );
+#else
+ return(0);
+#endif
+}
+
+void etLogger_fprintf(etFileHandle file, const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
+ va_list arglist;
+ va_start( arglist, format );
+ vfprintf(file, format, arglist );
+ va_end( arglist );
+#endif
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/etMultiThreadedFreeRTOSProjectSpecific_XMC_Dave.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/etMultiThreadedFreeRTOSProjectSpecific_XMC_Dave.c
new file mode 100644
index 000000000..d94b6b3a6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/etMultiThreadedFreeRTOSProjectSpecific_XMC_Dave.c
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+/*******************************************************************************
+ * This file implements the project specific part of the FreeRTOS
+ * runtime for a XMC ARM Cortex microcontroller from Infineon.
+ *
+ * It demonstrates how to adapt to your specific microcontroller and Realtime OS.
+ *
+ ********************************************************************************/
+
+#include "osal/etTime.h"
+#include "Dave.h"
+#include "helpers/etTimeHelpers.h"
+
+void etMultiThreadedFreeRTOSProjectSpecificUserEntry();
+
+// this function will be called during initialization
+// and must be implemented project spezific
+void etMultiThreadedFreeRTOSProjectSpecificUserEntry(){
+ if (DAVE_Init() == DAVE_STATUS_FAILURE){
+ while(1);
+ }
+}
+
+// the FreeRTOS Hooks must be implemented depending on
+// your FreeRTOS configuration
+void vApplicationMallocFailedHook(void){
+ while (1);
+}
+
+void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
+{
+ ( void ) pxTask;
+ ( void ) pcTaskName;
+
+ /* Run time stack overflow checking is performed if
+ configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
+ function is called if a stack overflow is detected. */
+ taskDISABLE_INTERRUPTS();
+ for( ;; );
+}
+
+void vApplicationIdleHook(void){
+volatile int i;
+
+ i++;
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/readme.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/readme.txt
new file mode 100644
index 000000000..3dffa4a14
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMultiThreadedFreeRTOSProjectSpecific_Examples/readme.txt
@@ -0,0 +1,8 @@
+The FreeRTOS eTrice runtime environment requires a running FreeRTOS for your specific target.
+Once you have your FreeRTOS running, it is very simple to adapt to your specific target.
+
+Within this directory you find some example implementations for dedicated targets.
+
+Please copy one of those example files into your project and compile it in your context.
+If necessary adapt the file to your needs.
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMutex.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMutex.c
new file mode 100644
index 000000000..7d473ce3e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etMutex.c
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etMutex.c FreeRTOS implementation of etMutex
+ *
+ */
+
+#include "osal/etMutex.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+void etMutex_construct(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "construct")
+ self->osData = xSemaphoreCreateMutex();
+ if((self->osData) == NULL){
+ while(1){};
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etMutex_destruct(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "destruct")
+ vSemaphoreDelete( self->osData );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMutex_enter(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "enter")
+ xSemaphoreTake(self->osData,portMAX_DELAY );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etMutex_leave(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "leave")
+ xSemaphoreGive(self->osData);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.c
new file mode 100644
index 000000000..eb5544fad
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.c
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution), Thomas Jung
+ *
+ *******************************************************************************/
+
+
+#include "etPlatform.h"
+#include "etDatatypes.h"
+#include "osal/etTime.h"
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "semphr.h"
+#include "queue.h"
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.h
new file mode 100644
index 000000000..0cb59bd9e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatform.h
@@ -0,0 +1,12 @@
+/*
+ * etPlatform.h
+ *
+ * Created on: 23.06.2012
+ * Author: junggtho
+ */
+
+#ifndef ETPLATFORM_H_
+#define ETPLATFORM_H_
+
+
+#endif /* ETPLATFORM_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatformLifecycle.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatformLifecycle.c
new file mode 100644
index 000000000..75c69bda7
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etPlatformLifecycle.c
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz, Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+
+
+#include "osal/etPlatformLifecycle.h"
+#include "etPlatform.h"
+
+
+/* implemenatation for eTrice interfaces*/
+
+// must be implemented projectspecific
+extern void etMultiThreadedFreeRTOSProjectSpecificUserEntry();
+void etTimeInit(void);
+
+void etUserEntry(void){
+ etTimeInit();
+ etMultiThreadedFreeRTOSProjectSpecificUserEntry();
+}
+
+void etUserPreRun(void){
+
+ /* Start the scheduler. */
+ vTaskStartScheduler();
+}
+
+void etUserPostRun(void){ }
+void etUserExit(void){ }
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etSema.c
new file mode 100644
index 000000000..c01b28724
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etSema.c
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz, Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etSema.c FreeRTOS implementation of etSema
+ *
+ */
+
+#include "osal/etSema.h"
+
+#include "debugging/etMSCLogger.h"
+
+
+void etSema_construct(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "construct")
+ self->osData = xSemaphoreCreateCounting( 1, 0 );
+ if ((self->osData) == NULL){
+ while(1){};
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etSema_destruct(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "destruct")
+ vSemaphoreDelete( self->osData );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSema_wakeup(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
+ xSemaphoreGive( self->osData );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSema_wakeupFromISR(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeupFromISR")
+ xSemaphoreGiveFromISR( self->osData, NULL );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSema_waitForWakeup(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "waitForWakeup")
+ xSemaphoreTake(self->osData, portMAX_DELAY );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etThread.c
new file mode 100644
index 000000000..d682bfa11
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etThread.c
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz, Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etThread.c FreeRTOS implementation of etThread
+ *
+ */
+
+#include "osal/etThread.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+void etThread_execute(etThread* self);
+
+void etThread_construct(
+ etThread* self,
+ etStacksize stacksize,
+ etPriority priority,
+ etThreadname threadName,
+ etThreadFunction threadFunction,
+ void* threadFunctionData)
+{
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "construct")
+
+ /* fill in data */
+ self->stacksize = stacksize;
+ self->priority = priority;
+ self->threadName = threadName;
+ self->threadFunction = threadFunction;
+ self->threadFunctionData = threadFunctionData;
+
+ if (xTaskCreate( threadFunction, ( signed char * ) threadName, stacksize, self->threadFunctionData, priority, &(self->osData)) != pdPASS){
+ while(1){};
+ }
+// xTaskCreate( threadFunction, ( signed char * ) threadName, stacksize, self->threadFunctionData, priority, &(self->osData) );
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_start(etThread* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "start")
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_execute(etThread* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "execute")
+ /* etThread_execute redirects the call from the thread to the execute function in the eTrice runtime to enable correct synchronous MSC logging */
+ self->threadFunction(self->threadFunctionData);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_destruct(etThread* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "destruct")
+ vTaskDelete( self->osData );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_sleep(etInt32 millis){
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "sleep")
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+/*
+etOSThreadData etThread_self(void){
+ return GetCurrentThread();
+}
+
+etOSThreadId etThread_self_id(void){
+ return GetCurrentThreadId();
+}
+*/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTime.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTime.c
new file mode 100644
index 000000000..1ea587d03
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTime.c
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz, Thomas Jung (initial contribution)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etTime.c FreeRTOS implementation of etTime
+ *
+ */
+
+#include "osal/etTime.h"
+
+etTime targetTime;
+
+void etTimeInit(void){
+ targetTime.nSec=0;
+ targetTime.sec=0;
+}
+
+
+void getTimeFromTarget(etTime *t) {
+ portENTER_CRITICAL();
+ *t = targetTime;
+ portEXIT_CRITICAL();
+}
+
+void vApplicationTickHook(void){
+ /* Tickrate from FreeRTOS Config */
+ targetTime.nSec += (1000000000UL / configTICK_RATE_HZ);
+ if (targetTime.nSec >= 1000000000UL) {
+ targetTime.nSec -= 1000000000UL;
+ targetTime.sec++;
+ }
+}
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTimer.c
new file mode 100644
index 000000000..ad5d04630
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_32Bit_FreeRTOS_Generic/etTimer.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution), Thomas Jung
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etTimer.c FreeRTOS implementation of etTimer
+ *
+ */
+
+#include "osal/etTimer.h"
+#include "helpers/etTimeHelpers.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+void etTimer_callback(xTimerHandle timer);
+
+void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction, void* timerFunctionData){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "construct")
+ {
+ self->osTimerData = NULL;
+ self->timerInterval.sec = timerInterval->sec;
+ self->timerInterval.nSec = timerInterval->nSec;
+ self->timerFunction = timerFunction;
+ self->timerFunctionData = timerFunctionData;
+ }
+
+ portTickType period = (timerInterval->sec*configTICK_RATE_HZ) + (timerInterval->nSec / (1000000000 / configTICK_RATE_HZ));
+
+
+ self->osTimerData = xTimerCreate ( "etTimer", period, pdTRUE, (void *) self, etTimer_callback );
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etTimer_start(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "start")
+ if (xTimerStart( self->osTimerData, 0 ) != pdPASS){
+ while(1){};
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etTimer_stop(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "stop")
+ if (xTimerStop( self->osTimerData, 0 ) != pdPASS){
+ while(1){};
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etTimer_destruct(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "destruct")
+
+ if (xTimerDelete( self->osTimerData, 0 ) != pdPASS){
+ while(1){};
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etTimer_callback(xTimerHandle timer){
+ {
+ etTimer* self = (etTimer*) pvTimerGetTimerID( timer );
+ self->timerFunction(self->timerFunctionData);
+ }
+}

Back to the top