Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c59
1 files changed, 41 insertions, 18 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
index 7e98fc932..8d2adc797 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
@@ -26,42 +26,65 @@
/** global handle for the Windows timer queue */
static HANDLE hTimerQueue = NULL;
-void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction){
- self->osTimerData = NULL;
- self->timerInterval.sec = timerInterval->sec;
- self->timerInterval.nSec = timerInterval->nSec;
- self->timerFunction = timerFunction;
- if (hTimerQueue == NULL){
- /* the Windows timer queue is only needed once for all timers */
- hTimerQueue = CreateTimerQueue();
+VOID CALLBACK etTimer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired);
+
+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;
if (hTimerQueue == NULL){
- etLogger_logError("etTimer_construct: CreateTimerQueue failed");
+ /* the Windows timer queue is only needed once for all timers */
+ hTimerQueue = CreateTimerQueue();
+ if (hTimerQueue == NULL){
+ etLogger_logError("etTimer_construct: CreateTimerQueue failed");
+ }
}
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_start(etTimer* self){
- UINT elapse;
- /* calculate the time in milliseconds -> accuracy will of nSec will get lost in windows! */
- elapse = etTimeHelpers_convertToMSec(&(self->timerInterval));
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "start")
+ {
+ /* calculate the time in milliseconds -> accuracy of nSec will get lost in windows! */
+ UINT elapse = etTimeHelpers_convertToMSec(&(self->timerInterval));
- if (hTimerQueue == NULL){
- etLogger_logError("etTimer_start: no Timer Queue to create timer (NULL)");
- }
- else {
- if (CreateTimerQueueTimer( &(self->osTimerData), hTimerQueue, self->timerFunction, NULL , 0, elapse, 0) == FALSE){
- etLogger_logError("etTimer_start: Timer could not be created");
+ if (hTimerQueue == NULL){
+ etLogger_logError("etTimer_start: no Timer Queue to create timer (NULL)");
+ }
+ else {
+ if (CreateTimerQueueTimer( &(self->osTimerData), hTimerQueue, etTimer_callback, self, 0, elapse, 0) == FALSE){
+ etLogger_logError("etTimer_start: Timer could not be created");
+ }
}
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_stop(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "stop")
if (DeleteTimerQueueTimer(hTimerQueue, self->osTimerData, NULL) == FALSE){
etLogger_logError("etTimer_stop: Timer could not be stopped");
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_destruct(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "destruct")
/* TODO: destroy hTimerQueue if last timer is destroyed */
/* DeleteTimerQueue(hTimerQueue); */
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+VOID CALLBACK etTimer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "callback")
+ {
+ etTimer* self = (etTimer*) lpParameter;
+ self->timerFunction(self->timerFunctionData);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top