From c193c9337a9ad073225b0181241334872368b76a Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Thu, 29 Sep 2016 16:51:44 +0200 Subject: [runtime.c, runtime.cpp, modellib.cpp] added WindowsMinGW_ST target implementation and build configurations, added gitignores, fixed review comments Change-Id: Ibecaea3f5164da17db10fc87e6e01ca6cd85496e --- .../src/platforms/MT_WIN_MinGW/etTimer.c | 3 +- .../src/platforms/ST_32Bit_Generic/etLogger.c | 2 +- .../src/platforms/ST_32Bit_Generic/etSema.c | 1 + .../etSingleThreaded_WIN_MinGW.c | 63 ++++++++++++++++++++++ .../src/platforms/ST_32Bit_Generic/etThread.c | 4 ++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreaded_WIN_MinGW.c (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms') 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 index 97fe30ef8..251f0c9a7 100644 --- 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 @@ -57,7 +57,8 @@ void etTimer_start(etTimer* self){ etLogger_logError("etTimer_start: no Timer Queue to create timer (NULL)"); } else { - if (CreateTimerQueueTimer( &(self->osTimerData), hTimerQueue, etTimer_callback, self, elapse, elapse, 0) == ET_FALSE){ + if (CreateTimerQueueTimer(&(self->osTimerData), hTimerQueue, + etTimer_callback, self, elapse, elapse, 0) == ET_FALSE) { etLogger_logError("etTimer_start: Timer could not be created"); } } diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etLogger.c index fb114d302..b0d45fcc9 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etLogger.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etLogger.c @@ -21,7 +21,7 @@ #include "debugging/etLogger.h" #include - +#include "etRuntimeConfig.h" void etLogger_logError(const char* message){ #ifdef ET_LOGGER_ACTIVATE diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSema.c index 00579a65c..923e87c82 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSema.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSema.c @@ -41,6 +41,7 @@ void etSema_waitForWakeup(etSema* self){ etTime actualTime; ET_MSC_LOGGER_SYNC_ENTRY("etSema", "waitForWakeup") /* busy wait as specified in etphys */ + getTimeFromTarget(&actualTime); if (etTimeHelpers_isGreater(&actualTime, &nextTime)){ etTimeHelpers_add(&nextTime,&(singleThreadedTimer->timerInterval)); diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreaded_WIN_MinGW.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreaded_WIN_MinGW.c new file mode 100644 index 000000000..6b523be78 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreaded_WIN_MinGW.c @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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 teh single threaded + * runtime for a XMC ARM Cortex microcontroller from Infineon. + * + * It demonstrates how to adapt to your specific microcontroller. The only thing + * you need is a periodic interrupt which maintains the etTime. This is the base + * for all the modeltimers you can use in your eTrice model. + * + * This implementation gives you a 1ms accurate time. For most applications this + * resolution is sufficient and the implementation is much simpler. This version + * could serve as a starting point for your own project with any other microcontroller. + * + ********************************************************************************/ + +#include "osal/etTime.h" +#include "helpers/etTimeHelpers.h" +#include "debugging/etLogger.h" + +#include + +extern etTime etTargetTime; +void incTimeFromTarget(etUInt32 ms); + +void getTimeFromTarget(etTime *t) { + /* return the time */ + /* make sure that reading the time is an atomic operation */ + /* => the timer interrupt should not interrupt this operation */ + + /* for windows we use the Sleep function to enforce the time slices for single threaded */ + /* the WindowsMinGW_ST is only meant for debugging, since the single threaded concept is only meant for bare metal targets */ + etUInt32 cycle_time_ms = 100; + Sleep(cycle_time_ms); + incTimeFromTarget(cycle_time_ms); /* hack to satisfy timer needs: increment time by 100 ms per cycle */ + + *t = etTargetTime; + +} + +void incTimeFromTarget(etUInt32 ms) { + etTargetTime.nSec += ms * 1000000; /* ns = ms *1000000 */ + + if (etTargetTime.nSec >= 1000000000L) { + etTargetTime.nSec -= 1000000000L; + etTargetTime.sec++; + } +} + +/* this function will be called during initialization */ +void etSingleThreadedProjectSpecificUserEntry(void) { +} + diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etThread.c index d359b9609..3c4e6eb74 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etThread.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etThread.c @@ -74,3 +74,7 @@ void etThread_sleep(etInt32 millis){ ET_MSC_LOGGER_SYNC_EXIT } + +etOSThreadId etThread_self_id(void){ + return 0; +} -- cgit v1.2.3