Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2013-04-29 19:41:43 +0000
committerThomas Schuetz2013-04-29 19:41:43 +0000
commit2903767e47d1d2a6d3135d7a26d2913987792f52 (patch)
tree86d2948ce587c67d289ad1213cae2b6e21a4e801 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent8ab083b90fbf7f51e39ad6c9c7ef4cf7c92aae93 (diff)
downloadorg.eclipse.etrice-2903767e47d1d2a6d3135d7a26d2913987792f52.tar.gz
org.eclipse.etrice-2903767e47d1d2a6d3135d7a26d2913987792f52.tar.xz
org.eclipse.etrice-2903767e47d1d2a6d3135d7a26d2913987792f52.zip
[runtime.c] reorganization of API for C OSAL
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h101
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/info.txt10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h)237
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c (renamed from runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c)142
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etMutex.c44
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etPlatformLifecycle.c21
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c46
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c59
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTime.c58
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c43
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/info.txt10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c144
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c39
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt2
14 files changed, 576 insertions, 380 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
new file mode 100644
index 000000000..ee503e50b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+#ifndef _ETDATATYPES_H_
+#define _ETDATATYPES_H_
+
+/*
+ * typedefs for platform specific datatypes
+ * generic Version for most bigger 32 and 64 bit platforms like Linux an Windows
+ *
+ * */
+
+/* TODO: implement for posix */
+
+#include <stdio.h>
+
+/* unsigned integer datatypes */
+typedef unsigned char uint8;
+typedef unsigned short int uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+
+/* signed integer datatypes */
+typedef char int8;
+typedef short int int16;
+typedef long int32;
+typedef long long int64;
+
+
+/* float datatypes */
+typedef float float32;
+typedef double float64;
+
+/* string datatypes */
+typedef char* charPtr;
+
+
+#ifndef NULL
+ #define NULL 0
+#endif
+
+/* boolean datatypes and values */
+typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+typedef bool boolean;
+
+#ifndef TRUE
+ #define TRUE 1
+#endif
+#ifndef FALSE
+ #define FALSE 0
+#endif
+
+#define ALIGNMENT 4
+
+/*
+ * 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 charPtr etCharPtr;
+
+typedef float32 etFloat32;
+typedef float64 etFloat64;
+
+typedef bool etBool;
+
+
+typedef FILE* etFileHandle;
+
+typedef int16 etAddressId;
+
+/*
+ * typedefs for OS-specific types
+ */
+
+typedef int etOSMutexData;
+typedef int etOSThreadData;
+/*typedef int etOSThreadId;*/ /*TODO: check if correct */
+typedef int etOSSemaData;
+
+/*typedef int etOSTimerId;*/ /*TODO: check if correct */
+
+
+#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/info.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/info.txt
new file mode 100644
index 000000000..fe9d04e4b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/info.txt
@@ -0,0 +1,10 @@
+Platform: MT_POSIX_GENERIC_GCC
+
+Threading: Multi Threaded
+Processor: -
+Operating System: POSIX
+Compiler: GCC
+Board: -
+
+Description:
+This platform should work for all Posix systems with a GCC compiler
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
index d6a33fd4d..ff5f6ad61 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
@@ -1,124 +1,113 @@
-/*******************************************************************************
- * 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)
- *
- *******************************************************************************/
-
-#ifndef _ETDATATYPES_H_
-#define _ETDATATYPES_H_
-
-/*
- * typedefs for platform specific datatypes
- * generic Version for most bigger 32 and 64 bit platforms like Linux an Windows
- *
- * */
-
-#include <stdio.h>
-
-#if defined __MINGW32__
-#include <windows.h>
-#include <process.h>
-#elif defined __GNUC__
-#else
-#error
-#endif
-
-
-/* unsigned integer datatypes */
-typedef unsigned char uint8;
-typedef unsigned short int uint16;
-typedef unsigned long uint32;
-typedef unsigned long long uint64;
-
-/* signed integer datatypes */
-typedef char int8;
-typedef short int int16;
-typedef long int32;
-typedef long long int64;
-
-
-/* float datatypes */
-typedef float float32;
-typedef double float64;
-
-/* string datatypes */
-typedef char* charPtr;
-
-
-#ifndef NULL
- #define NULL 0
-#endif
-
-/* boolean datatypes and values */
-typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
-#ifndef __MINGW32__
- typedef bool boolean;
-#endif
-
-#ifndef TRUE
- #define TRUE 1
-#endif
-#ifndef FALSE
- #define FALSE 0
-#endif
-
-#define ALIGNMENT 4
-
-/*
- * 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 charPtr etCharPtr;
-
-typedef float32 etFloat32;
-typedef float64 etFloat64;
-
-typedef bool etBool;
-
-
-typedef FILE* etFileHandle;
-
-typedef int16 etAddressId;
-
-/*
- * typedefs for threading
- */
-
-#if defined __MINGW32__
-
- typedef CRITICAL_SECTION etOSMutexData;
- typedef HANDLE etOSThreadData;
- typedef DWORD etOSThreadId;
- typedef HANDLE etOSSemaData;
-
-
-
-#elif defined __GNUC__
-
- /* dummy for LINUX/UNIX */
- typedef int etOSMutexData;
- typedef int etOSThreadData;
- typedef int etOSSemaData;
-
-#else
- #error
-#endif
-
-
-
-#endif /* _DATATYPES_H_ */
+/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+#ifndef _ETDATATYPES_H_
+#define _ETDATATYPES_H_
+
+/*
+ * typedefs for platform specific datatypes
+ * generic Version for most bigger 32 and 64 bit platforms like Linux an Windows
+ *
+ * */
+
+#include <stdio.h>
+
+#include <windows.h>
+#include <process.h>
+
+/* unsigned integer datatypes */
+typedef unsigned char uint8;
+typedef unsigned short int uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+
+/* signed integer datatypes */
+typedef char int8;
+typedef short int int16;
+typedef long int32;
+typedef long long int64;
+
+
+/* float datatypes */
+typedef float float32;
+typedef double float64;
+
+/* string datatypes */
+typedef char* charPtr;
+
+
+#ifndef NULL
+ #define NULL 0
+#endif
+
+/* boolean datatypes and values */
+typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
+
+#ifndef TRUE
+ #define TRUE 1
+#endif
+#ifndef FALSE
+ #define FALSE 0
+#endif
+
+#define ALIGNMENT 4
+
+/*
+ * 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 charPtr etCharPtr;
+
+typedef float32 etFloat32;
+typedef float64 etFloat64;
+
+typedef bool etBool;
+
+
+typedef FILE* etFileHandle;
+
+typedef int16 etAddressId;
+
+/*
+ * typedefs for OS-specific types
+ */
+
+ typedef CRITICAL_SECTION etOSMutexData;
+ typedef HANDLE etOSThreadData;
+ typedef DWORD etOSThreadId;
+ typedef HANDLE etOSSemaData;
+
+ typedef UINT_PTR etOSTimerId;
+
+//typedef TIMERPROC etTimerFunction;
+typedef VOID(CALLBACK *etTimerFunction)(HWND,UINT,UINT,DWORD);
+//typedef void (*etThreadFunction)(void *);
+
+#define etTimerFunction_RETURN_VALUE VOID CALLBACK
+
+#define etTimerFunction_ARGUMENT_LIST HWND arg1, UINT arg2, UINT arg3, DWORD arg4
+
+
+//typedef void (*etTimerFunction)(void); /**< OS specific timer callback function **/
+//typedef VOID(CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
+
+
+#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c
index 5ab7da075..aef339cfc 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c
@@ -1,71 +1,71 @@
-/*******************************************************************************
- * 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)
- *
- *******************************************************************************/
-
-#include "debugging/etLogger.h"
-
-#include <stdarg.h>
-
-
-void etLogger_logError(const char* message){
- printf("ERROR: %s\n", message);
-}
-
-void etLogger_logWarning(const char* message){
- printf("WARNING: %s\n", message);
-}
-
-void etLogger_logInfo(const char* message){
- printf("INFO: %s\n", message);
- fflush(stdout);
-}
-
-void etLogger_logErrorF(const char* format, ... ){
- printf("ERROR: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-void etLogger_logWarningF(const char* format, ... ){
- printf("WARNING: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-void etLogger_logInfoF(const char* format, ... ){
- printf("INFO: ");
- va_list arglist;
- va_start( arglist, format );
- vprintf( format, arglist );
- va_end( arglist );
- printf("\n");
-}
-
-etFileHandle etLogger_fopen(const char* filename, const char* mode){
- return( fopen(filename, mode) );
-}
-
-int etLogger_fclose(etFileHandle file){
- return( fclose(file) );
-}
-
-void etLogger_fprintf(etFileHandle file, const char* format, ... ){
- va_list arglist;
- va_start( arglist, format );
- vfprintf(file, format, arglist );
- va_end( arglist );
-}
+/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+#include "debugging/etLogger.h"
+
+#include <stdarg.h>
+
+
+void etLogger_logError(const char* message){
+ printf("ERROR: %s\n", message);
+}
+
+void etLogger_logWarning(const char* message){
+ printf("WARNING: %s\n", message);
+}
+
+void etLogger_logInfo(const char* message){
+ printf("INFO: %s\n", message);
+ fflush(stdout);
+}
+
+void etLogger_logErrorF(const char* format, ... ){
+ printf("ERROR: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+void etLogger_logWarningF(const char* format, ... ){
+ printf("WARNING: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+void etLogger_logInfoF(const char* format, ... ){
+ printf("INFO: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+etFileHandle etLogger_fopen(const char* filename, const char* mode){
+ return( fopen(filename, mode) );
+}
+
+int etLogger_fclose(etFileHandle file){
+ return( fclose(file) );
+}
+
+void etLogger_fprintf(etFileHandle file, const char* format, ... ){
+ va_list arglist;
+ va_start( arglist, format );
+ vfprintf(file, format, arglist );
+ va_end( arglist );
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etMutex.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etMutex.c
new file mode 100644
index 000000000..5521682ac
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etMutex.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)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etMutex.c MinGW 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")
+ InitializeCriticalSection( &(self->osData) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etMutex_destruct(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "destruct")
+ DeleteCriticalSection( &(self->osData) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMutex_enter(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "enter")
+ EnterCriticalSection( &(self->osData) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etMutex_leave(etMutex* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "leave")
+ LeaveCriticalSection( &(self->osData) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etPlatformLifecycle.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etPlatformLifecycle.c
new file mode 100644
index 000000000..5dd07e1ae
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etPlatformLifecycle.c
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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"
+
+void etUserEntry(void){ /* not needed for this OS */ }
+void etUserPreRun(void){ /* not needed for this OS */ }
+void etUserPostRun(void){ /* not needed for this OS */ }
+void etUserExit(void){ /* not needed for this OS */ }
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c
new file mode 100644
index 000000000..13f8daca8
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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 MinGW implementation of etSema
+ *
+ */
+
+#include "osal/etSema.h"
+#include "etDatatypes.h"
+
+#include "debugging/etMSCLogger.h"
+
+
+void etSema_construct(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "construct")
+ self->osData = CreateEvent( NULL, FALSE, FALSE, NULL );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+void etSema_destruct(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "destruct")
+ // TODO: implement this function
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSema_wakeup(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
+ SetEvent( self->osData );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etSema_waitForWakeup(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "waitForWakeup")
+ WaitForSingleObject( self->osData, INFINITE );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
new file mode 100644
index 000000000..14ea2b98a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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 MinGW 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){
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "construct")
+ self->osData = (HANDLE)_beginthread( (etThreadFunction)etThread_execute, self->stacksize, self );
+ SetThreadPriority(self->osData, self->priority);
+ 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")
+ TerminateThread(self->osData, 0);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_sleep(etInt32 millis){
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "sleep")
+ Sleep(millis);
+ 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_WIN_MinGW/etTime.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTime.c
new file mode 100644
index 000000000..d367f9ebc
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTime.c
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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 MinGW implementation of etTime
+ *
+ */
+
+#include "osal/etTime.h"
+
+#include <sys/time.h>
+
+void getTimeFromTarget(etTime *t){
+ struct timeval currentTime;
+ gettimeofday(&currentTime, NULL);
+ t->sec = currentTime.tv_sec;
+ t->nSec = currentTime.tv_usec*1000;
+}
+
+
+/* TODO: remove old API functions
+uint64 getTargetTimeUs(void){
+ struct timeval currentTime;
+ gettimeofday(&currentTime, NULL);
+
+ return currentTime.tv_sec * 1000000L + currentTime.tv_usec;
+}
+
+etBool etTimer_executeNeeded(void){
+
+ static uint64 lastTime = 0L;
+
+ uint64 currentTime = getTargetTimeUs();
+
+ uint64 timestep = 1000000L/FREQUENCY;
+
+ if (currentTime >= lastTime + timestep) {
+ lastTime = currentTime;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+*/
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
new file mode 100644
index 000000000..3cbd39fe6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+/**
+ *
+ * etTimer.c MinGW implementation of etTimer
+ *
+ */
+
+#include "osal/etTimer.h"
+#include "helpers/etTimeHelpers.h"
+
+void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction threadFunction){
+ self->osTimerId = 0;
+ self->timerInterval.sec = timerInterval->sec;
+ self->timerInterval.nSec = timerInterval->nSec;
+ self->timerFunction = threadFunction;
+}
+
+void etTimer_start(etTimer* self){
+ UINT elapse;
+ /* calculate the time in milliseconds -> accuracy will of nSec will get lost in windows! */
+ elapse = etTimeHelpers_convertToMSec(&(self->timerInterval));
+ /*TODO: should we replace the forced cast by a platform specific implementation of the timer callback function? */
+ self->osTimerId = SetTimer(NULL, 0, elapse, self->timerFunction);
+}
+
+void etTimer_stop(etTimer* self){
+ KillTimer(NULL, self->osTimerId);
+}
+
+void etTimer_destruct(etTimer* self){
+ /* no implementation needed for this operating system */
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/info.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/info.txt
new file mode 100644
index 000000000..c5b3b86f5
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/info.txt
@@ -0,0 +1,10 @@
+Platform: MT_WIN_MinGW
+
+Threading: Multi Threaded
+Processor: -
+Operating System: Windows (MinGW)
+Compiler: GCC (MinGW)
+Board: -
+
+Description:
+This platform should work for all Windows based MinGW compilers
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
deleted file mode 100644
index 1e1a97bc4..000000000
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * 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)
- *
- *******************************************************************************/
-
-#include "etDatatypes.h"
-#include "platform/etPlatform.h"
-
-#include "debugging/etLogger.h"
-#include "debugging/etMSCLogger.h"
-
-/* implemenatation for eTrice interfaces*/
-
-void etUserEntry(void){ }
-
-void etUserPreRun(void){ }
-
-void etUserPostRun(void){ }
-
-void etUserExit(void){ }
-
-
-/* platform specific functions */
-
-#if defined __MINGW32__
-
-/******************thread********************/
-void etThread_execute(etThread* self);
-
-void etThread_construct(etThread* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etThread", "construct")
- self->osData = (HANDLE)_beginthread( (etThreadFunction)etThread_execute, self->stacksize, self );
- SetThreadPriority(self->osData, self->priority);
- 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")
- TerminateThread(self->osData, 0);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-
-/******************thread helpers********************/
-void etThread_sleep(etInt32 millis){
- ET_MSC_LOGGER_SYNC_ENTRY("etThread", "sleep")
- Sleep(millis);
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-etOSThreadData etThread_self(void){
- return GetCurrentThread();
-}
-
-etOSThreadId etThread_self_id(void){
- return GetCurrentThreadId();
-}
-
-/*****************mutex**********************/
-void etMutex_construct(etMutex* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "construct")
- InitializeCriticalSection( &(self->osData) );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-void etMutex_destruct(etMutex* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "destruct")
- DeleteCriticalSection( &(self->osData) );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etMutex_enter(etMutex* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "enter")
- EnterCriticalSection( &(self->osData) );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-void etMutex_leave(etMutex* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "leave")
- LeaveCriticalSection( &(self->osData) );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-/********************semaphore****************/
-void etSema_construct(etSema* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etSema", "construct")
- self->osData = CreateEvent( NULL, FALSE, FALSE, NULL );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-void etSema_destruct(etSema* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etSema", "destruct")
- // TODO: implement this function
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSema_wakeup(etSema* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
- SetEvent( self->osData );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-
-void etSema_waitForWakeup(etSema* self){
- ET_MSC_LOGGER_SYNC_ENTRY("etSema", "waitForWakeup")
- WaitForSingleObject( self->osData, INFINITE );
- ET_MSC_LOGGER_SYNC_EXIT
-}
-/*********************************************/
-
-#elif defined __GNUC__
-
-/******************thread********************/
-void etThread_construct(etThread* self){}
-
-void etThread_destruct(etThread* self){}
-
-/*****************mutex**********************/
-void etMutex_construct(etMutex* self){}
-void etMutex_destruct(etMutex* self){}
-void etMutex_enter(etMutex* self){}
-void etMutex_leave(etMutex* self){}
-
-/********************semaphore****************/
-void etSema_construct(etSema* self){}
-void etSema_destruct(etSema* self){}
-
-void etSema_wakeup(etSema* self){}
-
-void etSema_waitForWakeup(etSema* self){}
-/*********************************************/
-
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c
deleted file mode 100644
index a0076c25a..000000000
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "platform/etTimer.h"
-
-#include <sys/time.h>
-
-#include "etRuntimeConfig.h"
-
-void etTimer_init(void){
-}
-
-uint64 getTargetTimeUs(void){
- struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
-
- return currentTime.tv_sec * 1000000L + currentTime.tv_usec;
-}
-
-etBool etTimer_executeNeeded(void){
-
- static uint64 lastTime = 0L;
-
- uint64 currentTime = getTargetTimeUs();
-
- uint64 timestep = 1000000L/FREQUENCY;
-
- if (currentTime >= lastTime + timestep) {
- lastTime = currentTime;
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-void getTimeFromTarget(etTargetTime_t *t){
- struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
- t->sec = currentTime.tv_sec;
- t->nSec = currentTime.tv_usec*1000;
-}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt
deleted file mode 100644
index a2ac1f6d4..000000000
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/info.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This generic platform can be used for most 32 or 64 bit systems like windows and linux.
-It uses standard c libraries only and it makes use of the file system.

Back to the top