Skip to content

Commit 5dd7a5d

Browse files
committed
stm: SDIOSDCard: Wait for write-complete just like micropython
1 parent 5cf1a1d commit 5dd7a5d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ports/stm/common-hal/_sdcardio/SDIOSDCard.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
140140
STATIC void wait_write_complete(sdcardio_sdiosdcard_obj_t *self) {
141141
if (self->state_programming) {
142142
HAL_SD_CardStateTypedef st = HAL_SD_CARD_PROGRAMMING;
143-
for (int i=0; i < 50000 && st == HAL_SD_CARD_PROGRAMMING; i++) {
143+
// This waits up to 60s for programming to complete. This seems like
144+
// an extremely long time, but this is the timeout that micropython's
145+
// implementation uses
146+
for (int i=0; i < 60000 && st == HAL_SD_CARD_PROGRAMMING; i++) {
144147
st = HAL_SD_GetCardState(&self->handle);
145-
HAL_Delay(10);
148+
HAL_Delay(1);
146149
};
147150
self->state_programming = false;
148151
}

0 commit comments

Comments
 (0)