comparison packages/io/flash/current/src/flash.c @ 195:67850532eebb

Merge from eCos master repository on 2001-11-02-06:43:03-GMT
author jlarmour
date Fri, 02 Nov 2001 16:12:33 +0000
parents 678094f34118
children e0c0827131d1
comparison
equal deleted inserted replaced
194:feb0fcf83327 195:67850532eebb
200 200
201 HAL_FLASH_CACHES_OFF(d_cache, i_cache); 201 HAL_FLASH_CACHES_OFF(d_cache, i_cache);
202 FLASH_Enable(block, end_addr); 202 FLASH_Enable(block, end_addr);
203 while (block < end_addr) { 203 while (block < end_addr) {
204 // Supply the blocksize for a gross check for erase success 204 // Supply the blocksize for a gross check for erase success
205 stat = (*_flash_erase_block)(block, flash_info.block_size); 205 int i;
206 stat = flash_hwr_map_error(stat); 206 unsigned char *dp;
207 bool erased = true;
208
209 dp = (unsigned char *)block;
210 for (i = 0; i < flash_info.block_size; i++) {
211 if (*dp++ != (unsigned char)0xFF) {
212 erased = false;
213 break;
214 }
215 }
216 if (!erased) {
217 stat = (*_flash_erase_block)(block, flash_info.block_size);
218 stat = flash_hwr_map_error(stat);
219 }
207 if (stat) { 220 if (stat) {
208 *err_addr = (void *)block; 221 *err_addr = (void *)block;
209 break; 222 break;
210 } 223 }
211 block += flash_info.block_size / sizeof(*block); 224 block += flash_info.block_size / sizeof(*block);
273 stat = (*_flash_program_buf)(addr, data, size, 286 stat = (*_flash_program_buf)(addr, data, size,
274 flash_info.block_mask, flash_info.buffer_size); 287 flash_info.block_mask, flash_info.buffer_size);
275 stat = flash_hwr_map_error(stat); 288 stat = flash_hwr_map_error(stat);
276 #ifdef CYGSEM_IO_FLASH_VERIFY_PROGRAM 289 #ifdef CYGSEM_IO_FLASH_VERIFY_PROGRAM
277 if (0 == stat) // Claims to be OK 290 if (0 == stat) // Claims to be OK
278 if (memcmp(addr, data, size) != 0) { 291 if (memcmp(addr, data, size) != 0) {
279 stat = 0x0BAD; 292 stat = 0x0BAD;
280 (*flash_info.pf)("V"); 293 (*flash_info.pf)("V");
281 } 294 }
282 #endif 295 #endif
283 if (stat) { 296 if (stat) {