mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
machine/rp2040: correct issue with spi pin validation
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -181,22 +181,24 @@ func (spi SPI) Configure(config SPIConfig) error {
|
||||
var okSDI, okSDO, okSCK bool
|
||||
switch spi.Bus {
|
||||
case rp.SPI0:
|
||||
okSDI = config.SDI == 0 || config.SDI == 4 || config.SDI == 17
|
||||
okSDI = config.SDI == 0 || config.SDI == 4 || config.SDI == 16
|
||||
okSDO = config.SDO == 3 || config.SDO == 7 || config.SDO == 19
|
||||
okSCK = config.SCK == 2 || config.SCK == 6 || config.SCK == 18
|
||||
case rp.SPI1:
|
||||
okSDI = config.SDI == 8 || config.SDI == 12
|
||||
okSDO = config.SDO == 11 || config.SDO == 15
|
||||
okSDO = config.SCK == 10 || config.SCK == 14
|
||||
okSDI = config.SDI == 8 || config.SDI == 12 || config.SDI == 28
|
||||
okSDO = config.SDO == 11 || config.SDO == 15 || config.SDO == 27
|
||||
okSCK = config.SCK == 10 || config.SCK == 14 || config.SCK == 26
|
||||
}
|
||||
|
||||
if !okSDI {
|
||||
switch {
|
||||
case !okSDI:
|
||||
return errSPIInvalidSDI
|
||||
} else if !okSDO {
|
||||
case !okSDO:
|
||||
return errSPIInvalidSDO
|
||||
} else if !okSCK {
|
||||
case !okSCK:
|
||||
return errSPIInvalidSCK
|
||||
}
|
||||
|
||||
if config.DataBits < 4 || config.DataBits > 16 {
|
||||
config.DataBits = 8
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user