rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
stm32_pwm.cpp File Reference

Functions

static expected< stm32_pwm_config > getConfigForPin (brain_pin_e pin)
 
stm32_hardware_pwm * getNextPwmDevice ()
 

Variables

static stm32_hardware_pwm hardPwms [5]
 

Function Documentation

◆ getConfigForPin()

static expected< stm32_pwm_config > getConfigForPin ( brain_pin_e  pin)
static

Could this be unified with getIcuParams() method?

Definition at line 95 of file stm32_pwm.cpp.

95 {
96 switch (pin) {
97#if STM32_PWM_USE_TIM1
98 case Gpio::A8: return stm32_pwm_config{&PWMD1, /*channel*/0, /*AF*/1};
99 case Gpio::A9: return stm32_pwm_config{&PWMD1, /*channel*/1, /*AF*/1};
100 case Gpio::A10: return stm32_pwm_config{&PWMD1, 2, 1};
101 case Gpio::A11: return stm32_pwm_config{&PWMD1, 3, 1};
102
103 case Gpio::E9: return stm32_pwm_config{&PWMD1, 0, 1};
104 case Gpio::E11: return stm32_pwm_config{&PWMD1, 1, 1};
105 case Gpio::E13: return stm32_pwm_config{&PWMD1, 2, 1};
106 case Gpio::E14: return stm32_pwm_config{&PWMD1, 3, 1};
107#endif
108#if STM32_PWM_USE_TIM2
109 case Gpio::A15: return stm32_pwm_config{&PWMD2, 0, 1};
110 case Gpio::B3: return stm32_pwm_config{&PWMD2, 1, 1};
111 case Gpio::B10: return stm32_pwm_config{&PWMD2, 2, 1};
112 case Gpio::B11: return stm32_pwm_config{&PWMD2, 3, 1};
113#endif
114#if STM32_PWM_USE_TIM3
115 case Gpio::B4: return stm32_pwm_config{&PWMD3, 0, 2};
116 case Gpio::B5: return stm32_pwm_config{&PWMD3, 1, 2};
117
118 case Gpio::C6: return stm32_pwm_config{&PWMD3, 0, 2};
119 case Gpio::C7: return stm32_pwm_config{&PWMD3, 1, 2};
120#endif
121#if STM32_PWM_USE_TIM4
122 case Gpio::B6: return stm32_pwm_config{&PWMD4, 0, 2};
123 case Gpio::B7: return stm32_pwm_config{&PWMD4, 1, 2};
124 case Gpio::B8: return stm32_pwm_config{&PWMD4, 2, 2};
125 case Gpio::B9: return stm32_pwm_config{&PWMD4, 3, 2};
126
127 case Gpio::D12: return stm32_pwm_config{&PWMD4, 0, 2};
128 case Gpio::D13: return stm32_pwm_config{&PWMD4, 1, 2};
129 case Gpio::D14: return stm32_pwm_config{&PWMD4, 2, 2};
130 case Gpio::D15: return stm32_pwm_config{&PWMD4, 3, 2};
131#endif
132#if STM32_PWM_USE_TIM5
133 case Gpio::A0: return stm32_pwm_config{&PWMD5, 0, 2};
134 case Gpio::A1: return stm32_pwm_config{&PWMD5, 1, 2};
135 case Gpio::A2: return stm32_pwm_config{&PWMD5, 2, 2};
136 case Gpio::A3: return stm32_pwm_config{&PWMD5, 3, 2};
137#endif
138#if STM32_PWM_USE_TIM8
139
140 /* TIM8 may be used for ADC trigger */
141#ifndef EFI_INTERNAL_FAST_ADC_PWM
142#if !STM32_PWM_USE_TIM3
143 // If TIM3 is not used, put these pins on TIM8 instead..
144 // See https://github.com/rusefi/rusefi/issues/639
145 // See https://github.com/rusefi/rusefi/pull/3032
146 case Gpio::C6: return stm32_pwm_config{&PWMD8, 0, 3};
147 case Gpio::C7: return stm32_pwm_config{&PWMD8, 1, 3};
148#endif
149
150 case Gpio::C8: return stm32_pwm_config{&PWMD8, 2, 3};
151 case Gpio::C9: return stm32_pwm_config{&PWMD8, 3, 3};
152#endif
153#endif
154
155#if STM32_PWM_USE_TIM9
156 case Gpio::E5: return stm32_pwm_config{&PWMD9, 0, 3};
157 case Gpio::E6: return stm32_pwm_config{&PWMD9, 1, 3};
158#endif
159 default: return unexpected;
160 }
161};
PWMDriver PWMD2
PWMD2 driver identifier.
Definition hal_pwm_lld.c:57
PWMDriver PWMD1
PWMD1 driver identifier.
Definition hal_pwm_lld.c:49
PWMDriver PWMD4
PWMD4 driver identifier.
Definition hal_pwm_lld.c:73
PWMDriver PWMD3
PWMD3 driver identifier.
Definition hal_pwm_lld.c:65
brain_pin_e pin
Definition stm32_adc.cpp:15

◆ getNextPwmDevice()

stm32_hardware_pwm * getNextPwmDevice ( )

Definition at line 165 of file stm32_pwm.cpp.

165 {
166 for (size_t i = 0; i < efi::size(hardPwms); i++) {
167 if (!hardPwms[i].hasInit()) {
168 return &hardPwms[i];
169 }
170 }
171
172 criticalError("Run out of hardware PWM devices!");
173 return nullptr;
174}
static stm32_hardware_pwm hardPwms[5]

Variable Documentation

◆ hardPwms

stm32_hardware_pwm hardPwms[5]
static

Definition at line 163 of file stm32_pwm.cpp.

Referenced by getNextPwmDevice().

Go to the source code of this file.