Commit afa00b8
committed
mimxrt/sdcard: Implement proper timeout in sdcard_transfer_blocking.
The previous implementation used USDHC_TransferBlocking which has
infinite loops in USDHC_WaitCommandDone and USDHC_TransferDataBlocking
with no timeout mechanism. Even though the wrapper had a timeout loop,
once inside the SDK function there was no way to abort.
This change replaces USDHC_TransferBlocking with USDHC_TransferNonBlocking
combined with polling of interrupt status flags and proper timeout
handling. The function now:
- Checks for card busy state with timeout before starting transfer
- Uses non-blocking SDK transfer to avoid infinite loops
- Polls interrupt flags with timeout for completion
- Properly handles both command-only and data transfers
- Calls error recovery on timeout or error conditions
This ensures that SD card operations will not hang indefinitely when
hardware doesn't respond as expected.
Signed-off-by: Andrew Leech <[email protected]>1 parent 832e10a commit afa00b8
1 file changed
+41
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
313 | | - | |
| 312 | + | |
| 313 | + | |
314 | 314 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
318 | 348 | | |
| 349 | + | |
319 | 350 | | |
320 | | - | |
| 351 | + | |
321 | 352 | | |
| 353 | + | |
322 | 354 | | |
323 | 355 | | |
324 | | - | |
325 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
326 | 360 | | |
327 | 361 | | |
328 | 362 | | |
| |||
0 commit comments