diff options
author | Thomas Schuetz | 2012-02-26 21:46:39 +0000 |
---|---|---|
committer | Thomas Schuetz | 2012-02-26 21:46:39 +0000 |
commit | fa4a03389b5596fbaa65d5acb0e198013c1820a8 (patch) | |
tree | 1a6ef7e8b46a1cfa85956dfa7fa9201cb228a1d1 | |
parent | a121360a55b1b4c8f834b6d68689064cd70499db (diff) | |
download | org.eclipse.etrice-fa4a03389b5596fbaa65d5acb0e198013c1820a8.tar.gz org.eclipse.etrice-fa4a03389b5596fbaa65d5acb0e198013c1820a8.tar.xz org.eclipse.etrice-fa4a03389b5596fbaa65d5acb0e198013c1820a8.zip |
[runtime] added etPlatform for user defined lifecycle functions (etUserEntry, etUserPreRun, ..., added TI-MSP430 specific platform
11 files changed, 274 insertions, 14 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend index 5c00020d0..72d95f03d 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend @@ -47,6 +47,7 @@ class SubSystemRunnerGen { #include "debugging/etLogger.h"
#include "debugging/etMSCLogger.h"
+ #include "platform/etPlatform.h"
/**
@@ -55,7 +56,8 @@ class SubSystemRunnerGen { */
int main(void) {
-
+ etUserEntry(); /* platform specific */
+
etLogger_logInfo("*** T H E B E G I N ***");
ET_MSC_LOGGER_OPEN("main");
@@ -63,9 +65,13 @@ class SubSystemRunnerGen { «ssi.name»_init(); /* lifecycle init */
«ssi.name»_start(); /* lifecycle start */
+ etUserPreRun(); /* platform specific */
+
/* run Scheduler */
«ssi.name»_run();
+ etUserPostRun(); /* platform specific */
+
/* shutdown sequence of lifecycle */
«ssi.name»_stop(); /* lifecycle stop */
«ssi.name»_destroy(); /* lifecycle destroy */
@@ -73,6 +79,8 @@ class SubSystemRunnerGen { ET_MSC_LOGGER_CLOSE
etLogger_logInfo("*** T H E E N D ***");
+ etUserExit(); /* platform specific */
+
return 0;
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java index 00727b482..30f202032 100644 --- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java +++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.java @@ -75,6 +75,8 @@ public class SubSystemRunnerGen { _builder.newLine(); _builder.append("#include \"debugging/etMSCLogger.h\""); _builder.newLine(); + _builder.append("#include \"platform/etPlatform.h\""); + _builder.newLine(); _builder.newLine(); _builder.newLine(); _builder.append("/**"); @@ -91,6 +93,10 @@ public class SubSystemRunnerGen { _builder.newLine(); _builder.append("int main(void) {"); _builder.newLine(); + _builder.append("\t"); + _builder.append("etUserEntry(); /* platform specific */"); + _builder.newLine(); + _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("etLogger_logInfo(\"*** T H E B E G I N ***\");"); @@ -114,6 +120,10 @@ public class SubSystemRunnerGen { _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("\t"); + _builder.append("etUserPreRun(); /* platform specific */"); + _builder.newLine(); + _builder.newLine(); + _builder.append("\t"); _builder.append("/* run Scheduler */"); _builder.newLine(); _builder.append("\t"); @@ -123,6 +133,10 @@ public class SubSystemRunnerGen { _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("\t"); + _builder.append("etUserPostRun(); /* platform specific */"); + _builder.newLine(); + _builder.newLine(); + _builder.append("\t"); _builder.append("/* shutdown sequence of lifecycle */"); _builder.newLine(); _builder.append("\t"); @@ -144,6 +158,10 @@ public class SubSystemRunnerGen { _builder.newLine(); _builder.newLine(); _builder.append("\t"); + _builder.append("etUserExit(); /* platform specific */"); + _builder.newLine(); + _builder.newLine(); + _builder.append("\t"); _builder.append("return 0;"); _builder.newLine(); _builder.append("}"); diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a Binary files differindex 7ac25a93e..a389000c2 100644 --- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a +++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h new file mode 100644 index 000000000..b462146fb --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + +/* + * etPlatform.h defines a generic interface for platform specific implementations + * + * */ + +/* + * Platform startup and shutdown -> generated code for SubSystemClass uses these interfaces + * */ + +void etUserEntry(void); +void etUserPreRun(void); +/* void etUserRun(void); */ /* TODO: do we need this function? */ +void etUserPostRun(void); +void etUserExit(void); + 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 new file mode 100644 index 000000000..84213de5e --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etGlobalFlags.h @@ -0,0 +1,22 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + +#ifndef ETGLOBALFLAGS_H_ +#define ETGLOBALFLAGS_H_ + +/* flags for debugging */ +#define ET_MSC_LOGGER_ACTIVATE /* needs ET_LOGGER_ACTIVATE */ +#define ET_LOGGER_ACTIVATE + + + +#endif /* ETGLOBALFLAGS_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etLogger.c new file mode 100644 index 000000000..9b20f31a3 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etLogger.c @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + +/* + * etLogger.c + * + * Created on: 16.01.2012 + * Author: tschuetz + */ + + +#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); +} + +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/MSP430/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c new file mode 100644 index 000000000..80ba0cfb3 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/etPlatform.c @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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 "msp430f5438a.h" +#include "hal_MSP-EXP430F5438.h" + +/* forward declarations */ +static void prvSetupHardware(void); +void initIO(void); + + +/* implemenatation for eTrice interfaces*/ + +void etUserEntry(void){ + prvSetupHardware(); +} + +void etUserPreRun(void){ + //_enable_interrupt(); +} + +void etUserPostRun(void){ } +void etUserExit(void){ } + + +/* platform specific functions */ + +static void prvSetupHardware(void) { + /* Convert a Hz value to a KHz value, as required by the Init_FLL_Settle() + function. */ + unsigned long ulCPU_Clock_KHz = (25000000UL / 1000UL ); + + /* Disable the watchdog. */ + WDTCTL = WDTPW + 0x36; + + 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); + + halLcdPrintLine(" eTrice on MSP430", 1, OVERWRITE_TEXT); + + //initIO(); +} + + +#pragma INTERRUPT(wdt_isr) +#pragma vector=WDT_VECTOR +void wdt_isr(void) { +// this interrupt will be called every 15,625ms + static unsigned char secCounter = 0; + + secCounter++; + + if (secCounter >= 64) { + secCounter = 0; + P1OUT ^= 0x01; + } +} // end interrupt diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/info.txt b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/info.txt new file mode 100644 index 000000000..b8f84e38c --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MSP430/info.txt @@ -0,0 +1 @@ +TI-MSP430 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 80b16b5b0..84213de5e 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 @@ -1,9 +1,14 @@ -/* - * etGlobalFlags.h +/******************************************************************************* + * 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 * - * Created on: 26.02.2012 - * Author: tschuetz - */ + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ #ifndef ETGLOBALFLAGS_H_ #define 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 9b20f31a3..47af50672 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 @@ -10,14 +10,6 @@ * *******************************************************************************/ -/* - * etLogger.c - * - * Created on: 16.01.2012 - * Author: tschuetz - */ - - #include "debugging/etLogger.h" #include <stdarg.h> 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 new file mode 100644 index 000000000..f8294f036 --- /dev/null +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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) + * + *******************************************************************************/ + + +/* implemenatation for eTrice interfaces*/ + +void etUserEntry(void){ } + +void etUserPreRun(void){ } + +void etUserPostRun(void){ } + +void etUserExit(void){ } + + +/* platform specific functions */ + |