summaryrefslogtreecommitdiff
path: root/src/flash/str9x.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-26 11:30:34 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-26 11:30:34 +0000
commite5181df1d461980e6faee9c08891ccae901a06f2 (patch)
tree30ee78d112ed06a327cbc59be78c8a25f33cf342 /src/flash/str9x.c
parentf5507d89293f00458f88624ffa98434d58b91e0f (diff)
downloadopenocd+libswd-e5181df1d461980e6faee9c08891ccae901a06f2.tar.gz
openocd+libswd-e5181df1d461980e6faee9c08891ccae901a06f2.tar.bz2
openocd+libswd-e5181df1d461980e6faee9c08891ccae901a06f2.tar.xz
openocd+libswd-e5181df1d461980e6faee9c08891ccae901a06f2.zip
added 1000ms timeout
git-svn-id: svn://svn.berlios.de/openocd/trunk@970 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/str9x.c')
-rw-r--r--src/flash/str9x.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/flash/str9x.c b/src/flash/str9x.c
index e781c144..94a2a1cf 100644
--- a/src/flash/str9x.c
+++ b/src/flash/str9x.c
@@ -305,8 +305,9 @@ int str9x_erase(struct flash_bank_s *bank, int first, int last)
{
return retval;
}
-
- while (1) {
+
+ int i;
+ for (i=0; i<1000; i++) {
if ((retval=target_read_u8(target, adr, &status))!=ERROR_OK)
{
return retval;
@@ -315,6 +316,11 @@ int str9x_erase(struct flash_bank_s *bank, int first, int last)
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)
@@ -571,13 +577,20 @@ int str9x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
/* 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);
@@ -614,12 +627,19 @@ int str9x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
/* 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);