@@ -111,6 +111,7 @@ byte SPIClassRP2040::transfer(uint8_t data) {
111
111
}
112
112
data = (_spis.getBitOrder () == MSBFIRST) ? data : reverseByte (data);
113
113
DEBUGSPI (" SPI::transfer(%02x), cpol=%d, cpha=%d\n " , data, cpol (), cpha ());
114
+ hw_write_masked (&spi_get_hw (_spi)->cr0 , (8 - 1 ) << SPI_SSPCR0_DSS_LSB, SPI_SSPCR0_DSS_BITS); // Fast set to 8-bits
114
115
spi_write_read_blocking (_spi, &data, &ret, 1 );
115
116
ret = (_spis.getBitOrder () == MSBFIRST) ? ret : reverseByte (ret);
116
117
DEBUGSPI (" SPI: read back %02x\n " , ret);
@@ -124,11 +125,8 @@ uint16_t SPIClassRP2040::transfer16(uint16_t data) {
124
125
}
125
126
data = (_spis.getBitOrder () == MSBFIRST) ? data : reverse16Bit (data);
126
127
DEBUGSPI (" SPI::transfer16(%04x), cpol=%d, cpha=%d\n " , data, cpol (), cpha ());
127
- uint8_t d[2 ];
128
- d[0 ] = (data >> 8 ) & 0xff ;
129
- d[1 ] = data & 0xff ;
130
- spi_write_read_blocking (_spi, d, d, 2 );
131
- ret = ((d[0 ] << 8 ) | (d[1 ] & 0xff )) & 0xffff ;
128
+ hw_write_masked (&spi_get_hw (_spi)->cr0 , (16 - 1 ) << SPI_SSPCR0_DSS_LSB, SPI_SSPCR0_DSS_BITS); // Fast set to 16-bits
129
+ spi_write16_read16_blocking (_spi, &data, &ret, 1 );
132
130
ret = (_spis.getBitOrder () == MSBFIRST) ? ret : reverse16Bit (ret);
133
131
DEBUGSPI (" SPI: read back %02x\n " , ret);
134
132
return ret;
@@ -149,6 +147,8 @@ void SPIClassRP2040::transfer(const void *txbuf, void *rxbuf, size_t count) {
149
147
return ;
150
148
}
151
149
150
+ hw_write_masked (&spi_get_hw (_spi)->cr0 , (8 - 1 ) << SPI_SSPCR0_DSS_LSB, SPI_SSPCR0_DSS_BITS); // Fast set to 8-bits
151
+
152
152
DEBUGSPI (" SPI::transfer(%p, %p, %d)\n " , txbuf, rxbuf, count);
153
153
const uint8_t *txbuff = reinterpret_cast <const uint8_t *>(txbuf);
154
154
uint8_t *rxbuff = reinterpret_cast <uint8_t *>(rxbuf);
0 commit comments