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