diff options
author | Lasse Dalegaard <dalegaard@gmail.com> | 2021-07-04 21:30:24 +0200 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2021-07-09 11:23:48 -0400 |
commit | 28f60f7ef69847f1514371d1c6788c3c0df98533 (patch) | |
tree | 351973d29a672f33ec1cb8e57e519f90b56af1b9 /src/rp2040/gpio.h | |
parent | 4802c6d86a4510172d630ffdce02434369138037 (diff) | |
download | kutter-28f60f7ef69847f1514371d1c6788c3c0df98533.tar.gz kutter-28f60f7ef69847f1514371d1c6788c3c0df98533.tar.xz kutter-28f60f7ef69847f1514371d1c6788c3c0df98533.zip |
rp2040: hardware PWM support
This implements hardware PWM support for the rp2040. The maximum
value(100% duty) is set to 255 to match the other controllers. Cycle
time is clamped automatically, and uses the full 8.4 fractional range of
the rp2040 PWM block. This allows a maximum PWM frequency of 490kHz and
a minimum frequency of 1915 Hz.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Diffstat (limited to 'src/rp2040/gpio.h')
-rw-r--r-- | src/rp2040/gpio.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rp2040/gpio.h b/src/rp2040/gpio.h index 50b6302c..5f6a836a 100644 --- a/src/rp2040/gpio.h +++ b/src/rp2040/gpio.h @@ -19,6 +19,14 @@ struct gpio_in gpio_in_setup(uint8_t pin, int8_t pull_up); void gpio_in_reset(struct gpio_in g, int8_t pull_up); uint8_t gpio_in_read(struct gpio_in g); +struct gpio_pwm { + void *reg; + uint8_t shift; + uint32_t mask; +}; +struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val); +void gpio_pwm_write(struct gpio_pwm g, uint32_t val); + struct gpio_adc { uint8_t chan; }; |