Skip to content

Commit d8fac13

Browse files
committed
f1 update
1 parent 9bb6cfb commit d8fac13

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "stm32_adc_utils.h"
22

3-
#if defined(_STM32_DEF_)
3+
#if defined(_STM32_DEF_)
44

55
// for searching the best ADCs, we need to know the number of ADCs
66
// it might be better to use some HAL variable for example ADC_COUNT

src/current_sense/hardware_specific/stm32/stm32f1/stm32f1_hal.cpp

+1-34
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,9 @@
33
#if defined(STM32F1xx)
44

55
#include "../../../../communication/SimpleFOCDebug.h"
6+
#include "../stm32_adc_utils.h"
67
#define _TRGO_NOT_AVAILABLE 12345
78

8-
// timer to injected TRGO
9-
// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h#L215
10-
uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){
11-
if(timer->Instance == TIM1)
12-
return ADC_EXTERNALTRIGINJECCONV_T1_TRGO;
13-
#ifdef TIM2 // if defined timer 2
14-
else if(timer->Instance == TIM2)
15-
return ADC_EXTERNALTRIGINJECCONV_T2_TRGO;
16-
#endif
17-
#ifdef TIM4 // if defined timer 4
18-
else if(timer->Instance == TIM4)
19-
return ADC_EXTERNALTRIGINJECCONV_T4_TRGO;
20-
#endif
21-
#ifdef TIM5 // if defined timer 5
22-
else if(timer->Instance == TIM5)
23-
return ADC_EXTERNALTRIGINJECCONV_T5_TRGO;
24-
#endif
25-
else
26-
return _TRGO_NOT_AVAILABLE;
27-
}
28-
29-
// timer to regular TRGO
30-
// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h#L215
31-
uint32_t _timerToRegularTRGO(TIM_HandleTypeDef* timer){
32-
if(timer->Instance == TIM3)
33-
return ADC_EXTERNALTRIGCONV_T3_TRGO;
34-
#ifdef TIM8 // if defined timer 8
35-
else if(timer->Instance == TIM8)
36-
return ADC_EXTERNALTRIGCONV_T8_TRGO;
37-
#endif
38-
else
39-
return _TRGO_NOT_AVAILABLE;
40-
}
41-
429
ADC_HandleTypeDef hadc;
4310

4411
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "../stm32_adc_utils.h"
2+
3+
#if defined(STM32F1xx)
4+
5+
6+
// timer to injected TRGO
7+
// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h#L215
8+
uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){
9+
if(timer->Instance == TIM1)
10+
return ADC_EXTERNALTRIGINJECCONV_T1_TRGO;
11+
#ifdef TIM2 // if defined timer 2
12+
else if(timer->Instance == TIM2)
13+
return ADC_EXTERNALTRIGINJECCONV_T2_TRGO;
14+
#endif
15+
#ifdef TIM4 // if defined timer 4
16+
else if(timer->Instance == TIM4)
17+
return ADC_EXTERNALTRIGINJECCONV_T4_TRGO;
18+
#endif
19+
#ifdef TIM5 // if defined timer 5
20+
else if(timer->Instance == TIM5)
21+
return ADC_EXTERNALTRIGINJECCONV_T5_TRGO;
22+
#endif
23+
else
24+
return _TRGO_NOT_AVAILABLE;
25+
}
26+
27+
// timer to regular TRGO
28+
// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h#L215
29+
uint32_t _timerToRegularTRGO(TIM_HandleTypeDef* timer){
30+
if(timer->Instance == TIM3)
31+
return ADC_EXTERNALTRIGCONV_T3_TRGO;
32+
#ifdef TIM8 // if defined timer 8
33+
else if(timer->Instance == TIM8)
34+
return ADC_EXTERNALTRIGCONV_T8_TRGO;
35+
#endif
36+
else
37+
return _TRGO_NOT_AVAILABLE;
38+
}
39+
40+
#endif

0 commit comments

Comments
 (0)