8000 nrf/modules/machine/pwm: Tag a PWM device as used in the constructor. · RetiredWizard/micropython@4dd288f · GitHub
[go: up one dir, main page]

Skip to content

Commit 4dd288f

Browse files
robert-hhdpgeorge
authored andcommitted
nrf/modules/machine/pwm: Tag a PWM device as used in the constructor.
When PWM constructor was created without specifying a device or setting both freq and duty rate, it was not tagged as used, and further calls to get a PWM object may get the same PWM device assigned. Fixes micropython#13494. Signed-off-by: robert-hh <robert@hammelrath.com>
1 parent 5e926b2 commit 4dd288f

File tree

1 file changed

+5
-0
lines changed
  • ports/nrf/modules/machine

1 file changed

+5
-0
lines changed

ports/nrf/modules/machine/pwm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ static mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args
233233
self->p_config->mode[pwm_channel] = MODE_HIGH_LOW;
234234
self->p_config->defer_start = false;
235235

236+
// Allocate the device if it was not used before.
237+
if (hard_configs[pwm_id].active == FREE) {
238+
hard_configs[pwm_id].active = STOPPED;
239+
}
240+
236241
// start the PWM running for this channel
237242
mp_map_t kw_args;
238243
mp_map_init_fixed_table(&kw_args, n_kw, all_args + n_args);

0 commit comments

Comments
 (0)
0