Skip to content

Commit cc64642

Browse files
committed
machine/rp2040: add PWM implementation
add documentation rp2040 pwm fixes and functionality added machine/rp2040: add PWM implementation
1 parent 0565b7c commit cc64642

File tree

3 files changed

+398
-0
lines changed

3 files changed

+398
-0
lines changed

src/examples/pwm/pico.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// +build pico
2+
3+
package main
4+
5+
import "machine"
6+
7+
var (
8+
pwm = machine.PWM4 // Pin 25 (LED on pico) corresponds to PWM4.
9+
pinA = machine.LED
10+
pinB = machine.GPIO24
11+
)

src/machine/machine_rp2040_gpio.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const (
6868
PinInputPullup
6969
PinAnalog
7070
PinUART
71+
PinPWM
7172
)
7273

7374
// set drives the pin high
@@ -155,6 +156,8 @@ func (p Pin) Configure(config PinConfig) {
155156
p.pulloff()
156157
case PinUART:
157158
p.setFunc(fnUART)
159+
case PinPWM:
160+
p.setFunc(fnPWM)
158161
}
159162
}
160163

0 commit comments

Comments
 (0)