Skip to content

Commit 8bb1d77

Browse files
committed
add claim to piolib drivers
1 parent e8ff5a2 commit 8bb1d77

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

rp2-pio/piolib/parallel8.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Parallel8Tx struct {
2020
const noDMA uint32 = 0xffff_ffff
2121

2222
func NewParallel8Tx(sm pio.StateMachine, wr, dStart machine.Pin, baud uint32) (*Parallel8Tx, error) {
23+
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
2324
const nPins = 8
2425
if dStart+nPins > 31 {
2526
return nil, errors.New("invalid D0..D7 pin range")

rp2-pio/piolib/pulsar.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Pulsar struct {
2020

2121
// NewPulsar returns a new Pulsar ready for use.
2222
func NewPulsar(sm pio.StateMachine, pin machine.Pin) (*Pulsar, error) {
23+
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
2324
Pio := sm.PIO()
2425

2526
offset, err := Pio.AddProgram(pulsarInstructions, pulsarOrigin)

rp2-pio/piolib/spi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type SPI struct {
1616
}
1717

1818
func NewSPI(sm pio.StateMachine, spicfg machine.SPIConfig) (*SPI, error) {
19+
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
1920
const nbits = 8
2021
// https://github.com/raspberrypi/pico-examples/blob/eca13acf57916a0bd5961028314006983894fc84/pio/spi/spi.pio#L46
2122
if !sm.IsValid() {

rp2-pio/piolib/ws2812.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type WS2812 struct {
1515
}
1616

1717
func NewWS2812(sm pio.StateMachine, pin machine.Pin, baud uint32) (*WS2812, error) {
18+
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
1819
whole, frac, err := pio.ClkDivFromFrequency(baud, machine.CPUFrequency())
1920
if err != nil {
2021
return nil, err

0 commit comments

Comments
 (0)