From 64a4649290cf3a5af3405d997d0130d1f7bacd2c Mon Sep 17 00:00:00 2001 From: Karl Andersson Date: Wed, 16 Jan 2019 01:44:22 +0100 Subject: [PATCH] STM32 - Fix SD write (#12897) --- Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp b/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp index a11b1585f..ff384da81 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp +++ b/Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp @@ -116,10 +116,9 @@ uint8_t spiRec(void) { */ void spiRead(uint8_t* buf, uint16_t nbyte) { if (nbyte == 0) return; + memset(buf, 0xFF, nbyte); SPI.beginTransaction(spiConfig); - for (int i = 0; i < nbyte; i++) { - buf[i] = SPI.transfer(0xFF); - } + SPI.transfer(buf, nbyte); SPI.endTransaction(); } @@ -145,9 +144,10 @@ void spiSend(uint8_t b) { * @details Use DMA */ void spiSendBlock(uint8_t token, const uint8_t* buf) { + uint8_t rxBuf[512]; SPI.beginTransaction(spiConfig); SPI.transfer(token); - SPI.transfer((uint8_t*)buf, (uint8_t*)0, 512); + SPI.transfer((uint8_t*)buf, &rxBuf, 512); SPI.endTransaction(); }