summaryrefslogtreecommitdiff
path: root/src/flash/str7x.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-28 10:44:41 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-28 10:44:41 +0000
commit86ca2270f40d650a849e778518e7aa9c2c713341 (patch)
tree76d0f52c9637707506e8df254f733d32c5b9b269 /src/flash/str7x.c
parentb008ff7ae1f5e646311b3901772be8c9ddaecd0c (diff)
downloadopenocd_libswd-86ca2270f40d650a849e778518e7aa9c2c713341.tar.gz
openocd_libswd-86ca2270f40d650a849e778518e7aa9c2c713341.tar.bz2
openocd_libswd-86ca2270f40d650a849e778518e7aa9c2c713341.tar.xz
openocd_libswd-86ca2270f40d650a849e778518e7aa9c2c713341.zip
Pavel Chromy cleaned up checks for halted, error messages, etc.
git-svn-id: svn://svn.berlios.de/openocd/trunk@374 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/str7x.c')
-rw-r--r--src/flash/str7x.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/flash/str7x.c b/src/flash/str7x.c
index 3574a897..30b8c07f 100644
--- a/src/flash/str7x.c
+++ b/src/flash/str7x.c
@@ -314,6 +314,11 @@ int str7x_erase(struct flash_bank_s *bank, int first, int last)
u32 retval;
u32 b0_sectors = 0, b1_sectors = 0;
+ if (bank->target->state != TARGET_HALTED)
+ {
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
for (i = first; i <= last; i++)
{
if (str7x_info->sector_bank[i] == 0)
@@ -568,6 +573,11 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
u32 check_address = offset;
int i;
+ if (bank->target->state != TARGET_HALTED)
+ {
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
if (offset & 0x7)
{
WARNING("offset 0x%x breaks required 8-byte alignment", offset);
@@ -627,18 +637,18 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
while (dwords_remaining > 0)
{
- // command
+ /* command */
cmd = FLASH_DWPG;
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), cmd);
- // address
+ /* address */
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address);
- // data word 1
+ /* data word 1 */
target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, buffer + bytes_written);
bytes_written += 4;
- // data word 2
+ /* data word 2 */
target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, buffer + bytes_written);
bytes_written += 4;
@@ -674,18 +684,18 @@ int str7x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
bytes_written++;
}
- // command
+ /* command */
cmd = FLASH_DWPG;
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), cmd);
- // address
+ /* address */
target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address);
- // data word 1
+ /* data word 1 */
target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, last_dword);
bytes_written += 4;
- // data word 2
+ /* data word 2 */
target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, last_dword + 4);
bytes_written += 4;