Parcourir la source

STM32 - Fix SD write (#12897)

Karl Andersson il y a 6 ans
Parent
révision
64a4649290
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4
    4
      Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp

+ 4
- 4
Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp Voir le fichier

@@ -116,10 +116,9 @@ uint8_t spiRec(void) {
116 116
  */
117 117
 void spiRead(uint8_t* buf, uint16_t nbyte) {
118 118
   if (nbyte == 0) return;
119
+  memset(buf, 0xFF, nbyte);
119 120
   SPI.beginTransaction(spiConfig);
120
-  for (int i = 0; i < nbyte; i++) {
121
-    buf[i] = SPI.transfer(0xFF);
122
-  }
121
+  SPI.transfer(buf, nbyte);
123 122
   SPI.endTransaction();
124 123
 }
125 124
 
@@ -145,9 +144,10 @@ void spiSend(uint8_t b) {
145 144
  * @details Use DMA
146 145
  */
147 146
 void spiSendBlock(uint8_t token, const uint8_t* buf) {
147
+  uint8_t rxBuf[512];
148 148
   SPI.beginTransaction(spiConfig);
149 149
   SPI.transfer(token);
150
-  SPI.transfer((uint8_t*)buf, (uint8_t*)0, 512);
150
+  SPI.transfer((uint8_t*)buf, &rxBuf, 512);
151 151
   SPI.endTransaction();
152 152
 }
153 153
 

Chargement…
Annuler
Enregistrer