mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Improve SD card reliability on all boards by trying to initialise multiple times before failing
This commit is contained in:
parent
ee11a83581
commit
773a83387f
@ -16,6 +16,7 @@
|
||||
Fix mild memory leak in jsvMakeIntoVariableName that caused GC to run more often than normal
|
||||
E.toString now tries harder to allocate a Flat String, and works with no-alloc for Uint8Array/FlatStrings
|
||||
WIO_LTE fix SD card initialisation
|
||||
Improve SD card reliability on all boards by trying to initialise multiple times before failing
|
||||
|
||||
1v95 : nRF5x: Swap to UART fifo to avoid overrun errors at high baud rates
|
||||
Ensure Exceptions/errors are reported on a blank line
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "platform_config.h"
|
||||
#include "jsutils.h"
|
||||
#include "jshardware.h"
|
||||
#include "jsparse.h"
|
||||
#include "jsspi.h"
|
||||
#include "diskio.h"
|
||||
|
||||
@ -325,11 +326,16 @@ DSTATUS disk_initialize (
|
||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||
if (Stat & STA_NODISK) return Stat; /* No card in the socket */
|
||||
|
||||
power_on(); /* Force socket power on */
|
||||
for (n = 10; n; n--) read_spi_byte(); /* 80 dummy clocks */
|
||||
// try and initialise the SD card - give it a few tries
|
||||
int tries = 2;
|
||||
do {
|
||||
power_on(); /* Force socket power on */
|
||||
for (n = 10; n; n--) read_spi_byte(); /* 80 dummy clocks */
|
||||
n = send_cmd(CMD0, 0);
|
||||
} while ((n != 1) && (tries-- > 0) && !jspIsInterrupted());
|
||||
|
||||
ty = 0;
|
||||
if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
|
||||
if (n == 1) { /* Enter Idle state */
|
||||
JsSysTime endTime = jshGetSystemTime()+jshGetTimeFromMilliseconds(1000); /* Initialization timeout of 1000 msec */
|
||||
if (send_cmd(CMD8, 0x1AA) == 1) { /* SDHC */
|
||||
for (n = 0; n < 4; n++) ocr[n] = read_spi_byte(); /* Get trailing return value of R7 resp */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user