{
return retval;
}
-
- while (1) {
+
+ int i;
+ for (i=0; i<1000; i++) {
if ((retval=target_read_u8(target, adr, &status))!=ERROR_OK)
{
return retval;
break;
alive_sleep(1);
}
+ if (i==1000)
+ {
+ LOG_ERROR("erase timed out");
+ return ERROR_FAIL;
+ }
/* clear status, also clear read array */
if ((retval=target_write_u16(target, adr, 0x50))!=ERROR_OK)
/* get status command */
target_write_u16(target, bank_adr, 0x70);
-
- while (1) {
+
+ int i;
+ for (i=0; i<1000; i++)
+ {
target_read_u8(target, bank_adr, &status);
if( status & 0x80 )
break;
alive_sleep(1);
}
+ if (i==1000)
+ {
+ LOG_ERROR("write timed out");
+ return ERROR_FAIL;
+ }
/* clear status reg and read array */
target_write_u16(target, bank_adr, 0x50);
/* query status command */
target_write_u16(target, bank_adr, 0x70);
- while (1) {
+ int i;
+ for (i=0; i<1000; i++)
+ {
target_read_u8(target, bank_adr, &status);
if( status & 0x80 )
break;
alive_sleep(1);
}
+ if (i==1000)
+ {
+ LOG_ERROR("write timed out");
+ return ERROR_FAIL;
+ }
/* clear status reg and read array */
target_write_u16(target, bank_adr, 0x50);