Skip to content

Commit 99e27ad

Browse files
author
Matthew West
committed
Add a safeguard if we didn't start
1 parent f4fcd12 commit 99e27ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/c_pwm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@ BBIO_err pwm_start(const char *key, float duty, float freq, int polarity)
495495
pwm = lookup_exported_pwm(key);
496496
}
497497

498+
// If we somehow didn't start successfully
499+
if (pwm == NULL) {
500+
return BBIO_GEN;
501+
}
502+
498503
err = pwm_set_polarity(key, polarity);
499504
if (err != BBIO_OK) {
500505
return err;

0 commit comments

Comments
 (0)