summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-10-23 11:29:38 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2020-10-23 15:35:11 +0000
commit3a7a46d1c02ecc633d65035b9c536858c1fccc3a (patch)
treeb7fd06ebeeb53a74c82ad584e4380fcd61bce559
parent186dbb45275e051a8a93d2cf66c416bf75c0174e (diff)
downloadrockbox-3a7a46d1c02ecc633d65035b9c536858c1fccc3a.tar.gz
rockbox-3a7a46d1c02ecc633d65035b9c536858c1fccc3a.zip
Hosted targets Fix timer cycle calculation overflow
at 1 GHZ the intermediate calculation for cycles overflows 32 bits this makes timer fail even with sensible values solution divide both sides by 100 Change-Id: I18a4054c2d06fb72531d5496bba562f71b03984f
-rw-r--r--apps/plugins/lua/rocklib_events.c5
-rw-r--r--firmware/target/hosted/kernel-unix.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/apps/plugins/lua/rocklib_events.c b/apps/plugins/lua/rocklib_events.c
index dc15c363a4..1c13a6758f 100644
--- a/apps/plugins/lua/rocklib_events.c
+++ b/apps/plugins/lua/rocklib_events.c
@@ -424,7 +424,10 @@ static void init_event_thread(bool init, struct event_data *ev_data)
424 IF_COP(, COP)); 424 IF_COP(, COP));
425 425
426 /* Timer is used to poll waiting events */ 426 /* Timer is used to poll waiting events */
427 rb->timer_register(1, NULL, EV_TIMER_FREQ, rev_timer_isr IF_COP(, CPU)); 427 if (!rb->timer_register(1, NULL, EV_TIMER_FREQ, rev_timer_isr IF_COP(, CPU)))
428 {
429 rb->splash(100, "No timer available!");
430 }
428} 431}
429 432
430static void playback_event_callback(unsigned short id, void *data) 433static void playback_event_callback(unsigned short id, void *data)
diff --git a/firmware/target/hosted/kernel-unix.c b/firmware/target/hosted/kernel-unix.c
index 1ce4dd8a10..5e9204effd 100644
--- a/firmware/target/hosted/kernel-unix.c
+++ b/firmware/target/hosted/kernel-unix.c
@@ -104,7 +104,7 @@ void tick_start(unsigned int interval_in_ms)
104} 104}
105 105
106#define cycles_to_microseconds(cycles) \ 106#define cycles_to_microseconds(cycles) \
107 ((int)((1000000*cycles)/TIMER_FREQ)) 107 ((int)((10000*cycles)/(TIMER_FREQ / 100)))
108 108
109 109
110static timer_t timer_tid; 110static timer_t timer_tid;