Skip to content

Commit 8245dcb

Browse files
committed
nil check for StateMachine.IsValid
1 parent f0394de commit 8245dcb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rp2-pio/statemachine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (sm StateMachine) StateMachineIndex() uint8 { return sm.index }
4848

4949
// IsValid returns true if state machine is a valid instance.
5050
func (sm StateMachine) IsValid() bool {
51-
return (sm.pio.hw == rp.PIO0 || sm.pio.hw == rp.PIO1) && sm.index <= 3
51+
return sm.pio != nil && (sm.pio.hw == rp.PIO0 || sm.pio.hw == rp.PIO1) && sm.index <= 3
5252
}
5353

5454
// Init initializes the state machine

0 commit comments

Comments
 (0)