@@ -131,31 +131,30 @@ static bool page_erased(uint32_t sector_address) {
131
131
if (flash_device -> no_erase_cmd ){
132
132
// skip this if device doesn't have an erase command.
133
133
return true;
134
- } else {
135
- uint8_t short_buffer [4 ];
136
- if (read_flash (sector_address , short_buffer , 4 )) {
137
- for (uint16_t i = 0 ; i < 4 ; i ++ ) {
138
- if (short_buffer [i ] != 0xff ) {
139
- return false;
140
- }
134
+ }
135
+ uint8_t short_buffer [4 ];
136
+ if (read_flash (sector_address , short_buffer , 4 )) {
137
+ for (uint16_t i = 0 ; i < 4 ; i ++ ) {
138
+ if (short_buffer [i ] != 0xff ) {
139
+ return false;
141
140
}
142
- } else {
143
- return false;
144
141
}
142
+ } else {
143
+ return false;
144
+ }
145
145
146
- // Now check the full length.
147
- uint8_t full_buffer [FILESYSTEM_BLOCK_SIZE ];
148
- if (read_flash (sector_address , full_buffer , FILESYSTEM_BLOCK_SIZE )) {
149
- for (uint16_t i = 0 ; i < FILESYSTEM_BLOCK_SIZE ; i ++ ) {
150
- if (short_buffer [i ] != 0xff ) {
151
- return false;
152
- }
146
+ // Now check the full length.
147
+ uint8_t full_buffer [FILESYSTEM_BLOCK_SIZE ];
148
+ if (read_flash (sector_address , full_buffer , FILESYSTEM_BLOCK_SIZE )) {
149
+ for (uint16_t i = 0 ; i < FILESYSTEM_BLOCK_SIZE ; i ++ ) {
150
+ if (short_buffer [i ] != 0xff ) {
151
+ return false;
153
152
}
154
- } else {
155
- return false;
156
153
}
157
- return true;
154
+ } else {
155
+ return false;
158
156
}
157
+ return true;
159
158
}
160
159
161
160
// Erases the given sector. Make sure you copied all of the data out of it you
@@ -166,16 +165,15 @@ static bool erase_sector(uint32_t sector_address) {
166
165
if (flash_device -> no_erase_cmd ){
167
166
// skip this if device doesn't have an erase command.
168
167
return true;
169
- } else {
170
- if (!wait_for_flash_ready () || !write_enable ()) {
171
- return false;
172
- }
173
- if (flash_device -> no_erase_cmd ) {
174
- return true;
175
- } else {
176
- spi_flash_sector_command (CMD_SECTOR_ERASE , sector_address );
168
+ }
169
+ if (!wait_for_flash_ready () || !write_enable ()) {
170
+ return false;
171
+ }
172
+ if (flash_device -> no_erase_cmd ) {
177
173
return true;
178
- }
174
+ } else {
175
+ spi_flash_sector_command (CMD_SECTOR_ERASE , sector_address );
176
+ return true;
179
177
}
180
178
}
181
179
0 commit comments