aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authordeadprogram <[email protected]>2024-12-18 11:21:51 +0100
committerdeadprogram <[email protected]>2024-12-18 19:41:31 +0100
commit443aaa7991a611946e91c601598971158f070f12 (patch)
treebdf98319874fa965ba286e53da26ad7926180075 /src
parent37f35f8c910b05e2040433448546f41b34535b32 (diff)
downloadtinygo-443aaa7991a611946e91c601598971158f070f12.tar.gz
tinygo-443aaa7991a611946e91c601598971158f070f12.zip
feature: make SPI implementation shared for rp2040/rp2350rp2350-spi
Signed-off-by: deadprogram <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/machine/machine_rp2_spi.go (renamed from src/machine/machine_rp2040_spi.go)9
-rw-r--r--src/machine/spi.go2
2 files changed, 5 insertions, 6 deletions
diff --git a/src/machine/machine_rp2040_spi.go b/src/machine/machine_rp2_spi.go
index dbb063cb3..faab9839a 100644
--- a/src/machine/machine_rp2040_spi.go
+++ b/src/machine/machine_rp2_spi.go
@@ -1,4 +1,4 @@
-//go:build rp2040
+//go:build rp2040 || rp2350
package machine
@@ -207,7 +207,7 @@ func (spi SPI) initSPI(config SPIConfig) (err error) {
}
err = spi.SetBaudRate(config.Frequency)
// Set SPI Format (CPHA and CPOL) and frame format (default is Motorola)
- spi.setFormat(config.Mode, rp.XIP_SSI_CTRLR0_SPI_FRF_STD)
+ spi.setFormat(config.Mode)
// Always enable DREQ signals -- harmless if DMA is not listening
spi.Bus.SSPDMACR.SetBits(rp.SPI0_SSPDMACR_TXDMAE | rp.SPI0_SSPDMACR_RXDMAE)
@@ -217,14 +217,13 @@ func (spi SPI) initSPI(config SPIConfig) (err error) {
}
//go:inline
-func (spi SPI) setFormat(mode uint8, frameFormat uint32) {
+func (spi SPI) setFormat(mode uint8) {
cpha := uint32(mode) & 1
cpol := uint32(mode>>1) & 1
spi.Bus.SSPCR0.ReplaceBits(
(cpha<<rp.SPI0_SSPCR0_SPH_Pos)|
(cpol<<rp.SPI0_SSPCR0_SPO_Pos)|
- (uint32(7)<<rp.SPI0_SSPCR0_DSS_Pos)| // Set databits (SPI word length) to 8 bits.
- (frameFormat&0b11)<<rp.SPI0_SSPCR0_FRF_Pos, // Frame format bits 4:5
+ (uint32(7)<<rp.SPI0_SSPCR0_DSS_Pos), // Set databits (SPI word length) to 8 bits.
rp.SPI0_SSPCR0_SPH_Msk|rp.SPI0_SSPCR0_SPO_Msk|rp.SPI0_SSPCR0_DSS_Msk|rp.SPI0_SSPCR0_FRF_Msk, 0)
}
diff --git a/src/machine/spi.go b/src/machine/spi.go
index a6fd866d1..9a1033ca7 100644
--- a/src/machine/spi.go
+++ b/src/machine/spi.go
@@ -1,4 +1,4 @@
-//go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
+//go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || rp2350 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
package machine