SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
stm32f1_utils.cpp
Go to the documentation of this file.
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
8uint32_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
29uint32_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