7
7
8
8
// timer to injected TRGO
9
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 (HardwareTimer * timer){
11
- if (timer->getHandle ()-> Instance == TIM1)
10
+ uint32_t _timerToInjectedTRGO (TIM_HandleTypeDef * timer){
11
+ if (timer->Instance == TIM1)
12
12
return ADC_EXTERNALTRIGINJECCONV_T1_TRGO;
13
13
#ifdef TIM2 // if defined timer 2
14
- else if (timer->getHandle ()-> Instance == TIM2)
14
+ else if (timer->Instance == TIM2)
15
15
return ADC_EXTERNALTRIGINJECCONV_T2_TRGO;
16
16
#endif
17
17
#ifdef TIM4 // if defined timer 4
18
- else if (timer->getHandle ()-> Instance == TIM4)
18
+ else if (timer->Instance == TIM4)
19
19
return ADC_EXTERNALTRIGINJECCONV_T4_TRGO;
20
20
#endif
21
21
#ifdef TIM5 // if defined timer 5
22
- else if (timer->getHandle ()-> Instance == TIM5)
22
+ else if (timer->Instance == TIM5)
23
23
return ADC_EXTERNALTRIGINJECCONV_T5_TRGO;
24
24
#endif
25
25
else
@@ -28,11 +28,11 @@ uint32_t _timerToInjectedTRGO(HardwareTimer* timer){
28
28
29
29
// timer to regular TRGO
30
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 (HardwareTimer * timer){
32
- if (timer->getHandle ()-> Instance == TIM3)
31
+ uint32_t _timerToRegularTRGO (TIM_HandleTypeDef * timer){
32
+ if (timer->Instance == TIM3)
33
33
return ADC_EXTERNALTRIGCONV_T3_TRGO;
34
34
#ifdef TIM8 // if defined timer 8
35
- else if (timer->getHandle ()-> Instance == TIM8)
35
+ else if (timer->Instance == TIM8)
36
36
return ADC_EXTERNALTRIGCONV_T8_TRGO;
37
37
#endif
38
38
else
@@ -82,16 +82,16 @@ int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* drive
82
82
83
83
// automating TRGO flag finding - hardware specific
84
84
uint8_t tim_num = 0 ;
85
- while (driver_params->timers [tim_num] != NP && tim_num < 6 ){
86
- uint32_t trigger_flag = _timerToInjectedTRGO (driver_params->timers [tim_num++]);
85
+ while (driver_params->timers_handle [tim_num] != NP && tim_num < 6 ){
86
+ uint32_t trigger_flag = _timerToInjectedTRGO (driver_params->timers_handle [tim_num++]);
87
87
if (trigger_flag == _TRGO_NOT_AVAILABLE) continue ; // timer does not have valid trgo for injected channels
88
88
89
89
// if the code comes here, it has found the timer available
90
90
// timer does have trgo flag for injected channels
91
91
sConfigInjected .ExternalTrigInjecConv = trigger_flag;
92
92
93
93
// this will be the timer with which the ADC will sync
94
- cs_params->timer_handle = driver_params->timers [tim_num-1 ];
94
+ cs_params->timer_handle = driver_params->timers_handle [tim_num-1 ];
95
95
// done
96
96
break ;
97
97
}
@@ -105,7 +105,7 @@ int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* drive
105
105
// display which timer is being used
106
106
#ifdef SIMPLEFOC_STM32_DEBUG
107
107
// it would be better to use the getTimerNumber from driver
108
- SIMPLEFOC_DEBUG (" STM32-CS: injected trigger for timer index: " , get_timer_index (cs_params->timer_handle ->getHandle ()-> Instance ) + 1 );
108
+ SIMPLEFOC_DEBUG (" STM32-CS: injected trigger for timer index: " , get_timer_index (cs_params->timer_handle ->Instance ) + 1 );
109
109
#endif
110
110
111
111
// first channel
0 commit comments