summaryrefslogtreecommitdiffstats
path: root/app/tacho.c
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-06-18 13:26:56 +0100
committerfishsoupisgood <github@madingley.org>2020-06-18 13:26:56 +0100
commite41764fceeabb1cdb6a7a299e00f2166a6f6ac32 (patch)
treec58c73d742bf990ec692d61ca8d911dd43fab8c6 /app/tacho.c
parentf7b7cf9e80200cade938d47527e39034c75b9b6d (diff)
downloadrobs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.gz
robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.bz2
robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.zip
moved stm32 into directory added noddy pcb
Diffstat (limited to 'app/tacho.c')
-rw-r--r--app/tacho.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/app/tacho.c b/app/tacho.c
deleted file mode 100644
index bf0222c..0000000
--- a/app/tacho.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "project.h"
-
-#define SPURIOUS MS(10) /*Anything faster than 6000rpm is a false trigger */
-
-
-
-uint32_t raw_tacho;
-
-static uint32_t
-cycle_diff (uint32_t a, uint32_t b)
-{
- return b - a;
-}
-
-
-
-void
-TACHO_ISR (void)
-{
- uint32_t now, diff;
- static uint32_t last_edge;
-
- if (! (EXTI_PR & TACHO))
- return;
-
- EXTI_PR = TACHO;
-
- now = dwt_read_cycle_counter();
-
- diff = cycle_diff (last_edge, now);
-
- if (diff < SPURIOUS)
- return;
-
- last_edge = now;
-
-
- /* Want RPM, diff is in units of 1/72 us */
-
- if (!diff)
- return;
-
- /* uint32_t is un-able to express 60s in clock ticks, so divide everything by 2 */
-
- diff >>= 1;
-
-
-
- raw_tacho = (US ((60U * 1000000) / 2)) / diff;
-
-}
-
-
-void
-tacho_init (void)
-{
- MAP_INPUT_PU (TACHO);
-
- exti_select_source (TACHO, TACHO_PORT);
- exti_set_trigger (TACHO, EXTI_TRIGGER_FALLING);
- exti_enable_request (TACHO);
- exti_reset_request (TACHO);
-
- nvic_enable_irq (TACHO_IRQ);
-
-}