diff options
| author | Andrew Leech <andrew.leech@planetinnovation.com.au> | 2024-06-05 12:22:03 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-07-26 11:14:19 +1000 |
| commit | 5e80416e6d6168ec5f1ad43191d4ddac1332c641 (patch) | |
| tree | 9a716d4aef829978f83291495e9931bb7e966633 | |
| parent | 62e0fa04a7a6f9044db1bb0f20ea7a2e00599921 (diff) | |
nrf/modules/machine/soft_pwm: Ensure duty_width is always valid.
Signed-off-by: Andrew Leech <andrew@alelec.net>
| -rw-r--r-- | ports/nrf/modules/machine/soft_pwm.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ports/nrf/modules/machine/soft_pwm.c b/ports/nrf/modules/machine/soft_pwm.c index 2fa336265..1891a6d6e 100644 --- a/ports/nrf/modules/machine/soft_pwm.c +++ b/ports/nrf/modules/machine/soft_pwm.c @@ -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); } |
