From 3656006a3053e8ec4ac548ac52ded62108dc3a25 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 7 Apr 2025 11:56:52 -0400 Subject: stm32: Change hard_pwm.c MAX_PWM to 257 Choose a value for MAX_PWM that avoids an expensive run-time division. Signed-off-by: Kevin O'Connor --- src/stm32/hard_pwm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/stm32/hard_pwm.c') diff --git a/src/stm32/hard_pwm.c b/src/stm32/hard_pwm.c index 09a29ed5..d9be268e 100644 --- a/src/stm32/hard_pwm.c +++ b/src/stm32/hard_pwm.c @@ -11,7 +11,7 @@ #include "internal.h" // GPIO #include "sched.h" // sched_shutdown -#define MAX_PWM 255 +#define MAX_PWM (256 + 1) DECL_CONSTANT("PWM_MAX", MAX_PWM); struct gpio_pwm_info { @@ -275,7 +275,8 @@ static const struct gpio_pwm_info pwm_regs[] = { }; struct gpio_pwm -gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val){ +gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint32_t val) +{ // Find pin in pwm_regs table const struct gpio_pwm_info* p = pwm_regs; for (;; p++) { -- cgit v1.2.3-70-g09d2