Rev 8 | Rev 28 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 9 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | * |
3 | * |
4 | * Created on: 21 Sep 2016 |
4 | * Created on: 21 Sep 2016 |
5 | * Author: Mike |
5 | * Author: Mike |
6 | */ |
6 | */ |
7 | #include "stm32l1xx_hal.h" |
7 | #include "stm32l1xx_hal.h" |
- | 8 | #include "misc.h" |
|
- | 9 | #include "main.h" |
|
- | 10 | ||
- | 11 | unsigned volatile long RPM_Time[RPM_SAMPLES]; // sampled on falling edge |
|
- | 12 | unsigned volatile long RPM_Count; // incremented every reading |
|
- | 13 | ||
- | 14 | ||
8 | 15 | ||
9 | void _init(void) |
16 | void _init(void) |
10 | { |
17 | { |
11 | 18 | ||
12 | } |
19 | } |
13 | 20 | ||
14 | 21 | ||
15 | void TIM2_IRQHandler(void) |
22 | void TIM2_IRQHandler(void) |
16 | { |
23 | { |
- | 24 | if(__HAL_TIM_GET_FLAG(&htim2, TIM_FLAG_CC1)) |
|
17 | 25 | { |
|
- | 26 | __HAL_TIM_CLEAR_FLAG(&htim2, TIM_FLAG_CC1) ; |
|
- | 27 | RPM_Time[RPM_Count++] = __HAL_TIM_GET_COMPARE(&htim2,TIM_CHANNEL_1); |
|
- | 28 | if (RPM_Count == RPM_SAMPLES) { |
|
- | 29 | RPM_Count = 0; |
|
18 | 30 | } |
|
19 | 31 | } |
|
20 | } |
32 | } |
21 | 33 | ||
22 | 34 | ||
23 | char blink = 0; |
35 | char blink = 0; |
24 | // 100mS periodic sampler handler |
36 | // 100mS periodic sampler handler |
25 | void TIM6_IRQHandler(void) |
37 | void TIM6_IRQHandler(void) |
26 | { |
38 | { |
27 | __HAL_TIM_CLEAR_FLAG(&htim6, TIM_FLAG_UPDATE) ; |
39 | if(__HAL_TIM_GET_FLAG(&htim6, TIM_FLAG_UPDATE)) |
- | 40 | { |
|
28 | TimerFlag = 1; |
41 | __HAL_TIM_CLEAR_FLAG(&htim6, TIM_FLAG_UPDATE) ; |
29 | 42 | ||
30 | blink = !blink; |
43 | blink = !blink; |
31 | HAL_GPIO_WritePin(LED_Blink_GPIO_Port, LED_Blink_Pin, blink ? GPIO_PIN_SET : GPIO_PIN_RESET); |
44 | HAL_GPIO_WritePin(LED_Blink_GPIO_Port, LED_Blink_Pin, blink ? GPIO_PIN_SET : GPIO_PIN_RESET); |
32 | 45 | ||
- | 46 | TimerFlag = 1; |
|
33 | if (NoSerialInCTR < 5) { |
47 | if (NoSerialInCTR < 5) { |
34 | NoSerialInCTR++; |
48 | NoSerialInCTR++; |
35 | if (NoSerialInCTR == 5) { |
49 | if (NoSerialInCTR == 5) { |
36 | NoSerialIn = 1; |
50 | NoSerialIn = 1; |
37 | } |
- | |
38 | } |
51 | } |
- | 52 | } |
|
39 | 53 | } |
|
40 | 54 | ||
41 | } |
55 | } |
42 | 56 | ||
43 | 57 | ||
44 | 58 |