X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Femul%2Ftimer_qt.c;h=e0883abd87059b2f809e992f91ca4ae26dd586bf;hb=976d522209efc4c11a019ae6b34657b6b3f59ba0;hp=6f96da646984ce5e69c53e7c135669fd9d3c6f35;hpb=7a88d4d67f907aa2d714378d16b6829440210330;p=bertos.git diff --git a/bertos/emul/timer_qt.c b/bertos/emul/timer_qt.c index 6f96da64..e0883abd 100644 --- a/bertos/emul/timer_qt.c +++ b/bertos/emul/timer_qt.c @@ -30,9 +30,8 @@ * * --> * - * \version $Id$ * - * \author Bernardo Innocenti + * \author Bernie Innocenti * * \brief Low-level timer module for Qt emulator (implementation). */ @@ -42,6 +41,10 @@ #include #include +#if CONFIG_KERN_IRQ +#include +#endif + // The user interrupt server routine void timer_isr(void); @@ -87,13 +90,28 @@ public: // Record initial time system_time.start(); + #if CONFIG_KERN_IRQ + irq_register(SIGALRM, timer_isr); + #endif + // Activate timer interrupt - timer.connect(&timer, SIGNAL(timeout()), this, SLOT(timerInterrupt())); + connect(&timer, SIGNAL(timeout()), SLOT(timerInterrupt())); timer.start(1000 / TIMER_TICKS_PER_SEC); initialized = true; } + void cleanup() + { + // Timer cleaned twice? + ASSERT(initialized); + + timer.stop(); + timer.disconnect(); + + initialized = false; + } + /// Return current time in high-precision format. hptime_t hpread() { @@ -105,7 +123,11 @@ public slots: void timerInterrupt(void) { // Just call user interrupt server, timer restarts automatically. - timer_isr(); + #if CONFIG_KERN_IRQ + irq_entry(SIGALRM); + #else + timer_isr(); + #endif } }; @@ -116,10 +138,14 @@ public slots: /// HW dependent timer initialization. static void timer_hw_init(void) { - // Kick EmulTimer initialization EmulTimer::instance().init(); } +static void timer_hw_cleanup(void) +{ + EmulTimer::instance().cleanup(); +} + INLINE hptime_t timer_hw_hpread(void) { return EmulTimer::instance().hpread();