Skip to content

machine/rp2040: add PWM implementation #2015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/examples/pwm/pico.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build pico

package main

import "machine"

var (
pwm = machine.PWM4 // Pin 25 (LED on pico) corresponds to PWM4.
pinA = machine.LED
pinB = machine.GPIO24
)
3 changes: 3 additions & 0 deletions src/machine/machine_rp2040_gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
PinInputPullup
PinAnalog
PinUART
PinPWM
PinI2C
PinSPI
)
Expand Down Expand Up @@ -181,6 +182,8 @@ func (p Pin) Configure(config PinConfig) {
p.pulloff()
case PinUART:
p.setFunc(fnUART)
case PinPWM:
p.setFunc(fnPWM)
case PinI2C:
// IO config according to 4.3.1.3 of rp2040 datasheet.
p.setFunc(fnI2C)
Expand Down
Loading