浏览代码

STM32 - Fix SD write (#12897)

Karl Andersson 6 年前
父节点
当前提交
64a4649290
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4
    4
      Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp

+ 4
- 4
Marlin/src/HAL/HAL_STM32/HAL_spi_STM32.cpp 查看文件

116
  */
116
  */
117
 void spiRead(uint8_t* buf, uint16_t nbyte) {
117
 void spiRead(uint8_t* buf, uint16_t nbyte) {
118
   if (nbyte == 0) return;
118
   if (nbyte == 0) return;
119
+  memset(buf, 0xFF, nbyte);
119
   SPI.beginTransaction(spiConfig);
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
   SPI.endTransaction();
122
   SPI.endTransaction();
124
 }
123
 }
125
 
124
 
145
  * @details Use DMA
144
  * @details Use DMA
146
  */
145
  */
147
 void spiSendBlock(uint8_t token, const uint8_t* buf) {
146
 void spiSendBlock(uint8_t token, const uint8_t* buf) {
147
+  uint8_t rxBuf[512];
148
   SPI.beginTransaction(spiConfig);
148
   SPI.beginTransaction(spiConfig);
149
   SPI.transfer(token);
149
   SPI.transfer(token);
150
-  SPI.transfer((uint8_t*)buf, (uint8_t*)0, 512);
150
+  SPI.transfer((uint8_t*)buf, &rxBuf, 512);
151
   SPI.endTransaction();
151
   SPI.endTransaction();
152
 }
152
 }
153
 
153
 

正在加载...
取消
保存