diff options
author | fishsoupisgood <github@madingley.org> | 2020-09-09 11:53:37 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-09-09 11:53:37 +0100 |
commit | 9d87c925a9eaa4fc256be3173c14a20d1469472d (patch) | |
tree | 50d63f87a47a0eac3f5b8058850184bcd4e6ee95 /stm32/app/ticker.c | |
parent | dafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff) | |
download | heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2 heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip |
everything, mostly, working
Diffstat (limited to 'stm32/app/ticker.c')
-rw-r--r-- | stm32/app/ticker.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/stm32/app/ticker.c b/stm32/app/ticker.c deleted file mode 100644 index e47f4eb..0000000 --- a/stm32/app/ticker.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "project.h" - - -static volatile uint32_t delay_hms_count; -static volatile uint32_t ticks; -static uint32_t scale = 7; - -void -delay_us (uint32_t d) -{ - d *= scale; - - while (d--) - __asm__ ("nop"); -} - -void -sys_tick_handler (void) -{ - if (delay_hms_count) - delay_hms_count--; - - led_tick(); - ot_phy_tx_tick(); - ot_tick(); - onewire_tick(); - temp_tick(); - adc_tick(); - pressure_tick(); - - - ticks++; -} - - - -void -delay_ms (uint32_t d) -{ - delay_hms_count = d << 1; - - while (delay_hms_count); -} - -#if 0 -int -timed_out (uint32_t then, unsigned int ms) -{ - then = ticks - then; - - if (then > ms) - return 1; - - return 0; -} - -int -timed_out_cycles (uint32_t then, unsigned int cycles) -{ - then = dwt_read_cycle_counter() - then; - - if (then > cycles) - return 1; - - return 0; -} -#endif - - - -void -ticker_init (void) -{ - uint32_t v, w; - - /*Start periodic timer */ - - systick_set_clocksource (STK_CSR_CLKSOURCE_AHB_DIV8); - /* 72MHz / 8 = > 9Mhz */ - systick_set_reload (4500); - /* 9MHz / 4500 => 2kHz */ - systick_interrupt_enable(); - systick_counter_enable(); - - /*Calibrate the delay loop */ - - - - do { - scale--; - v = ticks; - - while (v == ticks); - - delay_us (500); - w = ticks; - v++; - w -= v; - } while (w); - - - -} |