SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
stm32f4_utils.cpp
Go to the documentation of this file.
1#include "../stm32_adc_utils.h"
2
3#if defined(STM32F4xx)
4
5// timer to injected TRGO
6// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h#L179
7uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){
8 if(timer->Instance == TIM1)
9 return ADC_EXTERNALTRIGINJECCONV_T1_TRGO;
10#ifdef TIM2 // if defined timer 2
11 else if(timer->Instance == TIM2)
12 return ADC_EXTERNALTRIGINJECCONV_T2_TRGO;
13#endif
14#ifdef TIM4 // if defined timer 4
15 else if(timer->Instance == TIM4)
16 return ADC_EXTERNALTRIGINJECCONV_T4_TRGO;
17#endif
18#ifdef TIM5 // if defined timer 5
19 else if(timer->Instance == TIM5)
20 return ADC_EXTERNALTRIGINJECCONV_T5_TRGO;
21#endif
22 else
23 return _TRGO_NOT_AVAILABLE;
24}
25
26// timer to regular TRGO
27// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h#L331
28uint32_t _timerToRegularTRGO(TIM_HandleTypeDef* timer){
29#ifdef TIM2 // if defined timer 2
30 if(timer->Instance == TIM2)
31 return ADC_EXTERNALTRIGCONV_T2_TRGO;
32#endif
33#ifdef TIM3 // if defined timer 3
34 if(timer->Instance == TIM3)
35 return ADC_EXTERNALTRIGCONV_T3_TRGO;
36#endif
37#ifdef TIM8 // if defined timer 8
38 if(timer->Instance == TIM8)
39 return ADC_EXTERNALTRIGCONV_T8_TRGO;
40#endif
41 return _TRGO_NOT_AVAILABLE;
42}
43
44#endif