diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2025-04-07 11:56:52 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2025-04-17 12:07:44 -0400 |
commit | 3656006a3053e8ec4ac548ac52ded62108dc3a25 (patch) | |
tree | 2eed3fdf64f794b2fb7acd237c819ac49c79162c /src | |
parent | 7a9b06ad867259f48ec0393701b8c9963c5a6610 (diff) | |
download | kutter-3656006a3053e8ec4ac548ac52ded62108dc3a25.tar.gz kutter-3656006a3053e8ec4ac548ac52ded62108dc3a25.tar.xz kutter-3656006a3053e8ec4ac548ac52ded62108dc3a25.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/stm32/gpio.h | 2 | ||||
-rw-r--r-- | src/stm32/hard_pwm.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/stm32/gpio.h b/src/stm32/gpio.h index 96105e9b..6a5f910c 100644 --- a/src/stm32/gpio.h +++ b/src/stm32/gpio.h @@ -24,7 +24,7 @@ uint8_t gpio_in_read(struct gpio_in g); struct gpio_pwm { void *reg; }; -struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val); +struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint32_t val); void gpio_pwm_write(struct gpio_pwm g, uint32_t val); struct gpio_adc { 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++) { |