From f46750a29ba723daa3644eeffae6ffc5561d7165 Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Wed, 28 Oct 2026 14:35:40 -0300 Subject: [PATCH 1/2] drivers: add PWMSetter HAL --- pwm.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pwm.go diff --git a/pwm.go b/pwm.go new file mode 100644 index 000000000..a17ebd3c5 --- /dev/null +++ b/pwm.go @@ -0,0 +1,19 @@ +package drivers + +// PWMSetter is a typical PWM controller implementation which allows shared +// setting of frequency and individual setting of duty cycle for several PWM channels. +type PWMSetter interface { + // Top usually represents maximum value the running PWM counter can take, either by hardware or set at configuration. + Top() uint32 + // SetChannels sets the PWM counter limit for channels specified. channels are PWM peripheral based, not MCU host based. + // Users need to check first what PWMSetter and channel combination corresponds to a pin before using the PWMSetter. + // - channels corresponds to values, so len(channels) must be equal to len(values). + // - The PWMSetter can potentially synchronize PWM signal output for a single SetChannels call depending on configuration. + // Example: + // + // quarter := 25*pwm.Top()/100 // 25% duty-cycle. + // full := pwm.Top() // 100% duty cycle (always on) + // off := uint32(0) // PWM low output (always off) + // pwm.SetChannels([]uint8{c1, c2, c3}, []uint32{quarter, full, off}) + SetChannels(channels []uint8, values []uint32) error +} From 08f6b802d018093f20d37a43c1dfe652e64f0d42 Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Wed, 28 Oct 2026 14:39:38 -0300 Subject: [PATCH 2/2] rename PWM --- pwm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwm.go b/pwm.go index a17ebd3c5..1a7e77b1b 100644 --- a/pwm.go +++ b/pwm.go @@ -1,8 +1,8 @@ package drivers -// PWMSetter is a typical PWM controller implementation which allows shared +// PWM is a typical PWM controller implementation which allows shared // setting of frequency and individual setting of duty cycle for several PWM channels. -type PWMSetter interface { +type PWM interface { // Top usually represents maximum value the running PWM counter can take, either by hardware or set at configuration. Top() uint32 // SetChannels sets the PWM counter limit for channels specified. channels are PWM peripheral based, not MCU host based.