X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fao_timer.c;h=8b7c2327ff2bdd34f93e7f93a8351f0c3ff63a4f;hb=398c02b945a58634c8932f07df2c2be8438da7d1;hp=f3011d3f0e159097c71ce8c3e3f49443c98d070b;hpb=055f3232decc07e064d596469b81cf9869411c2d;p=fw%2Faltos diff --git a/src/stm/ao_timer.c b/src/stm/ao_timer.c index f3011d3f..8b7c2327 100644 --- a/src/stm/ao_timer.c +++ b/src/stm/ao_timer.c @@ -16,16 +16,14 @@ */ #include "ao.h" +#include -volatile __data AO_TICK_TYPE ao_tick_count; +volatile AO_TICK_TYPE ao_tick_count; -uint16_t ao_time(void) +AO_TICK_TYPE +ao_time(void) { - uint16_t v; - ao_arch_critical( - v = ao_tick_count; - ); - return v; + return ao_tick_count; } #if AO_DATA_ALL @@ -42,6 +40,10 @@ void stm_tim6_isr(void) if (stm_tim6.sr & (1 << STM_TIM67_SR_UIF)) { stm_tim6.sr = 0; ++ao_tick_count; +#if HAS_TASK_QUEUE + if (ao_task_alarm_tick && (int16_t) (ao_tick_count - ao_task_alarm_tick) >= 0) + ao_task_check_alarm((uint16_t) ao_tick_count); +#endif #if AO_DATA_ALL if (++ao_data_count == ao_data_interval) { ao_data_count = 0; @@ -56,10 +58,12 @@ void stm_tim6_isr(void) #if HAS_ADC void -ao_timer_set_adc_interval(uint8_t interval) __critical +ao_timer_set_adc_interval(uint8_t interval) { - ao_data_interval = interval; - ao_data_count = 0; + ao_arch_critical( + ao_data_interval = interval; + ao_data_count = 0; + ); } #endif