Pārlūkot izejas kodu

Merge pull request #463 from ZuluSCSI/dev_watchdog_during_write

Reset watchdog while data transfer is progressing
Alex Perez 1 gadu atpakaļ
vecāks
revīzija
7925831c4c
2 mainītis faili ar 18 papildinājumiem un 0 dzēšanām
  1. 6 0
      src/ZuluSCSI_cdrom.cpp
  2. 12 0
      src/ZuluSCSI_disk.cpp

+ 6 - 0
src/ZuluSCSI_cdrom.cpp

@@ -1721,6 +1721,12 @@ static void doReadCD(uint32_t lba, uint32_t length, uint8_t sector_type,
         }
         assert(buf == bufstart + result_length);
         scsiStartWrite(bufstart, result_length);
+
+        // Reset the watchdog while the transfer is progressing.
+        // If the host stops transferring, the watchdog will eventually expire.
+        // This is needed to avoid hitting the watchdog if the host performs
+        // a large transfer compared to its transfer speed.
+        platform_reset_watchdog();
     }
 
     scsiFinishWrite();

+ 12 - 0
src/ZuluSCSI_disk.cpp

@@ -1671,6 +1671,12 @@ void diskDataOut()
             }
             platform_set_sd_callback(NULL, NULL);
             g_disk_transfer.bytes_sd += len;
+
+            // Reset the watchdog while the transfer is progressing.
+            // If the host stops transferring, the watchdog will eventually expire.
+            // This is needed to avoid hitting the watchdog if the host performs
+            // a large transfer compared to its transfer speed.
+            platform_reset_watchdog();
         }
     }
 
@@ -1844,6 +1850,12 @@ static void start_dataInTransfer(uint8_t *buffer, uint32_t count)
 
     platform_poll();
     diskEjectButtonUpdate(false);
+
+    // Reset the watchdog while the transfer is progressing.
+    // If the host stops transferring, the watchdog will eventually expire.
+    // This is needed to avoid hitting the watchdog if the host performs
+    // a large transfer compared to its transfer speed.
+    platform_reset_watchdog();
 }
 
 static void diskDataIn()