give some time to CF to set outputs after reset
Stefan Schuermans

Stefan Schuermans commited on 2012-05-06 18:02:28
Showing 1 changed files, with 12 additions and 0 deletions.

... ...
@@ -61,6 +61,9 @@
61 61
 // time to give CF to power up (in 20ms steps)
62 62
 #define CF_POWERUP_TIME (5) // 100ms
63 63
 
64
+// time to give CF to set outputs after reset (in 20ms steps)
65
+#define CF_POST_RESET_TIME (2) // 40ms
66
+
64 67
 // timeout value for wait for ready after reset counter (in 20ms steps)
65 68
 #define CF_RESET_READY_TIMEOUT (50)    // 1s
66 69
 
... ...
@@ -407,6 +410,15 @@ char CfReset(void) // (extern)
407 410
   CF_RESET_IDLE();
408 411
   debug_cf_printf("CF reset");
409 412
 
413
+  // wait a little bit
414
+  if (!CF_IS_DETECT()) {
415
+    CfGone();
416
+    return -1;
417
+  }
418
+  CfTickCnt = CF_POST_RESET_TIME;
419
+  while (CfTickCnt > 0)
420
+    Tasks();
421
+
410 422
   // wait for CF to become ready
411 423
   if (CfWaitReady(CF_RESET_READY_TIMEOUT) != 0)
412 424
     return -1;
413 425