From: bernie Date: Sun, 10 Aug 2008 13:38:02 +0000 (+0000) Subject: trac#29: Cleanup timer on demo exit X-Git-Tag: 2.0.0~336 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=42e61240ce8a55e92fe0942fecbee3abe371c507;p=bertos.git trac#29: Cleanup timer on demo exit git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1598 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/app/demo/demo.c b/app/demo/demo.c index 2853f01a..ed64a12d 100644 --- a/app/demo/demo.c +++ b/app/demo/demo.c @@ -302,6 +302,7 @@ int main(int argc, char *argv[]) menu_handle(&main_menu); + timer_cleanup(); emul_cleanup(); return 0; } diff --git a/bertos/drv/timer.h b/bertos/drv/timer.h index f251ff82..a71dfb68 100644 --- a/bertos/drv/timer.h +++ b/bertos/drv/timer.h @@ -178,13 +178,15 @@ INLINE utime_t hptime_to_us(hptime_t hpticks) #endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */ } - -void timer_init(void); void timer_delayTicks(ticks_t delay); INLINE void timer_delay(mtime_t delay) { timer_delayTicks(ms_to_ticks(delay)); } + +void timer_init(void); +void timer_cleanup(void); + int timer_testSetup(void); int timer_testRun(void); int timer_testTearDown(void); diff --git a/bertos/emul/timer_qt.c b/bertos/emul/timer_qt.c index 204b22dc..7c2a0c34 100644 --- a/bertos/emul/timer_qt.c +++ b/bertos/emul/timer_qt.c @@ -88,12 +88,23 @@ public: system_time.start(); // 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() { @@ -116,10 +127,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();