Commit c535ae9 1 parent 412225e commit c535ae9 Copy full SHA for c535ae9
File tree 1 file changed +16
-8
lines changed
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) {
92
92
#if defined(__IMXRT1062__)
93
93
// start off with just trying on T4.x
94
94
cdPin_ = _SD_DAT3;
95
- if (!ret) pinMode (_SD_DAT3, INPUT_PULLDOWN);
95
+ if (!ret) {
96
+ pinMode (_SD_DAT3, INPUT_PULLDOWN);
97
+ delayMicroseconds (5 );
98
+ }
96
99
#endif
97
100
return ret;
98
101
}
@@ -140,29 +143,34 @@ bool SDClass::mediaPresent()
140
143
// Serial.print("status=offline");
141
144
ret = false ;
142
145
#ifdef _SD_DAT3
143
- if (csPin_ == BUILTIN_SDCARD)
146
+ if (csPin_ == BUILTIN_SDCARD) {
144
147
pinMode (_SD_DAT3, INPUT_PULLDOWN);
148
+ delayMicroseconds (5 );
149
+ }
145
150
#endif
146
151
} else {
147
152
// Serial.print("status=present");
148
153
ret = true ;
149
154
}
150
155
} else {
151
- // TODO: need a quick test, only call begin if likely present
152
156
ret = true ; // assume we need to check
153
-
157
+ // quick test with cdPin_ or _SD_DAT3, only call restart() if likely present
154
158
#ifdef _SD_DAT3
155
159
if (csPin_ == BUILTIN_SDCARD) ret = digitalReadFast (_SD_DAT3);
156
160
else
157
161
#endif
158
162
{
159
163
if (cdPin_ < NUM_DIGITAL_PINS) ret = digitalRead (cdPin_);
160
164
}
161
- // now try to restart
162
- if (ret)
163
- {
165
+ if (ret) {
166
+ // now try to restart
164
167
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
166
174
}
167
175
// Serial.print(ret ? "begin ok" : "begin nope");
168
176
}
You can’t perform that action at this time.
0 commit comments