File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,10 @@ bool SDClass::begin(uint8_t csPin) {
9292 #if defined(__IMXRT1062__)
9393 // start off with just trying on T4.x
9494 cdPin_ = _SD_DAT3;
95- if (!ret) pinMode (_SD_DAT3, INPUT_PULLDOWN);
95+ if (!ret) {
96+ pinMode (_SD_DAT3, INPUT_PULLDOWN);
97+ delayMicroseconds (5 );
98+ }
9699 #endif
97100 return ret;
98101 }
@@ -140,29 +143,34 @@ bool SDClass::mediaPresent()
140143 // Serial.print("status=offline");
141144 ret = false ;
142145 #ifdef _SD_DAT3
143- if (csPin_ == BUILTIN_SDCARD)
146+ if (csPin_ == BUILTIN_SDCARD) {
144147 pinMode (_SD_DAT3, INPUT_PULLDOWN);
148+ delayMicroseconds (5 );
149+ }
145150 #endif
146151 } else {
147152 // Serial.print("status=present");
148153 ret = true ;
149154 }
150155 } else {
151- // TODO: need a quick test, only call begin if likely present
152156 ret = true ; // assume we need to check
153-
157+ // quick test with cdPin_ or _SD_DAT3, only call restart() if likely present
154158 #ifdef _SD_DAT3
155159 if (csPin_ == BUILTIN_SDCARD) ret = digitalReadFast (_SD_DAT3);
156160 else
157161 #endif
158162 {
159163 if (cdPin_ < NUM_DIGITAL_PINS) ret = digitalRead (cdPin_);
160164 }
161- // now try to restart
162- if (ret)
163- {
165+ if (ret) {
166+ // now try to restart
164167 ret = sdfs.restart ();
165- // bugbug:: if it fails and builtin may need to start pinMode again...
168+ #ifdef _SD_DAT3
169+ if (!ret) {
170+ pinMode (_SD_DAT3, INPUT_PULLDOWN);
171+ delayMicroseconds (5 );
172+ }
173+ #endif
166174 }
167175 // Serial.print(ret ? "begin ok" : "begin nope");
168176 }
You can’t perform that action at this time.
0 commit comments