@@ -13,6 +13,9 @@ int EEPROMaddress = 0;
13
13
char commandBuffer[BUFFER_SIZE + 1 ];
14
14
char strTemp[2001 ];
15
15
16
+ const char sdCardTestStringLength = 100 ;
17
+ const char *testString = {" This is some test string..." };
18
+
16
19
// Internal registers of MCP
17
20
uint8_t mcpRegsInt[22 ];
18
21
@@ -22,6 +25,8 @@ void setup()
22
25
Serial.begin (115200 );
23
26
EEPROM.begin (64 );
24
27
28
+ microSDCardTest ();
29
+
25
30
vcomVoltage = -1.19 ;
26
31
27
32
if (EEPROM.read (EEPROMaddress) != 170 )
@@ -500,3 +505,69 @@ void writeVCOMToEEPROM(double v)
500
505
Serial.println (" \n VCOM EEPROM PROGRAMMING OK\n " );
501
506
}
502
507
}
508
+
509
+ int checkMicroSDCard ()
510
+ {
511
+ int sdInitOk = 0 ;
512
+ sdInitOk = display.sdCardInit ();
513
+
514
+ if (sdInitOk)
515
+ {
516
+ File file;
517
+
518
+ if (file.open (" /testFile.txt" , O_CREAT | O_RDWR))
519
+ {
520
+ file.print (testString);
521
+ file.close ();
522
+ }
523
+ else
524
+ {
525
+ return 0 ;
526
+ }
527
+
528
+ delay (250 );
529
+
530
+ if (file.open (" /testFile.txt" , O_RDWR))
531
+ {
532
+ char sdCardString[sdCardTestStringLength];
533
+ file.read (sdCardString, sizeof (sdCardString));
534
+ sdCardString[file.fileSize ()] = 0 ;
535
+ int stringCompare = strcmp (testString, sdCardString);
536
+ file.remove ();
537
+ file.close ();
538
+ if (stringCompare != 0 )
539
+ return 0 ;
540
+ }
541
+ else
542
+ {
543
+ return 0 ;
544
+ }
545
+ }
546
+ else
547
+ {
548
+ return 0 ;
549
+ }
550
+ return 1 ;
551
+ }
552
+
553
+ void microSDCardTest ()
554
+ {
555
+ display.setTextSize (5 );
556
+ display.setCursor (100 , 100 );
557
+ display.print (" microSD card slot test " );
558
+
559
+ if (checkMicroSDCard ())
560
+ {
561
+ display.print (" OK!" );
562
+ display.display ();
563
+ }
564
+ else
565
+ {
566
+ display.print (" FAIL!" );
567
+ display.display ();
568
+ while (1 );
569
+ }
570
+
571
+ display.clearDisplay ();
572
+ delay (2500 );
573
+ }
0 commit comments