DEVICE NAME := "SD Card 4-bit interface"
PINS
DATA := 1, 9, 8, 7;
CMD := 2;
CLK := 5;
nCD := 10;
WP := 12;
VDD_ENABLE := 20;
END;
DISABLE DEVICE
VDD_ENABLE := 0;
WP := Z;
CMD := Z;
END;
TEST COVERAGE
nCD := OPEN HI LO;
CLK := OPEN HI LO;
CMD := OPEN HI LO;
VDD_ENABLE := OPEN HI LO;
DATA := OPEN HI LO;
END;
FILES
"FaultFinder.xje";
"SD_MMC.xje";
END;
END;
CONST INT PROMPT_BEFORE_DESTRUCTIVE_TEST := TRUE;
CONST INT DESTRUCTIVE_TEST_START_ADDRESS := 0;
CONST INT RESULT_PASS WIDTH 1 := FALSE;
CONST INT RESULT_FAIL WIDTH 1 := TRUE;
INT DEBUG_SD_MMC := FALSE;
TestNonDestructive()(INT result)
InsertCard()(result);
IF result != RESULT_PASS THEN RETURN; END;
Test(FALSE, 0)(result);
IF result != RESULT_PASS THEN RETURN; END;
RemoveCard()(result);
END;
TestDestructive()(INT result)
InsertCard()(result);
IF result != RESULT_PASS THEN RETURN; END;
Test(TRUE, DESTRUCTIVE_TEST_START_ADDRESS)(result);
IF result != RESULT_PASS THEN RETURN; END;
RemoveCard()(result);
END;
InsertCard()(INT result)
INT notDetect;
INT key;
result := RESULT_PASS;
SET CMD := I, DATA := I;
IF READABLE(nCD) THEN
SET notDetect := nCD;
IF notDetect THEN
DO WHILE GETKEY() END;
PRINT("Insert SD card (", DEVICE_REF, "), or press any key to abort\n");
ALERT();
DO
SET notDetect := nCD;
WHILE (!GETKEY() && notDetect)
END;
IF (notDetect) THEN
PRINT("Waiting for card aborted by user\n");
result := RESULT_FAIL;
RETURN;
END;
END;
ELSE
DO WHILE GETKEY() END;
PRINT("Insert SD card (", DEVICE_REF, "), and press any key to continue\n");
ALERT();
key := WAITKEY();
END;
IF WRITEABLE(VDD_ENABLE) THEN
SLEEP(1000);
SET VDD_ENABLE := 1;
SET CLK := 0;
SLEEP(100);
END;
END;
RemoveCard()(INT result)
INT notDetect;
INT key;
IF WRITEABLE(VDD_ENABLE) THEN
SET VDD_ENABLE := 0;
END;
SET CLK := 0;
SET CMD := I;
IF READABLE(nCD) THEN
SET notDetect := nCD;
IF notDetect THEN
result := RESULT_PASS;
ELSE
DO WHILE GETKEY() END;
PRINT("Remove SD card (", DEVICE_REF, "), or press any key to abort\n");
ALERT();
DO
SET notDetect := nCD;
WHILE (!GETKEY() && !notDetect)
END;
IF (notDetect) THEN
result := RESULT_PASS;
ELSE
result := RESULT_FAIL;
END;
END;
ELSE
DO WHILE GETKEY() END;
PRINT("Remove SD card (", DEVICE_REF, "), and press any key to continue\n");
ALERT();
key := WAITKEY();
END;
END;