Skip to content

Commit f64e70e

Browse files
committed
feature: make SPI implementation shared for rp2040/rp2350
Signed-off-by: deadprogram <[email protected]>
1 parent 64fa785 commit f64e70e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/machine/machine_rp2040_spi.go renamed to src/machine/machine_rp2_spi.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build rp2040
1+
//go:build rp2040 || rp2350
22

33
package machine
44

@@ -207,7 +207,7 @@ func (spi SPI) initSPI(config SPIConfig) (err error) {
207207
}
208208
err = spi.SetBaudRate(config.Frequency)
209209
// Set SPI Format (CPHA and CPOL) and frame format (default is Motorola)
210-
spi.setFormat(config.Mode, rp.XIP_SSI_CTRLR0_SPI_FRF_STD)
210+
spi.setFormat(config.Mode)
211211

212212
// Always enable DREQ signals -- harmless if DMA is not listening
213213
spi.Bus.SSPDMACR.SetBits(rp.SPI0_SSPDMACR_TXDMAE | rp.SPI0_SSPDMACR_RXDMAE)
@@ -217,14 +217,13 @@ func (spi SPI) initSPI(config SPIConfig) (err error) {
217217
}
218218

219219
//go:inline
220-
func (spi SPI) setFormat(mode uint8, frameFormat uint32) {
220+
func (spi SPI) setFormat(mode uint8) {
221221
cpha := uint32(mode) & 1
222222
cpol := uint32(mode>>1) & 1
223223
spi.Bus.SSPCR0.ReplaceBits(
224224
(cpha<<rp.SPI0_SSPCR0_SPH_Pos)|
225225
(cpol<<rp.SPI0_SSPCR0_SPO_Pos)|
226-
(uint32(7)<<rp.SPI0_SSPCR0_DSS_Pos)| // Set databits (SPI word length) to 8 bits.
227-
(frameFormat&0b11)<<rp.SPI0_SSPCR0_FRF_Pos, // Frame format bits 4:5
226+
(uint32(7)<<rp.SPI0_SSPCR0_DSS_Pos), // Set databits (SPI word length) to 8 bits.
228227
rp.SPI0_SSPCR0_SPH_Msk|rp.SPI0_SSPCR0_SPO_Msk|rp.SPI0_SSPCR0_DSS_Msk|rp.SPI0_SSPCR0_FRF_Msk, 0)
229228
}
230229

src/machine/spi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
1+
//go:build !baremetal || atmega || esp32 || fe310 || k210 || nrf || (nxp && !mk66f18) || rp2040 || rp2350 || sam || (stm32 && !stm32f7x2 && !stm32l5x2)
22

33
package machine
44

0 commit comments

Comments
 (0)