diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2018-07-08 00:22:53 +0200 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2018-07-08 09:25:11 -0400 |
commit | 2991c7a831b4439a1bed8b1d4dca585d786a3c30 (patch) | |
tree | b0aaff74a5a9c8326d412ee22d897e1daaacfd22 /src/stm32f1/gpio.c | |
parent | ebd9035325fc3f4ca8e40b06804f3834bbea5a28 (diff) | |
download | kutter-2991c7a831b4439a1bed8b1d4dca585d786a3c30.tar.gz kutter-2991c7a831b4439a1bed8b1d4dca585d786a3c30.tar.xz kutter-2991c7a831b4439a1bed8b1d4dca585d786a3c30.zip |
stm32f1: implement spi_prepare
Implement spi_prepare to fix the undefined behavior on SPI transaction
start.
Tested with the following command sequence:
allocate_oids count=2
config_spi oid=0 bus=0 pin=PA8 mode=3 rate=1000000 shutdown_msg=
config_spi oid=1 bus=0 pin=PA8 mode=1 rate=1000000 shutdown_msg=
spi_send oid=0 data=30313233343536373839
spi_transfer oid=1 data=3031
Discussion about this here:
https://github.com/KevinOConnor/klipper/pull/453#issuecomment-403131149
Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
Diffstat (limited to 'src/stm32f1/gpio.c')
-rw-r--r-- | src/stm32f1/gpio.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/stm32f1/gpio.c b/src/stm32f1/gpio.c index 832febd8..84f7fbe7 100644 --- a/src/stm32f1/gpio.c +++ b/src/stm32f1/gpio.c @@ -303,15 +303,14 @@ spi_setup(uint32_t bus, uint8_t mode, uint32_t rate) void spi_prepare(struct spi_config config) { + *SPI2 = config.config; + LL_SPI_Enable(SPI2); } void spi_transfer(struct spi_config config, uint8_t receive_data, uint8_t len, uint8_t *data) { - *SPI2 = config.config; - LL_SPI_Enable(SPI2); - while (len--) { LL_SPI_TransmitData8(SPI2, *data); while (!LL_SPI_IsActiveFlag_TXE(SPI2)); |