mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
rp2040: add a delay on SCK polarity change
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
parent
b1011e3fb1
commit
14685bf77f
@ -10,6 +10,7 @@
|
||||
#include "internal.h" // pclock, gpio_peripheral
|
||||
#include "hardware/structs/spi.h" // spi_hw_t
|
||||
#include "hardware/regs/resets.h" // RESETS_RESET_SPI*_BITS
|
||||
#include "board/misc.h" // timer_is_before
|
||||
|
||||
|
||||
DECL_ENUMERATION("spi_bus", "spi0_gpio0_gpio3_gpio2", 0);
|
||||
@ -115,10 +116,16 @@ spi_prepare(struct spi_config config)
|
||||
spi_hw_t *spi = config.spi;
|
||||
if (spi->cr0 == config.cr0 && spi->cpsr == config.cpsr)
|
||||
return;
|
||||
uint32_t diff = spi->cr0 ^ config.cr0;
|
||||
spi->cr1 = 0;
|
||||
spi->cr0 = config.cr0;
|
||||
spi->cpsr = config.cpsr;
|
||||
spi->cr1 = SPI_SSPCR1_SSE_BITS;
|
||||
// Give time for state to update before caller changes CS pin
|
||||
uint32_t end = timer_read_time() + timer_from_us(1);
|
||||
if (diff & SPI_SSPCR0_SPO_BITS)
|
||||
while (timer_is_before(timer_read_time(), end))
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user