Skip to content

Commit 8dae22b

Browse files
authored
Merge pull request #9024 from dhalbert/rp2040-pwmout-claim-fix
raspberrypi/common-hal/pwmio/PWMOut.c: don't claim pin before error checking
2 parents 8d5922f + ca8c9ca commit 8dae22b

File tree

1 file changed

+5
-6
lines changed
  • ports/raspberrypi/common-hal/pwmio

1 file changed

+5
-6
lines changed

ports/raspberrypi/common-hal/pwmio/PWMOut.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
123123
uint16_t duty,
124124
uint32_t frequency,
125125
bool variable_frequency) {
126-
self->pin = pin;
127-
self->variable_frequency = variable_frequency;
128-
self->duty_cycle = duty;
129-
130-
claim_pin(pin);
131-
132126
if (frequency == 0 || frequency > (common_hal_mcu_processor_get_frequency() / 2)) {
133127
return PWMOUT_INVALID_FREQUENCY;
134128
}
@@ -141,6 +135,11 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
141135
return r;
142136
}
143137

138+
claim_pin(pin);
139+
140+
self->pin = pin;
141+
self->variable_frequency = variable_frequency;
142+
self->duty_cycle = duty;
144143
self->slice = slice;
145144
self->ab_channel = ab_channel;
146145

0 commit comments

Comments
 (0)