mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
stm32: h7 spi - add a delay on SCK polarity change
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
parent
28a4baf95c
commit
07b3726d31
@ -9,6 +9,7 @@
|
||||
#include "gpio.h" // spi_setup
|
||||
#include "internal.h" // gpio_peripheral
|
||||
#include "sched.h" // sched_shutdown
|
||||
#include "board/misc.h" // timer_is_before
|
||||
|
||||
struct spi_info {
|
||||
SPI_TypeDef *spi;
|
||||
@ -113,8 +114,14 @@ spi_prepare(struct spi_config config)
|
||||
// Load frequency
|
||||
spi->CFG1 = (div << SPI_CFG1_MBR_Pos) | (7 << SPI_CFG1_DSIZE_Pos);
|
||||
// Load mode
|
||||
spi->CFG2 = ((mode << SPI_CFG2_CPHA_Pos) | SPI_CFG2_MASTER | SPI_CFG2_SSM
|
||||
| SPI_CFG2_AFCNTR | SPI_CFG2_SSOE);
|
||||
uint32_t cfg2 = ((mode << SPI_CFG2_CPHA_Pos) | SPI_CFG2_MASTER
|
||||
| SPI_CFG2_SSM | SPI_CFG2_AFCNTR | SPI_CFG2_SSOE);
|
||||
uint32_t diff = spi->CFG2 ^ cfg2;
|
||||
spi->CFG2 = cfg2;
|
||||
uint32_t end = timer_read_time() + timer_from_us(1);
|
||||
if (diff & SPI_CFG2_CPOL_Msk)
|
||||
while (timer_is_before(timer_read_time(), end))
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user