77
88// timer to injected TRGO
99// 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)
1212 return ADC_EXTERNALTRIGINJECCONV_T1_TRGO;
1313#ifdef TIM2 // if defined timer 2
14- else if (timer->getHandle ()-> Instance == TIM2)
14+ else if (timer->Instance == TIM2)
1515 return ADC_EXTERNALTRIGINJECCONV_T2_TRGO;
1616#endif
1717#ifdef TIM4 // if defined timer 4
18- else if (timer->getHandle ()-> Instance == TIM4)
18+ else if (timer->Instance == TIM4)
1919 return ADC_EXTERNALTRIGINJECCONV_T4_TRGO;
2020#endif
2121#ifdef TIM5 // if defined timer 5
22- else if (timer->getHandle ()-> Instance == TIM5)
22+ else if (timer->Instance == TIM5)
2323 return ADC_EXTERNALTRIGINJECCONV_T5_TRGO;
2424#endif
2525 else
@@ -28,11 +28,11 @@ uint32_t _timerToInjectedTRGO(HardwareTimer* timer){
2828
2929// timer to regular TRGO
3030// 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)
3333 return ADC_EXTERNALTRIGCONV_T3_TRGO;
3434#ifdef TIM8 // if defined timer 8
35- else if (timer->getHandle ()-> Instance == TIM8)
35+ else if (timer->Instance == TIM8)
3636 return ADC_EXTERNALTRIGCONV_T8_TRGO;
3737#endif
3838 else
@@ -82,16 +82,16 @@ int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* drive
8282
8383 // automating TRGO flag finding - hardware specific
8484 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++]);
8787 if (trigger_flag == _TRGO_NOT_AVAILABLE) continue ; // timer does not have valid trgo for injected channels
8888
8989 // if the code comes here, it has found the timer available
9090 // timer does have trgo flag for injected channels
9191 sConfigInjected .ExternalTrigInjecConv = trigger_flag;
9292
9393 // 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 ];
9595 // done
9696 break ;
9797 }
@@ -105,7 +105,7 @@ int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* drive
105105 // display which timer is being used
106106 #ifdef SIMPLEFOC_STM32_DEBUG
107107 // 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 );
109109 #endif
110110
111111 // first channel
0 commit comments