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
   #define SDIO_CMD_PIN  PD2
85
   #define SDIO_CMD_PIN  PD2
86
 
86
 
87
   SD_HandleTypeDef hsd;  // create SDIO structure
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
   DMA_HandleTypeDef hdma_sdio;
90
   DMA_HandleTypeDef hdma_sdio;
91
 
91
 
92
   /*
92
   /*
274
   }
274
   }
275
 
275
 
276
   static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) {
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
     TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
279
     TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
280
 
280
 
296
       return false;
296
       return false;
297
     }
297
     }
298
 
298
 
299
-    uint32_t timeout = millis() + 500;
299
+    millis_t timeout = millis() + 500;
300
     // Wait the transfer
300
     // Wait the transfer
301
     while (hsd.State != HAL_SD_STATE_READY) {
301
     while (hsd.State != HAL_SD_STATE_READY) {
302
-      if (millis() > timeout) {
302
+      if (ELAPSED(millis(), timeout)) {
303
         HAL_DMA_Abort_IT(&hdma_sdio);
303
         HAL_DMA_Abort_IT(&hdma_sdio);
304
         HAL_DMA_DeInit(&hdma_sdio);
304
         HAL_DMA_DeInit(&hdma_sdio);
305
         return false;
305
         return false;
313
     HAL_DMA_DeInit(&hdma_sdio);
313
     HAL_DMA_DeInit(&hdma_sdio);
314
 
314
 
315
     timeout = millis() + 500;
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
     return true;
318
     return true;
320
   }
319
   }

Loading…
Cancel
Save