esp32-s2: Don't set PWMOut frequency to 0
FeatherS2 crashes if you set the PWMOut frequency to 0. This change will raise `ValueError: Invalid PWM frequency` if the requested frequency is 0. (Lifted from the atmel-samd port)
This commit is contained in:
parent
e6dc3e4686
commit
2db113f191
@ -129,6 +129,12 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
|
|||||||
return PWMOUT_INITIALIZATION_ERROR;
|
return PWMOUT_INITIALIZATION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check the frequency -- 0 is not valid
|
||||||
|
// maybe also want to reject frequency > system_clock / 2 ??
|
||||||
|
if (frequency == 0) {
|
||||||
|
return PWMOUT_INVALID_FREQUENCY;
|
||||||
|
}
|
||||||
|
|
||||||
// Make reservations
|
// Make reservations
|
||||||
reserved_timer_freq[timer_index] = frequency;
|
reserved_timer_freq[timer_index] = frequency;
|
||||||
reserved_channels[channel_index] = timer_index;
|
reserved_channels[channel_index] = timer_index;
|
||||||
|
Loading…
Reference in New Issue
Block a user