Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /// This file deals with calculating RPM |
2 | #pragma once |
||
3 | |||
4 | #include "main.h" |
||
5 | #if !defined RPMTIMER |
||
6 | #warning RPMTIMER was not set |
||
7 | #endif |
||
8 | |||
9 | #if RPMTIMER==1 |
||
10 | // construct macros to deal with interrupts from the given Timer channel |
||
11 | #define TIMER_IRQ_HANDLER TIM1_IRQHandler |
||
12 | #define TIMER_HANDLE htim1 |
||
13 | #elif RPMTIMER==2 |
||
14 | #define TIMER_IRQ_HANDLER TIM2_IRQHandler |
||
15 | #define TIMER_HANDLE htim2 |
||
16 | #elif RPMTIMER==3 |
||
17 | #define TIMER_IRQ_HANDLER TIM3_IRQHandler |
||
18 | #define TIMER_HANDLE htim3 |
||
19 | #elif RPMTIMER==4 |
||
20 | #define TIMER_IRQ_HANDLER TIM4_IRQHandler |
||
21 | #define TIMER_HANDLE htim4 |
||
22 | #endif |
||
23 | |||
24 | |||
25 | #if defined RPMTIMER |
||
26 | |||
27 | #define RPM_FLAG (1UL << 16) // set high if the CB points are opened |
||
28 | #define RPM_SAMPLES 256 // sample times per 100mS or 1000mS when testing |
||
29 | #define RPM_COUNT_RATE 100000UL // Counter increments at 100KHz (need to match in STM32CubeMX) |
||
30 | |||
31 | #define RPM_AVERAGE 4 |
||
32 | |||
9 | mjames | 33 | |
34 | #endif |
||
35 | |||
2 | mjames | 36 | #if defined __cplusplus |
37 | extern "C" |
||
38 | { |
||
39 | #endif |
||
40 | // return rpm estimate or -1 if not calculated this time |
||
41 | extern int CalculateRPM(void); |
||
42 | |||
43 | #if defined __cplusplus |
||
44 | } |
||
45 | #endif |