From b8a9273162b7016afc29f4c98fc3b66324d4c85b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Jun 2020 15:00:28 -0700 Subject: [PATCH] altos: Fix a bunch of time variables to be AO_TICK_TYPE The default tick type is now 32 bits, so all of these variables were mis-typed at 16 bits. Signed-off-by: Keith Packard --- src/attiny/ao_arch.h | 2 +- src/attiny/ao_clock.c | 6 +++--- src/kernel/ao.h | 12 ++++++------ src/kernel/ao_beep.h | 2 +- src/kernel/ao_notask.c | 2 +- src/kernel/ao_task.c | 14 +++++++------- src/kernel/ao_task.h | 10 +++++----- src/lpc/ao_beep_lpc.c | 2 +- src/stm/ao_beep_stm.c | 2 +- src/stmf0/ao_beep_stm.c | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h index 5550eb44..eecd297b 100644 --- a/src/attiny/ao_arch.h +++ b/src/attiny/ao_arch.h @@ -77,7 +77,7 @@ #define ao_mutex_put(m) void -ao_delay_until(uint16_t target); +ao_delay_until(AO_TICK_TYPE target); /* We can't hit 100 Hz, but we can hit 125 */ #define AO_HERTZ 125 diff --git a/src/attiny/ao_clock.c b/src/attiny/ao_clock.c index 2ac0500b..06695850 100644 --- a/src/attiny/ao_clock.c +++ b/src/attiny/ao_clock.c @@ -31,7 +31,7 @@ ISR(TIMER1_COMPA_vect) AO_TICK_TYPE ao_time(void) { - uint16_t r; + AO_TICK_TYPE r; cli(); r = ao_tick_count; @@ -127,7 +127,7 @@ void ao_delay_us(uint16_t us) } void -ao_delay_until(uint16_t target) +ao_delay_until(AO_TICK_TYPE target) { cli(); ao_wakeup_count = target; @@ -137,7 +137,7 @@ ao_delay_until(uint16_t target) } void -ao_delay(uint16_t ticks) +ao_delay(AO_TICK_TYPE ticks) { ao_delay_until(ao_time() + ticks); } diff --git a/src/kernel/ao.h b/src/kernel/ao.h index f44b0e9e..be663775 100644 --- a/src/kernel/ao.h +++ b/src/kernel/ao.h @@ -42,6 +42,11 @@ extern char ao_getchar(void); typedef AO_PORT_TYPE ao_port_t; +#ifndef AO_TICK_TYPE +#define AO_TICK_TYPE uint32_t +#define AO_TICK_SIGNED int32_t +#endif + #if HAS_TASK #include #else @@ -100,11 +105,6 @@ extern AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal; * ao_timer.c */ -#ifndef AO_TICK_TYPE -#define AO_TICK_TYPE uint32_t -#define AO_TICK_SIGNED int32_t -#endif - extern volatile AO_TICK_TYPE ao_tick_count; /* Our timer runs at 100Hz */ @@ -124,7 +124,7 @@ ao_time_ns(void); /* Suspend the current task until ticks time has passed */ void -ao_delay(uint16_t ticks); +ao_delay(AO_TICK_TYPE ticks); /* Set the ADC interval */ void diff --git a/src/kernel/ao_beep.h b/src/kernel/ao_beep.h index fdc150f1..8c5d5343 100644 --- a/src/kernel/ao_beep.h +++ b/src/kernel/ao_beep.h @@ -85,7 +85,7 @@ ao_beep(uint8_t beep); /* Turn on the beeper for the specified time */ void -ao_beep_for(uint8_t beep, uint16_t ticks); +ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks); /* Initialize the beeper */ void diff --git a/src/kernel/ao_notask.c b/src/kernel/ao_notask.c index a5bdc8a7..e973c7ae 100644 --- a/src/kernel/ao_notask.c +++ b/src/kernel/ao_notask.c @@ -41,7 +41,7 @@ ao_sleep(void *wchan) #if HAS_AO_DELAY void -ao_delay(uint16_t ticks) +ao_delay(AO_TICK_TYPE ticks) { AO_TICK_TYPE target; diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index 15cd2a55..38aefbec 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -126,7 +126,7 @@ ao_task_validate_alarm_queue(void) #define ao_task_validate_alarm_queue() #endif -uint16_t ao_task_alarm_tick; +AO_TICK_TYPE ao_task_alarm_tick; static void ao_task_to_alarm_queue(struct ao_task *task) @@ -174,7 +174,7 @@ ao_task_exit_queue(struct ao_task *task) } void -ao_task_check_alarm(uint16_t tick) +ao_task_check_alarm(AO_TICK_TYPE tick) { struct ao_task *alarm, *next; @@ -359,8 +359,8 @@ ao_yield(void) ao_arch_naked_define else { #if HAS_SAMPLE_PROFILE - uint16_t tick = ao_sample_profile_timer_value(); - uint16_t run = tick - ao_cur_task->start; + AO_TICK_TYPE tick = ao_sample_profile_timer_value(); + AO_TICK_TYPE run = tick - ao_cur_task->start; if (run > ao_cur_task->max_run) ao_cur_task->max_run = run; ++ao_cur_task->yields; @@ -493,7 +493,7 @@ ao_wakeup(void *wchan) } uint8_t -ao_sleep_for(void *wchan, uint16_t timeout) +ao_sleep_for(void *wchan, AO_TICK_TYPE timeout) { uint8_t ret; if (timeout) { @@ -530,7 +530,7 @@ ao_sleep_for(void *wchan, uint16_t timeout) static uint8_t ao_forever; void -ao_delay(uint16_t ticks) +ao_delay(AO_TICK_TYPE ticks) { if (!ticks) ticks = 1; @@ -565,7 +565,7 @@ ao_task_info(void) { uint8_t i; struct ao_task *task; - uint16_t now = ao_time(); + AO_TICK_TYPE now = ao_time(); for (i = 0; i < ao_num_tasks; i++) { task = ao_tasks[i]; diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h index 03b62969..7d81c1da 100644 --- a/src/kernel/ao_task.h +++ b/src/kernel/ao_task.h @@ -38,7 +38,7 @@ /* An AltOS task */ struct ao_task { void *wchan; /* current wait channel (NULL if running) */ - uint16_t alarm; /* abort ao_sleep time */ + AO_TICK_TYPE alarm; /* abort ao_sleep time */ uint16_t task_id; /* unique id */ /* Saved stack pointer */ union { @@ -96,7 +96,7 @@ ao_sleep(void *wchan); * 1 on alarm */ uint8_t -ao_sleep_for(void *wchan, uint16_t timeout); +ao_sleep_for(void *wchan, AO_TICK_TYPE timeout); /* Wake all tasks sleeping on wchan */ void @@ -105,7 +105,7 @@ ao_wakeup(void *wchan); #if 0 /* set an alarm to go off in 'delay' ticks */ void -ao_alarm(uint16_t delay); +ao_alarm(AO_TICK_TYPE delay); /* Clear any pending alarm */ void @@ -122,9 +122,9 @@ ao_add_task(struct ao_task * task, void (*start)(void), const char *name); #if HAS_TASK_QUEUE /* Called on timer interrupt to check alarms */ -extern uint16_t ao_task_alarm_tick; +extern AO_TICK_TYPE ao_task_alarm_tick; void -ao_task_check_alarm(uint16_t tick); +ao_task_check_alarm(AO_TICK_TYPE tick); #endif /* Terminate the current task */ diff --git a/src/lpc/ao_beep_lpc.c b/src/lpc/ao_beep_lpc.c index eab86ee6..ab06ef48 100644 --- a/src/lpc/ao_beep_lpc.c +++ b/src/lpc/ao_beep_lpc.c @@ -59,7 +59,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) +ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks) { ao_beep(beep); ao_delay(ticks); diff --git a/src/stm/ao_beep_stm.c b/src/stm/ao_beep_stm.c index 2bcd6849..12d2b0b6 100644 --- a/src/stm/ao_beep_stm.c +++ b/src/stm/ao_beep_stm.c @@ -148,7 +148,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) +ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks) { ao_beep(beep); ao_delay(ticks); diff --git a/src/stmf0/ao_beep_stm.c b/src/stmf0/ao_beep_stm.c index 31af7f4a..39022da1 100644 --- a/src/stmf0/ao_beep_stm.c +++ b/src/stmf0/ao_beep_stm.c @@ -376,7 +376,7 @@ ao_beep(uint8_t beep) } void -ao_beep_for(uint8_t beep, uint16_t ticks) +ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks) { ao_beep(beep); ao_delay(ticks); -- 2.30.2