Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c43
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h32
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c7
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c6
5 files changed, 81 insertions, 13 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index 346e199a1..196c5be40 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -54,6 +54,9 @@ void etMessageService_init(
etMutex_construct( &(self->queueMutex) );
etSema_construct( &(self->executionSemaphore) );
+ /* init high prio functions */
+ self->highPrioFuncRoot=NULL;
+
/* init thread */
etThread_construct(&self->thread, stacksize, priority, "MessageService", (etThreadFunction) etMessageService_deliverAllMessages, self);
@@ -165,16 +168,54 @@ void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buf
ET_MSC_LOGGER_SYNC_EXIT
}
+void etMessageService_registerHighPrioFunc(etMessageService* self,etHighPrioFunc *func){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "registerHighPrioFunc")
+ func->next=self->highPrioFuncRoot;
+ self->highPrioFuncRoot=func;
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_unregisterHighPrioFunc(etMessageService* self,etHighPrioFunc *func){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "unregisterHighPrioFunc")
+ etHighPrioFunc *highPrioFunc;
+ if (self->highPrioFuncRoot==func){
+ self->highPrioFuncRoot=self->highPrioFuncRoot->next;
+ }else{
+ highPrioFunc = self->highPrioFuncRoot;
+ while(highPrioFunc != NULL){
+ if (highPrioFunc->next==func){
+ highPrioFunc->next=highPrioFunc->next->next;
+ break;
+ }
+ highPrioFunc=highPrioFunc->next;
+ }
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+static void etMessageService_callHighPrioFunc(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "callHighPrioFunc")
+ etHighPrioFunc *highPrioFunc;
+ highPrioFunc = self->highPrioFuncRoot;
+ while (highPrioFunc != NULL){
+ (*(highPrioFunc->func))(highPrioFunc->param);
+ highPrioFunc=highPrioFunc->next;
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
static void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
{
etBool cont = ET_TRUE;
while (cont){
+ etMessageService_callHighPrioFunc(self);
while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
etMessage* msg = etMessageService_popMessage(self);
if (!self->msgDispatcher(msg))
cont = ET_FALSE;
etMessageService_returnMessageBuffer(self, msg);
+ etMessageService_callHighPrioFunc(self);
}
if (cont)
etSema_waitForWakeup(&self->executionSemaphore);
@@ -204,3 +245,5 @@ static void etMessageService_timerCallback(void* data) {
}
ET_MSC_LOGGER_SYNC_EXIT
}
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index cd729b9a5..7a7110ad1 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -52,18 +52,25 @@ typedef struct etBuffer{
etUInt16 blockSize; /**< size of blocks for the message pool */
} etBuffer;
+typedef struct etHighPrioFunc etHighPrioFunc;
+struct etHighPrioFunc{
+ void (*func)(void *);
+ void * param;
+ etHighPrioFunc *next;
+};
+
typedef struct etMessageService {
- etMessageQueue messageQueue; /**< message queue that holds all used messages */
- etMessageQueue messagePool; /**< message pool that holds all free messages */
- etBuffer messageBuffer; /**< information about the message buffer that holds information about
- the actual memory position and size for the message pool */
- etDispatcherReceiveMessage msgDispatcher; /**< function pointer to the generated message dispatcher function */
- etThread thread; /**< thread for the execution of the message service */
- etMutex poolMutex; /**< mutex for synchronizing the access to the message pool */
- etMutex queueMutex; /**< mutex for synchronizing the access to the message queue */
- etSema executionSemaphore; /**< semaphore for waiting and waking up the execution */
- etTimer timer; /**< timer for cyclic calls */
- etMessageService_execmode execmode; /**< execution mode*/
+ etMessageQueue messageQueue; /** message queue that holds all used messages */
+ etMessageQueue messagePool; /** message pool that holds all free messages */
+ etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
+ etDispatcherReceiveMessage msgDispatcher; /** function pointer to the generated message dispatcher function */
+ etThread thread; /** thread for the execution of the message service */
+ etMutex poolMutex; /** mutex for synchronizing the access to the message pool */
+ etMutex queueMutex; /** mutex for synchronizing the access to the message queue */
+ etSema executionSemaphore; /** semaphore for waiting and waking up the execution */
+ etTimer timer; /** timer for cyclic calls */
+ etMessageService_execmode execmode; /** execution mode*/
+ etHighPrioFunc *highPrioFuncRoot;
} etMessageService;
/**
@@ -166,5 +173,8 @@ void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buf
*/
etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
+/* functions to register and unregister high prio functions */
+void etMessageService_registerHighPrioFunc(etMessageService* self, etHighPrioFunc* func);
+void etMessageService_unregisterHighPrioFunc(etMessageService* self, etHighPrioFunc* func);
#endif /* RMESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
index e1b115308..6642f69a3 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
@@ -10,6 +10,9 @@
*
*******************************************************************************/
+#ifndef _ETSEMA_H_
+#define _ETSEMA_H_
+
/**
* \file etSema.h
*
@@ -17,8 +20,6 @@
*
* \author Thomas Schuetz
*/
-#ifndef _ETSEMA_H_
-#define _ETSEMA_H_
#include "etDatatypes.h"
@@ -46,6 +47,7 @@ void etSema_destruct(etSema* self);
* \param self the 'this' pointer of the semaphore
*/
void etSema_wakeup(etSema* self);
+void etSema_wakeupFromISR(etSema* self);
/**
* make the semaphore waiting for a wakeup
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
index 8eb5660f2..9f8d583cf 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
@@ -39,6 +39,13 @@ void etSema_destruct(etSema* self){
ET_MSC_LOGGER_SYNC_EXIT
}
+void etSema_wakeupFromISR(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeupFromISR")
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
void etSema_wakeup(etSema* self){
ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
{
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c
index 5d779ec26..cb38e9b6b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c
@@ -33,6 +33,12 @@ void etSema_destruct(etSema* self){
ET_MSC_LOGGER_SYNC_EXIT
}
+void etSema_wakeupFromISR(etSema* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeupFromISR")
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
void etSema_wakeup(etSema* self){
ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
SetEvent( self->osData );

Back to the top