Skip to content

Commit

Permalink
rp2040: Only change SPI settings while peripheral is disabled
Browse files Browse the repository at this point in the history
Make sure to disable/enable the peripheral to ensure the clock
polarity is properly set prior to a change in CS.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Jan 25, 2024
1 parent f1982ed commit 5e433ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rp2040/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ void
spi_prepare(struct spi_config config)
{
spi_hw_t *spi = config.spi;
if (spi->cr0 == config.cr0 && spi->cpsr == config.cpsr)
return;
spi->cr1 = 0;
spi->cr0 = config.cr0;
spi->cpsr = config.cpsr;
spi->cr1 = SPI_SSPCR1_SSE_BITS;
}

void
Expand Down

0 comments on commit 5e433ff

Please sign in to comment.