Skip to content

Commit e8509dd

Browse files
committed
rename StateMachine.Claim()->TryClaim()
1 parent 06bcd7c commit e8509dd

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

rp2-pio/pio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (pio *PIO) StateMachine(index uint8) StateMachine {
7171
func (pio *PIO) ClaimStateMachine() (sm StateMachine, err error) {
7272
for i := uint8(0); i < 4; i++ {
7373
sm = pio.StateMachine(i)
74-
if sm.Claim() {
74+
if sm.TryClaim() {
7575
return sm, nil
7676
}
7777
}

rp2-pio/piolib/i2s.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type I2S struct {
1515
}
1616

1717
func NewI2S(sm pio.StateMachine, data, clockAndNext machine.Pin) (*I2S, error) {
18-
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
18+
sm.TryClaim() // SM should be claimed beforehand, we just guarantee it's claimed.
1919
Pio := sm.PIO()
2020

2121
offset, err := Pio.AddProgram(i2sInstructions, i2sOrigin)

rp2-pio/piolib/parallel8.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Parallel8Tx struct {
2121
const noDMA uint32 = 0xffff_ffff
2222

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

rp2-pio/piolib/pulsar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +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.
23+
sm.TryClaim() // SM should be claimed beforehand, we just guarantee it's claimed.
2424
Pio := sm.PIO()
2525

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

rp2-pio/piolib/spi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +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.
19+
sm.TryClaim() // SM should be claimed beforehand, we just guarantee it's claimed.
2020
const nbits = 8
2121
// https://github.com/raspberrypi/pico-examples/blob/eca13acf57916a0bd5961028314006983894fc84/pio/spi/spi.pio#L46
2222
if !sm.IsValid() {

rp2-pio/piolib/spi3w.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewSPI3w(sm pio.StateMachine, dio, clk machine.Pin, baud uint32) (*SPI3w, e
3232
}
3333

3434
// https://github.com/embassy-rs/embassy/blob/c4a8b79dbc927e46fcc71879673ad3410aa3174b/cyw43-pio/src/lib.rs#L90
35-
sm.Claim() // SM should be claimed beforehand, we just guarantee it's claimed.
35+
sm.TryClaim() // SM should be claimed beforehand, we just guarantee it's claimed.
3636

3737
Pio := sm.PIO()
3838
offset, err := Pio.AddProgram(spi3wInstructions, spi3wOrigin)

rp2-pio/piolib/ws2812.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +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.
18+
sm.TryClaim() // SM should be claimed beforehand, we just guarantee it's claimed.
1919
whole, frac, err := pio.ClkDivFromFrequency(baud, machine.CPUFrequency())
2020
if err != nil {
2121
return nil, err

rp2-pio/statemachine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (sm StateMachine) Unclaim() { sm.pio.claimedSMMask &^= (1 << sm.index) }
2525

2626
// Claim attempts to claim the state machine for use by the caller and returns
2727
// true if successful, or false if StateMachine already claimed.
28-
func (sm StateMachine) Claim() bool {
28+
func (sm StateMachine) TryClaim() bool {
2929
if sm.IsClaimed() {
3030
return false
3131
}

0 commit comments

Comments
 (0)