Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2014-01-29 21:53:05 +0000
committertjung2014-01-29 21:53:05 +0000
commita60098c28aeb1e32cf4e2603608e22212e058e6f (patch)
treeb301a3c113c9f67a33c8f31eaaa40208ea6b5be4 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent7cae0f242bf85064758cb58c84a0bf0f953335b1 (diff)
downloadorg.eclipse.etrice-a60098c28aeb1e32cf4e2603608e22212e058e6f.tar.gz
org.eclipse.etrice-a60098c28aeb1e32cf4e2603608e22212e058e6f.tar.xz
org.eclipse.etrice-a60098c28aeb1e32cf4e2603608e22212e058e6f.zip
files removed from c-build
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_MSP430_F5438_FreeRTOS_CCS5_HWElevator/etTimer_org.c99
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h19
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c22
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c160
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c129
6 files changed, 239 insertions, 201 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_MSP430_F5438_FreeRTOS_CCS5_HWElevator/etTimer_org.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_MSP430_F5438_FreeRTOS_CCS5_HWElevator/etTimer_org.c
deleted file mode 100644
index 1f7907d63..000000000
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_MSP430_F5438_FreeRTOS_CCS5_HWElevator/etTimer_org.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "msp430f5438a.h"
-#include "platforms/etTimer.h"
-
-/* global timer */
-
-static etTargetTime_t targetTime;
-static etTargetTime_t lastTargetTime;
-static volatile etBool etTimer_executeFlag = FALSE;
-
-void etTimer_init(void){
- targetTime.nSec=0;
- targetTime.sec=0;
- lastTargetTime.nSec=0;
- lastTargetTime.sec=0;
-}
-
-etBool etTimer_executeNeeded(void){
- if (etTimer_executeFlag == TRUE){
- etTimer_executeFlag = FALSE;
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-int isTimeGreaterThanActualTime(const etTargetTime_t *t) {
-
- _disable_interrupt();
- if (t->sec > targetTime.sec) {
- _enable_interrupt();
- return 1;
- }
-
- if (t->sec < targetTime.sec) {
- _enable_interrupt();
- return 0;
- }
-
- if (t->nSec > targetTime.nSec) {
- _enable_interrupt();
- return 1;
- }
- else {
- _enable_interrupt();
- return 0;
- }
-}
-
-uint32 getNSecFromTarget(void){
- etTargetTime_t time;
- getTimeFromTarget(&time);
- return time.nSec;
-}
-
-uint32 getSecFromTarget(void){
- etTargetTime_t time;
- getTimeFromTarget(&time);
- return time.sec;
-}
-
-
-void getTimeFromTarget(etTargetTime_t *t) {
- _disable_interrupt();
- *t = targetTime;
- _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)
-#pragma vector=WDT_VECTOR
-void wdt_isr(void) {
-// this interrupt will be called every 15,625ms
-
- etTimer_executeFlag = TRUE;
- targetTime.nSec += 15625000L;
-
- if (targetTime.nSec >= 1000000000L) {
- targetTime.nSec -= 1000000000L;
- targetTime.sec++;
- }
-} // end interrupt
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h
index aa948e6b4..361b1f4db 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etDatatypes.h
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
+ * Thomas Schuetz (initial contribution), Thomas Jung
*
*******************************************************************************/
@@ -63,10 +63,27 @@ typedef uint32 etUInt32;
typedef bool etBool;
+#define ALIGNMENT 2 /* power of 2 and >= sizeof(int) ! */
+
typedef float32 etFloat32;
+typedef float32 etFloat64;
+
+/* string datatypes */
+typedef char* charPtr;
+
typedef FILE* etFileHandle;
typedef int8 etAddressId;
+
+/*
+ * typedefs for OS-specific types
+ */
+
+typedef uint16 etOSThreadId;
+
+typedef uint16 etOSTimerId;
+
+
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c
index 9b20f31a3..fb114d302 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etLogger.c
@@ -24,55 +24,77 @@
void etLogger_logError(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
printf("ERROR: %s\n", message);
+#endif
}
void etLogger_logWarning(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
printf("WARNING: %s\n", message);
+#endif
}
void etLogger_logInfo(const char* message){
+#ifdef ET_LOGGER_ACTIVATE
printf("INFO: %s\n", message);
+#endif
}
void etLogger_logErrorF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
printf("ERROR: ");
va_list arglist;
va_start( arglist, format );
vprintf( format, arglist );
va_end( arglist );
printf("\n");
+#endif
}
void etLogger_logWarningF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
printf("WARNING: ");
va_list arglist;
va_start( arglist, format );
vprintf( format, arglist );
va_end( arglist );
printf("\n");
+#endif
}
void etLogger_logInfoF(const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
printf("INFO: ");
va_list arglist;
va_start( arglist, format );
vprintf( format, arglist );
va_end( arglist );
printf("\n");
+#endif
}
etFileHandle etLogger_fopen(const char* filename, const char* mode){
+#ifdef ET_LOGGER_ACTIVATE
return( fopen(filename, mode) );
+#else
+ return (0);
+#endif
}
int etLogger_fclose(etFileHandle file){
+#ifdef ET_LOGGER_ACTIVATE
return( fclose(file) );
+#else
+ return(0);
+#endif
}
void etLogger_fprintf(etFileHandle file, const char* format, ... ){
+#ifdef ET_LOGGER_ACTIVATE
va_list arglist;
va_start( arglist, format );
vfprintf(file, format, arglist );
va_end( arglist );
+#endif
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c
index 9c2f2c586..60ea698a8 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.c
@@ -6,14 +6,15 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
+ * Thomas Schuetz (initial contribution), Thomas Jung
*
*******************************************************************************/
#include "msp430f5438a.h"
-#include "platform/etTimer.h"
+//#include "platform/etTimer.h"
#include "hal_pmm.h"
#include "etPlatform.h"
+#include "etDatatypes.h"
void enableLatchOutput(void);
void initClockSystem(void);
@@ -42,26 +43,9 @@ volatile unsigned char execute;
unsigned int floorLatchShadow[6];
unsigned char motorLatchShadow[12];
-
-/* implemenatation for eTrice interfaces*/
-
-void etUserEntry(void){
- initHw();
- etTimer_init();
-}
-
-void etUserPreRun(void){
- enableInterrupt();
-}
-
-void etUserPostRun(void){ }
-void etUserExit(void){ }
-
-
/* platform specific functions */
-
/*****************************************************/
@@ -70,6 +54,7 @@ volatile unsigned int i=0;
volatile unsigned char j,m;
WDTCTL = WDTPW + 0x36; //WDT as Timer;
+// WDTCTL = WDTPW + 0x80; //disable WDT;
SetVCore(PMMCOREV_3);
initClockSystem();
@@ -289,3 +274,140 @@ void initClockSystem(void){
}
+/***************************************serial******************************/
+
+void executeModel(void);
+
+void initUART1(void){
+ // set IO Pins to Peripheral
+
+ UCA1CTL1 |= 0x01; // hold the UART in Reset during initialization
+ UCA1CTL1 |= 0x80; //CLK = SMCLK
+
+ P5SEL |= 0xC0;
+
+ UCA1CTL0 = 0x00; //8N1 LSB first
+ UCA1BR0 = 6; //Baudrate 0
+ UCA1BR1 = 0; //Baudrate 1
+ UCA1MCTL = 0x81;
+ UCA1STAT = 0; //clear all flags
+ UCA1IRTCTL = 0; //IrDA Tx disabled
+ UCA1IRRCTL = 0; //IrDA Rx disabled
+ UCA1ABCTL = 0; //Autobaud disabled
+
+ UCA1CTL1 &= ~0x01; //release the reset for operation
+
+ UCA1IE = 0x01;
+}
+
+
+
+#define ET_SERIAL_RXBUFFER_LEN 100
+#define ET_SERIAL_TXBUFFER_LEN 100
+unsigned char etSerialState = 0;
+unsigned char etSerialLen;
+unsigned char etSerialCS;
+unsigned char etSerialRxBuffer[ET_SERIAL_RXBUFFER_LEN];
+unsigned char *etSerialRxBufferWritePointer;
+unsigned char etExecute;
+unsigned char etSerialDataReceived=0;
+
+void executeModel(void){
+ if (etSerialRxBuffer[1] > 9){
+ etExecute=1;
+ }
+}
+
+void etSendSerialData(unsigned char len, unsigned char chnl, unsigned char * data){
+unsigned char i;
+unsigned char cs;
+
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = 0x2D;
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = 0xD4;
+
+ cs = len;
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = len;
+
+ cs^=chnl;
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = chnl;
+
+ for (i=0;i<len-1;i++){
+ // wait until TX Buffer is empty
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = *data;
+ cs ^= *data++;
+ }
+
+ while ((UCA1IFG & 0x02) == 0);
+ UCA1TXBUF = cs;
+}
+
+
+#pragma vector=USCI_A1_VECTOR
+interrupt void USCI_A1_ISR( void ){
+unsigned char cChar;
+
+switch (UCA1IV){
+ case 2:
+ //receive interrupt
+ cChar = UCA1RXBUF;
+ switch (etSerialState){
+ case 0:
+ // synch pattern => 0x2d,0xD4
+ if (cChar==0x2D){
+ etSerialState++;
+ }
+ break;
+ case 1:
+ // second byte of synch pattern
+ if (cChar==0xD4){
+ etSerialState++;
+ etSerialRxBufferWritePointer=etSerialRxBuffer;
+ etSerialCS=0;
+ }else{
+ etSerialState=0;
+ }
+ break;
+ case 2:
+ // first byte is the len
+ if ((etSerialLen=cChar) <= ET_SERIAL_RXBUFFER_LEN){
+ *etSerialRxBufferWritePointer++=cChar;
+ etSerialCS^=cChar;
+ etSerialState++;
+ }else{etSerialState=0;}
+ break;
+ case 3:
+ // receive the data
+ *etSerialRxBufferWritePointer++=cChar;
+ etSerialCS^=cChar;
+ etSerialLen--;
+ if(etSerialLen==0){etSerialState++;}
+ break;
+ case 4:
+ // receive the CS
+ //if (etSerialCS != cChar){etSerialState=0;}
+ //else{
+ // command received OK
+ etSerialState=0;
+ etSerialDataReceived=1;
+ executeModel();
+ //}
+ break;
+
+ default:etSerialState=0; break;
+ };
+
+ break;
+ case 4:
+ //transmit interrupt
+ //UCA1TXBUF = cChar;
+ //UCA1IE &= ~UCTXIE;
+ break;
+ default:;
+ }
+}
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h
index 40d0048bb..72283cd74 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etPlatform.h
@@ -23,6 +23,8 @@
#define TOGGLE 0x03
+#include "etTime.h"
+
void writeTo7Seg(unsigned char data);
void writeToDoor(unsigned char floor, unsigned char data);
unsigned char getButtonStatus(unsigned char floor, unsigned int id);
@@ -31,6 +33,15 @@ void shiftMotorDown(void);
void shiftMotorUp(void);
unsigned char getMotorPosition(void);
void toggleTestLed(void);
+void initHw(void);
+void enableInterrupt(void);
+void getTimeFromTarget(etTime *t);
+
+//serial
+void etSendSerialData(unsigned char len, unsigned char chnl, unsigned char * data);
+extern unsigned char etSerialDataReceived;
+extern unsigned char etSerialRxBuffer[];
+
#endif /* ETPLATFORM_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c
index 67f193b29..a6c680a84 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/ST_MSP430_F5438_CCS5_HWElevator/etTimer.c
@@ -1,99 +1,64 @@
-#include "msp430f5438a.h"
-#include "platform/etTimer.h"
+/*******************************************************************************
+ * 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), Thomas Jung
+ *
+ *******************************************************************************/
+
+#include "osal/etTimer.h"
+#include "helpers/etTimeHelpers.h"
+
+#include "debugging/etLogger.h"
+#include "debugging/etMSCLogger.h"
+
+etTimer * singleThreadedTimer;
+
+void etTimer_callback(xTimerHandle timer);
+
+void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction, void* timerFunctionData){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "construct")
+ {
+ self->osTimerData = NULL;
+ self->timerInterval.sec = timerInterval->sec;
+ self->timerInterval.nSec = timerInterval->nSec;
+ self->timerFunction = timerFunction;
+ self->timerFunctionData = timerFunctionData;
-/* global timer */
-static etTargetTime_t targetTime;
-static etTargetTime_t lastTargetTime;
-static volatile etBool etTimer_executeFlag = FALSE;
-
-void etTimer_init(void){
- targetTime.nSec=0;
- targetTime.sec=0;
- lastTargetTime.nSec=0;
- lastTargetTime.sec=0;
-}
-
-etBool etTimer_executeNeeded(void){
- if (etTimer_executeFlag == TRUE){
- etTimer_executeFlag = FALSE;
- return TRUE;
}
- else {
- return FALSE;
- }
-}
-
-int isTimeGreaterThanActualTime(const etTargetTime_t *t) {
+ // store the timer, it will be needed to call the do actions
+ singleThreadedTimer = self;
- _disable_interrupt();
- if (t->sec > targetTime.sec) {
- _enable_interrupt();
- return 1;
- }
-
- if (t->sec < targetTime.sec) {
- _enable_interrupt();
- return 0;
- }
-
- if (t->nSec > targetTime.nSec) {
- _enable_interrupt();
- return 1;
- }
- else {
- _enable_interrupt();
- return 0;
- }
+ ET_MSC_LOGGER_SYNC_EXIT
}
-uint32 getNSecFromTarget(void){
- etTargetTime_t time;
- getTimeFromTarget(&time);
- return time.nSec;
-}
+void etTimer_start(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "start")
-uint32 getSecFromTarget(void){
- etTargetTime_t time;
- getTimeFromTarget(&time);
- return time.sec;
+ ET_MSC_LOGGER_SYNC_EXIT
}
-void getTimeFromTarget(etTargetTime_t *t) {
- _disable_interrupt();
- *t = targetTime;
- _enable_interrupt();
-}
+void etTimer_stop(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "stop")
-#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;
+ ET_MSC_LOGGER_SYNC_EXIT
}
-uint32 getTimeBaseUS(void){
- return ET_TIMER_TIME_BASE_US;
-}
+void etTimer_destruct(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "destruct")
-uint32 getTimeBaseMS(void){
- return ET_TIMER_TIME_BASE_MS;
+ ET_MSC_LOGGER_SYNC_EXIT
}
-
-/* the timer interrupt */
-#pragma INTERRUPT(wdt_isr)
-#pragma vector=WDT_VECTOR
-void wdt_isr(void) {
-// this interrupt will be called every 15,625ms
-
- etTimer_executeFlag = TRUE;
- targetTime.nSec += 15625000L;
-
- if (targetTime.nSec >= 1000000000L) {
- targetTime.nSec -= 1000000000L;
- targetTime.sec++;
+void etTimer_callback(xTimerHandle timer){
+ {
+ // the do actiosn will be called directly from the semaphore wakeup function
}
-} // end interrupt
+}
+

Back to the top