Skip to content

Commit 5e80416

Browse files
pi-anldpgeorge
authored andcommitted
nrf/modules/machine/soft_pwm: Ensure duty_width is always valid.
Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent 62e0fa0 commit 5e80416

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ports/nrf/modules/machine/soft_pwm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ static void machine_soft_pwm_start(machine_pwm_obj_t *self) {
199199
duty_width = self->duty * DUTY_FULL_SCALE / 65536;
200200
} else if (self->duty_mode == DUTY_NS) {
201201
duty_width = (uint64_t)self->duty * self->freq * DUTY_FULL_SCALE / 1000000000ULL;
202+
} else {
203+
mp_raise_ValueError(MP_ERROR_TEXT("invalid duty mode"));
202204
}
203205
pwm_set_duty_cycle(self->pwm_pin, duty_width);
204206
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy