8000 have clock start high in SPI mode 3 · kdb424/circuitpython@1611cf9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1611cf9

Browse files
committed
have clock start high in SPI mode 3
1 parent 6689b9a commit 1611cf9

File tree

1 file changed

+9
-0
lines changed
  • ports/raspberrypi/common-hal/busio

1 file changed

+9
-0
lines changed

ports/raspberrypi/common-hal/busio/SPI.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
151151

152152
spi_set_format(self->peripheral, bits, polarity, phase, SPI_MSB_FIRST);
153153

154+
// Workaround to start with clock line high if polarity=1. The hw SPI peripheral does not do this
155+
// automatically. See https://github.com/raspberrypi/pico-sdk/issues/868 and
156+
// https://forums.raspberrypi.com/viewtopic.php?t=336142
157+
// TODO: scheduled to be be fixed in pico-sdk 1.5.0.
158+
if (polarity) {
159+
hw_clear_bits(&spi_get_hw(self->peripheral)->cr1, SPI_SSPCR1_SSE_BITS); // disable the SPI
160+
hw_set_bits(&spi_get_hw(self->peripheral)->cr1, SPI_SSPCR1_SSE_BITS); // re-enable the SPI
161+
}
162+
154163
self->polarity = polarity;
155164
self->phase = phase;
156165
self->bits = bits;

0 commit comments

Comments
 (0)
0