Browse Source

SDIO cleanup

Scott Lahteine 4 years ago
parent
commit
c6c6c56186
1 changed files with 6 additions and 7 deletions
  1. 6
    7
      Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp

+ 6
- 7
Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp View File

@@ -85,8 +85,8 @@
85 85
   #define SDIO_CMD_PIN  PD2
86 86
 
87 87
   SD_HandleTypeDef hsd;  // create SDIO structure
88
-  // F4 support one dma for RX and another for TX.
89
-  // But Marlin will never do read and write at same time, so we use always one dma for both.
88
+  // F4 supports one DMA for RX and another for TX, but Marlin will never
89
+  // do read and write at same time, so we use the same DMA for both.
90 90
   DMA_HandleTypeDef hdma_sdio;
91 91
 
92 92
   /*
@@ -274,7 +274,7 @@
274 274
   }
275 275
 
276 276
   static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) {
277
-    if(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false;
277
+    if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false;
278 278
 
279 279
     TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
280 280
 
@@ -296,10 +296,10 @@
296 296
       return false;
297 297
     }
298 298
 
299
-    uint32_t timeout = millis() + 500;
299
+    millis_t timeout = millis() + 500;
300 300
     // Wait the transfer
301 301
     while (hsd.State != HAL_SD_STATE_READY) {
302
-      if (millis() > timeout) {
302
+      if (ELAPSED(millis(), timeout)) {
303 303
         HAL_DMA_Abort_IT(&hdma_sdio);
304 304
         HAL_DMA_DeInit(&hdma_sdio);
305 305
         return false;
@@ -313,8 +313,7 @@
313 313
     HAL_DMA_DeInit(&hdma_sdio);
314 314
 
315 315
     timeout = millis() + 500;
316
-    while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER)
317
-      if (millis() > timeout) return false;
316
+    while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false;
318 317
 
319 318
     return true;
320 319
   }

Loading…
Cancel
Save