mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
stm32: Fix prescaler overflow check in hard_pwm.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
acd96047de
commit
7a9b06ad86
@ -291,10 +291,10 @@ gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val){
|
||||
if (pclock_div > 1)
|
||||
pclock_div /= 2; // Timers run at twice the normal pclock frequency
|
||||
uint32_t prescaler = cycle_time / (pclock_div * (MAX_PWM - 1));
|
||||
if (prescaler > 0) {
|
||||
prescaler -= 1;
|
||||
} else if (prescaler > UINT16_MAX) {
|
||||
if (prescaler > UINT16_MAX) {
|
||||
prescaler = UINT16_MAX;
|
||||
} else if (prescaler > 0) {
|
||||
prescaler -= 1;
|
||||
}
|
||||
|
||||
gpio_peripheral(p->pin, p->function, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user