Skip to content

Commit

Permalink
nrf/soft_pwm: Ensure duty_width can't be used uninitialised.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Jun 5, 2024
1 parent cca1e08 commit d126e2a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ports/nrf/modules/machine/soft_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ static void machine_soft_pwm_start(machine_pwm_obj_t *self) {
duty_width = self->duty * DUTY_FULL_SCALE / 65536;
} else if (self->duty_mode == DUTY_NS) {
duty_width = (uint64_t)self->duty * self->freq * DUTY_FULL_SCALE / 1000000000ULL;
} else {
mp_raise_ValueError(MP_ERROR_TEXT("invalid duty mode"));
}
pwm_set_duty_cycle(self->pwm_pin, duty_width);
}
Expand Down

0 comments on commit d126e2a

Please sign in to comment.