altosui: Add config and pyro tabs to graph widget
[fw/altos] / src / stm32f1 / ao_timer.c
index 116d33ace1981bf2a96b37257f5fcab6f4720b34..1368ab684cb4eabf4b846154a65e8b9809085131 100644 (file)
@@ -47,17 +47,47 @@ ao_time_ns(void)
                (uint64_t) val * (1000000000ULL / AO_SYSTICK);
 }
 
+#if AO_DATA_ALL
+volatile uint8_t       ao_data_interval = 1;
+volatile uint8_t       ao_data_count;
+#endif
+
 void stm_systick_isr(void)
 {
        if (stm_systick.ctrl & (1 << STM_SYSTICK_CTRL_COUNTFLAG)) {
                ++ao_tick_count;
-//             ao_task_check_alarm();
+               ao_task_check_alarm();
+#if AO_DATA_ALL
+               if (++ao_data_count == ao_data_interval && ao_data_interval) {
+                       ao_data_count = 0;
+#if HAS_FAKE_FLIGHT
+                       if (ao_fake_flight_active)
+                               ao_fake_flight_poll();
+                       else
+#endif
+                               ao_adc_poll();
+#if (AO_DATA_ALL & ~(AO_DATA_ADC))
+                       ao_wakeup((void *) &ao_data_count);
+#endif
+               }
+#endif
 #ifdef AO_TIMER_HOOK
                AO_TIMER_HOOK;
 #endif
        }
 }
 
+#if HAS_ADC
+void
+ao_timer_set_adc_interval(uint8_t interval)
+{
+       ao_arch_critical(
+               ao_data_interval = interval;
+               ao_data_count = 0;
+               );
+}
+#endif
+
 #define SYSTICK_RELOAD (AO_SYSTICK / 100 - 1)
 
 void
@@ -68,5 +98,5 @@ ao_timer_init(void)
        stm_systick.ctrl = ((1 << STM_SYSTICK_CTRL_ENABLE) |
                            (1 << STM_SYSTICK_CTRL_TICKINT) |
                            (STM_SYSTICK_CTRL_CLKSOURCE_HCLK_8 << STM_SYSTICK_CTRL_CLKSOURCE));
-//     stm_nvic.shpr15_12 |= (uint32_t) AO_STM_NVIC_CLOCK_PRIORITY << 24;
+       stm_scb.shpr3 |= (uint32_t) AO_STM_NVIC_CLOCK_PRIORITY << 24;
 }