From a088ab503f5ff0a837a50bf9d9cc92c70c6db1a3 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Tue, 27 Apr 2021 14:57:27 +0200 Subject: [PATCH] update to GINT_CALL() callbacks --- src/gint/rtc.c | 36 +++++++++++------------------------- src/gint/timer.c | 4 ++-- src/gint/timer_callbacks.c | 4 ++-- src/gint/tlb.c | 4 ++-- src/perf/interrupt.c | 3 ++- src/perf/libprof.c | 2 +- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/gint/rtc.c b/src/gint/rtc.c index e96b3ef..ab9ac91 100644 --- a/src/gint/rtc.c +++ b/src/gint/rtc.c @@ -237,7 +237,7 @@ static uint32_t test_speed(void) int volatile flag = 0; prof = prof_make(); - rtc_start_timer(RTC_16Hz, speed_callback, &flag); + rtc_periodic_enable(RTC_16Hz, GINT_CALL(speed_callback, &flag)); while(flag != 2) sleep(); return prof_time(prof); @@ -548,15 +548,6 @@ static void edit_date(void) // Main screen with lazy update //--- -static volatile int frame_done = 0; - -static int rtc_timer_callback(void) -{ - frame_done = 0; - return TIMER_CONTINUE; -} - -/* gintctl_gint_rtc(): Configure RTC and check timer speed */ void gintctl_gint_rtc(void) { key_event_t ev; @@ -566,23 +557,18 @@ void gintctl_gint_rtc(void) int tab = 1; uint32_t elapsed = test_speed(); + volatile int frame_needed = 1; - rtc_start_timer(RTC_1Hz, rtc_timer_callback); + rtc_periodic_enable(RTC_1Hz, GINT_CALL_SET(&frame_needed)); while(run_loop) { - if(!frame_done) rtc_get_time(&time); - - /* Redraw only when a second elapses */ - if(!frame_done && tab == 1) + if(frame_needed) { - draw_rtc(&time); - frame_done = 1; - } - else if(!frame_done && tab == 2) - { - draw_speed(&time, elapsed); - frame_done = 1; + rtc_get_time(&time); + if(tab == 1) draw_rtc(&time); + if(tab == 2) draw_speed(&time, elapsed); + frame_needed = 0; } /* Handle keyboard events */ @@ -599,13 +585,13 @@ void gintctl_gint_rtc(void) else if(ev.key == KEY_F6 && tab == 1) edit_time(); else action = 0; - if(action) frame_done = 0; + if(action) frame_needed = 1; } /* Wait for either keyboard or RTC to produce an event, except if we already have work to do */ - if(frame_done) sleep(); + if(!frame_needed) sleep(); } - rtc_stop_timer(); + rtc_periodic_disable(); } diff --git a/src/gint/timer.c b/src/gint/timer.c index 183e993..0710e21 100644 --- a/src/gint/timer.c +++ b/src/gint/timer.c @@ -145,8 +145,8 @@ void gintctl_gint_timer(void) /* On F1, pretend to sleep and just see what happens */ if(key == KEY_F1) { - int free = timer_setup(tid, timer_delay(tid, 1000000, - TIMER_Pphi_4), NULL); + int free = timer_configure(tid, timer_delay(tid, 1000000, + TIMER_Pphi_4), GINT_CALL_NULL); if(free == tid) timer_start(tid); } diff --git a/src/gint/timer_callbacks.c b/src/gint/timer_callbacks.c index e7961f1..e720c03 100644 --- a/src/gint/timer_callbacks.c +++ b/src/gint/timer_callbacks.c @@ -103,7 +103,7 @@ void gintctl_gint_timer_callbacks(void) if(!callback) continue; /* Allocate a first timer to run the callback */ - int t = timer_setup(TIMER_ANY, 40000, callback, arg); + int t = timer_configure(TIMER_ANY, 40000, GINT_CALL(callback, arg)); if(t < 0) { status = 2; @@ -114,7 +114,7 @@ void gintctl_gint_timer_callbacks(void) if(key == KEY_F2 || key == KEY_F3) { /* Request a TMU (higher priority) */ - auxiliary_timer = timer_setup(TIMER_TMU, 10000, NULL); + auxiliary_timer = timer_configure(TIMER_TMU,10000,GINT_CALL_NULL); if(auxiliary_timer < 0) { status = 2; diff --git a/src/gint/tlb.c b/src/gint/tlb.c index 05d23a8..b2fb0e0 100644 --- a/src/gint/tlb.c +++ b/src/gint/tlb.c @@ -419,8 +419,8 @@ void gintctl_gint_tlb(void) } if(key == KEY_F6 && next_miss != 0xffffffff) { - int timer = timer_setup(TIMER_ANY, 10000, - generate_tlb_miss, next_miss); + int timer = timer_configure(TIMER_ANY, 10000, + GINT_CALL(generate_tlb_miss, next_miss)); if(timer >= 0) { timer_start(timer); diff --git a/src/perf/interrupt.c b/src/perf/interrupt.c index 81eac3b..a7bf6b0 100644 --- a/src/perf/interrupt.c +++ b/src/perf/interrupt.c @@ -19,7 +19,8 @@ int stress_callback(int *counter) uint32_t stress_interrupts(void) { int counter = 0; - int timer = timer_setup(TIMER_ANY, 1, stress_callback, &counter); + int timer = timer_configure(TIMER_ANY, 1, + GINT_CALL(stress_callback, &counter)); if(timer < 0) return 0; return prof_exec({ diff --git a/src/perf/libprof.c b/src/perf/libprof.c index 905e7bc..f2cff73 100644 --- a/src/perf/libprof.c +++ b/src/perf/libprof.c @@ -12,7 +12,7 @@ static uint32_t run_sleep(int us) { /* We can't use sleep_us() as we want a TMU */ volatile int flag = 0; - int timer = timer_setup(TIMER_TMU, us, timer_timeout, &flag); + int timer = timer_configure(TIMER_TMU, us, GINT_CALL_SET_STOP(&flag)); if(timer < 0) return 0; return prof_exec({