Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c43
1 files changed, 43 insertions, 0 deletions
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 */
+}

Back to the top