Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-03-02 15:19:50 +0000
committerThomas Schuetz2012-03-02 15:19:50 +0000
commitc541a2e954c318c7df2e9d0f8f68d8163a06079e (patch)
tree93bd0d0936d6f32cc567e759dda9f8df7ffa7127 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent21c13921f486d0bb8035c9b52b8f2634afbeb69e (diff)
downloadorg.eclipse.etrice-c541a2e954c318c7df2e9d0f8f68d8163a06079e.tar.gz
org.eclipse.etrice-c541a2e954c318c7df2e9d0f8f68d8163a06079e.tar.xz
org.eclipse.etrice-c541a2e954c318c7df2e9d0f8f68d8163a06079e.zip
[runtime.c] added etTimer.c implementation for generic platform, introduced precompiler defines for timing and scheduling
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c24
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c20
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h5
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c33
6 files changed, 67 insertions, 22 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h
index cf4a7e6d8..92df9f69b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h
@@ -19,4 +19,10 @@
#define STRUCT_ALIGN 2
+/* timing and scheduling */
+//#define FREQUENCY 100L
+//#define ET_RUNTIME_MAXLOOP 100000
+#define ET_RUNTIME_ENDLESS
+
+
#endif /* ETGLOBALFLAGS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c
index 416e6347f..9dec5c084 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c
@@ -44,30 +44,14 @@ static void prvSetupHardware(void) {
/* Disable the watchdog. */
WDTCTL = WDTPW + 0x36;
+ SFRIE1 |= WDTIE;
+ /* select port pin functions */
halBoardInit();
- LFXT_Start(XT1DRIVE_0);
- Init_FLL_Settle((unsigned short) ulCPU_Clock_KHz, 488);
-
- halButtonsInit(BUTTON_ALL);
- halButtonsInterruptEnable(BUTTON_SELECT);
-
- /* Initialise the LCD, but note that the backlight is not used as the
- library function uses timer A0 to modulate the backlight, and this file
- defines vApplicationSetupTimerInterrupt() to also use timer A0 to generate
- the tick interrupt. If the backlight is required, then change either the
- halLCD library or vApplicationSetupTimerInterrupt() to use a different
- timer. Timer A1 is used for the run time stats time base6. */
- halLcdInit();
- halLcdSetContrast(105);
- halLcdClearScreen();
- halLcdBackLightInit();
- halLcdSetBackLight(10);
+ LFXT_Start(XT1DRIVE_0); /* enable oszillator */
+ Init_FLL_Settle((unsigned short) ulCPU_Clock_KHz, 488); /* clock divisor */
- halLcdPrintLine(" eTrice on MSP430", 1, OVERWRITE_TEXT);
-
- SFRIE1 |= WDTIE;
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c
index f501c9ad6..cdffb9636 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etTimer.c
@@ -6,7 +6,7 @@
static etTargetTime_t targetTime;
static etTargetTime_t lastTargetTime;
-static etBool etTimer_executeFlag = FALSE;
+static volatile etBool etTimer_executeFlag = FALSE;
void etTimer_init(void){
targetTime.nSec=0;
@@ -67,6 +67,23 @@ void getTimeFromTarget(etTargetTime_t *t) {
_enable_interrupt();
}
+#define ET_TIMER_TIME_BASE_NS 15625000L
+#define ET_TIMER_TIME_BASE_US ET_TIMER_TIME_BASE_NS / 1000L
+#define ET_TIMER_TIME_BASE_MS ET_TIMER_TIME_BASE_US / 1000L
+
+uint32 getTimeBaseNS(void){
+ return ET_TIMER_TIME_BASE_NS;
+}
+
+uint32 getTimeBaseUS(void){
+ return ET_TIMER_TIME_BASE_US;
+}
+
+uint32 getTimeBaseMS(void){
+ return ET_TIMER_TIME_BASE_MS;
+}
+
+
/* the timer interrupt */
#pragma INTERRUPT(wdt_isr)
@@ -88,7 +105,6 @@ void wdt_isr(void) {
if (secCounter >= 64) {
secCounter = 0;
- //P1OUT ^= 0x01;
}
} // end interrupt
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h
index 647dbab9b..d5eb4d68c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etGlobalFlags.h
@@ -20,5 +20,10 @@
#define STRUCT_ALIGN 8
+/* timing and scheduling */
+#define FREQUENCY 1000L
+#define ET_RUNTIME_MAXLOOP 1000
+//#define ET_RUNTIME_ENDLESS
+
#endif /* ETGLOBALFLAGS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c
index f68276960..5ab7da075 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etLogger.c
@@ -25,6 +25,7 @@ void etLogger_logWarning(const char* message){
void etLogger_logInfo(const char* message){
printf("INFO: %s\n", message);
+ fflush(stdout);
}
void etLogger_logErrorF(const char* format, ... ){
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
new file mode 100644
index 000000000..103529382
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etTimer.c
@@ -0,0 +1,33 @@
+#include "platform/etTimer.h"
+
+#include <sys/time.h>
+
+#include "etGlobalFlags.h"
+
+void etTimer_init(void){
+}
+
+uint64 getTargetTimeUs(void){
+ struct timeval time;
+ gettimeofday(&time, NULL);
+
+ return time.tv_sec * 1000000L + time.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;
+ }
+}
+

Back to the top