8000 nrf/soft_pwm: Ensure duty_width can't be used uninitialised. · micropython/micropython@139fcd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 139fcd1

Browse files
committed
nrf/soft_pwm: Ensure duty_width can't be used uninitialised.
Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent af41d52 commit 139fcd1

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)
0