Skip to content

Commit c9ddb99

Browse files
author
Richard Unger
committed
add 1-PWM support to RP2040 PWM driver
1 parent e5f2cdf commit c9ddb99

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/drivers/hardware_specific/rp2040_mcu.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ void syncSlices() {
9595
}
9696

9797

98+
99+
void* _configure1PWM(long pwm_frequency, const int pinA) {
100+
RP2040DriverParams* params = new RP2040DriverParams();
101+
if( !pwm_frequency || !_isset(pwm_frequency) ) pwm_frequency = _PWM_FREQUENCY;
102+
else pwm_frequency = _constrain(pwm_frequency, _PWM_FREQUENCY_MIN, _PWM_FREQUENCY_MAX);
103+
params->pwm_frequency = pwm_frequency;
104+
setupPWM(pinA, pwm_frequency, !SIMPLEFOC_PWM_ACTIVE_HIGH, params, 0);
105+
syncSlices();
106+
return params;
107+
}
108+
109+
110+
98111
void* _configure2PWM(long pwm_frequency, const int pinA, const int pinB) {
99112
RP2040DriverParams* params = new RP2040DriverParams();
100113
if( !pwm_frequency || !_isset(pwm_frequency) ) pwm_frequency = _PWM_FREQUENCY;
@@ -165,6 +178,12 @@ void writeDutyCycle(float val, uint slice, uint chan) {
165178

166179

167180

181+
void _writeDutyCycle1PWM(float dc_a, void* params) {
182+
writeDutyCycle(dc_a, ((RP2040DriverParams*)params)->slice[0], ((RP2040DriverParams*)params)->chan[0]);
183+
}
184+
185+
186+
168187

169188
void _writeDutyCycle2PWM(float dc_a, float dc_b, void* params) {
170189
writeDutyCycle(dc_a, ((RP2040DriverParams*)params)->slice[0], ((RP2040DriverParams*)params)->chan[0]);

0 commit comments

Comments
 (0)