Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jung2015-06-05 05:52:47 +0000
committerThomas Jung2015-06-05 05:52:47 +0000
commita1293a6ed5ae7dda30af22180a6e3cb2a8d5c727 (patch)
tree66322c21c40591342bf6691bf3d93b76919f87b2 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent40961c90418e3efceab85da9b12abb6d397ef001 (diff)
downloadorg.eclipse.etrice-a1293a6ed5ae7dda30af22180a6e3cb2a8d5c727.tar.gz
org.eclipse.etrice-a1293a6ed5ae7dda30af22180a6e3cb2a8d5c727.tar.xz
org.eclipse.etrice-a1293a6ed5ae7dda30af22180a6e3cb2a8d5c727.zip
original, more simple version of getTimeFromTarget added
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave.c21
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave_simple.c67
2 files changed, 85 insertions, 3 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave.c
index 6a9a2c784..5010b89a6 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave.c
@@ -9,10 +9,24 @@
* 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 CPU clock accurate time. This is achieved
+ * by calculating the time from the ARM SystickCounter in addition to
+ * counting the interrupts. This requires a bit more complex implementation.
+ *
+ * There is also a simple version available see
+ * "etSingleThreadedProjectSpecific_XMC_Dave_simple.c"
+ *
+ ********************************************************************************/
#include "osal/etTime.h"
-#include "XMC4500.h"
#include "Dave.h"
#include "helpers/etTimeHelpers.h"
@@ -56,12 +70,13 @@ void etTick_Handler(void *nanoSecPerTick) {
}
}
+// initialize the DAVE generated APPs
void etSingleThreadedProjectSpecificUserEntry(void){
DAVE_Init();
DAVE_InstallTickHandler();
}
-
+// the Dave APP SYSTIMER must be available in the project
void DAVE_InstallTickHandler(void){
uint32_t timerId;
timerId = SYSTIMER_CreateTimer(1000,SYSTIMER_PERIODIC,etTick_Handler,(void*) 1000000);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave_simple.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave_simple.c
new file mode 100644
index 000000000..9725310ba
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_32Bit_Generic/etSingleThreadedProjectSpecific_Examples/etSingleThreadedProjectSpecific_XMC_Dave_simple.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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 "Dave.h"
+#include "helpers/etTimeHelpers.h"
+
+extern etTime etTargetTime;
+void DAVE_InstallTickHandler(void);
+
+void getTimeFromTarget(etTime *t) {
+// return the time
+// make sure that reading the time is an atomic opration
+// => the timer interrupt should not interrupt this operation
+ __disable_irq();
+ *t = etTargetTime;
+ __enable_irq();
+}
+
+// the timer interrupt
+void etTick_Handler(void *nanoSecPerTick) {
+// this interrupt will be called every 1ms
+
+ etTargetTime.nSec += (uint32_t)nanoSecPerTick;
+
+ if (etTargetTime.nSec >= 1000000000L) {
+ etTargetTime.nSec -= 1000000000L;
+ etTargetTime.sec++;
+ }
+}
+
+// this function will be called during initialization
+void etSingleThreadedProjectSpecificUserEntry(void){
+ DAVE_Init();
+ DAVE_InstallTickHandler();
+}
+
+// The SYSTIMER App from DAVE must be available
+void DAVE_InstallTickHandler(void){
+uint32_t timerId;
+ timerId = SYSTIMER_CreateTimer(1000,SYSTIMER_PERIODIC,etTick_Handler,(void*) 1000000);
+ SYSTIMER_StartTimer(timerId);
+}
+

Back to the top