]> localhost Git - SCSI2SD.git/commitdiff
Perform a software reset of the spi flash before init
authorMichael McMaster <michael@codesrc.com>
Tue, 9 Feb 2021 02:12:37 +0000 (12:12 +1000)
committerMichael McMaster <michael@codesrc.com>
Tue, 9 Feb 2021 02:12:37 +0000 (12:12 +1000)
software/SCSI2SD/src/flash.c

index 0e8783c0993544adf140de03458bfefbc4cfc752..ed015d3db895b3c6feb77946d97752c8200e383b 100644 (file)
@@ -164,11 +164,23 @@ static void spiFlash_init(S2S_Device* dev)
     nNOR_CS_Write(1); // Deselect
     
     NOR_SPI_Start();
-    CyDelayUs(1);
+    CyDelayUs(50); // tRPH is 35 uS. Wait a bit longer
 
+    // Mode-bit-reset (go back to normal from high performance mode)
     nNOR_CS_Write(0); // Select
     CyDelayCycles(4); // Tiny delay
-    
+    spiFlashByte(0xFF);
+    nNOR_CS_Write(1); // Deselect
+    CyDelayCycles(4); // Tiny delay
+
+    // Software-reset
+    nNOR_CS_Write(0); // Select
+    CyDelayCycles(4); // Tiny delay
+    spiFlashByte(0xF0);
+    nNOR_CS_Write(1); // Deselect - reset is triggered on the deselect
+    CyDelayUs(50); // tRPH is 35 uS. Wait a bit longer
+
+    nNOR_CS_Write(0); // Select
     // JEDEC standard "Read Identification" command
     // returns CFI information
     spiFlashByte(0x9F);
@@ -450,4 +462,4 @@ static int spiFlash_readAsyncPoll(S2S_Device* dev)
     }
     
     return allComplete;
-}
\ No newline at end of file
+}