SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
stm32l4_utils.cpp
Go to the documentation of this file.
1#include "../stm32_adc_utils.h"
2
3#if defined(STM32L4xx)
4
5
6// timer to injected TRGO
7// https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_adc_ex.h#L210
8uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){
9 if(timer->Instance == TIM1)
10 return ADC_EXTERNALTRIGINJEC_T1_TRGO;
11#ifdef TIM2 // if defined timer 2
12 else if(timer->Instance == TIM2)
13 return ADC_EXTERNALTRIGINJEC_T2_TRGO;
14#endif
15#ifdef TIM3 // if defined timer 3
16 else if(timer->Instance == TIM3)
17 return ADC_EXTERNALTRIGINJEC_T3_TRGO;
18#endif
19#ifdef TIM4 // if defined timer 4
20 else if(timer->Instance == TIM4)
21 return ADC_EXTERNALTRIGINJEC_T4_TRGO;
22#endif
23#ifdef TIM6 // if defined timer 6
24 else if(timer->Instance == TIM6)
25 return ADC_EXTERNALTRIGINJEC_T6_TRGO;
26#endif
27#ifdef TIM8 // if defined timer 8
28 else if(timer->Instance == TIM8)
29 return ADC_EXTERNALTRIGINJEC_T8_TRGO;
30#endif
31#ifdef TIM15 // if defined timer 15
32 else if(timer->Instance == TIM15)
33 return ADC_EXTERNALTRIGINJEC_T15_TRGO;
34#endif
35 else
36 return _TRGO_NOT_AVAILABLE;
37}
38
39// timer to regular TRGO
40// https://github.com/stm32duino/Arduino_Core_STM32/blob/6588dee03382e73ed42c4a5e473900ab3b79d6e4/system/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_adc.h#L519
41uint32_t _timerToRegularTRGO(TIM_HandleTypeDef* timer){
42 if(timer->Instance == TIM1)
43 return ADC_EXTERNALTRIG_T1_TRGO;
44#ifdef TIM2 // if defined timer 2
45 else if(timer->Instance == TIM2)
46 return ADC_EXTERNALTRIG_T2_TRGO;
47#endif
48#ifdef TIM3 // if defined timer 3
49 else if(timer->Instance == TIM3)
50 return ADC_EXTERNALTRIG_T3_TRGO;
51#endif
52#ifdef TIM4 // if defined timer 4
53 else if(timer->Instance == TIM4)
54 return ADC_EXTERNALTRIG_T4_TRGO;
55#endif
56#ifdef TIM6 // if defined timer 6
57 else if(timer->Instance == TIM6)
58 return ADC_EXTERNALTRIG_T6_TRGO;
59#endif
60#ifdef TIM8 // if defined timer 8
61 else if(timer->Instance == TIM8)
62 return ADC_EXTERNALTRIG_T8_TRGO;
63#endif
64#ifdef TIM15 // if defined timer 15
65 else if(timer->Instance == TIM15)
66 return ADC_EXTERNALTRIG_T15_TRGO;
67#endif
68 else
69 return _TRGO_NOT_AVAILABLE;
70}
71
72#endif