File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ static void flash_execute_command(void) {
135135 case 0x05 : // Read Status Register-1
136136 case 0x35 : // Read Status Register-2
137137 case 0x15 : // Read Status Register-3
138- flash .commandStatus [0 ] |= 1 << 2 ;
138+ flash .commandStatus [0 ] |= 2 << 1 ;
139139 break ;
140140 case 0x32 : // Quad Input Page Program
141141 flash .commandStatus [0 ] |= 1 << 1 ;
@@ -154,6 +154,11 @@ static void flash_execute_command(void) {
154154 break ;
155155 }
156156 if (!flash .commandLength && flash .commandStatus [0 ] & 3 << 1 ) {
157+ /* Zero-length reads or writes finish without any byte transfers */
158+ flash .commandStatus [0 ] &= ~(3 << 1 );
159+ flash_finish_command ();
160+ } else if (flash .commandStatus [0 ] & 2 << 1 ) {
161+ /* Reads are considered finished before the byte transfers */
157162 flash_finish_command ();
158163 }
159164}
@@ -193,8 +198,11 @@ static void flash_write_command(uint8_t byte) {
193198}
194199static void flash_command_byte_transferred (void ) {
195200 if (!-- flash .commandLength ) {
201+ bool write = flash .commandStatus [0 ] & 1 << 1 ;
196202 flash .commandStatus [0 ] &= ~(3 << 1 );
197- flash_finish_command ();
203+ if (write ) {
204+ flash_finish_command ();
205+ }
198206 }
199207}
200208
You can’t perform that action at this time.
0 commit comments