summaryrefslogtreecommitdiff
path: root/src/flash/stm32x.c
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-07 00:21:59 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-07 00:21:59 +0000
commitfdf114ab0a5078ea0a46d060bb79f882954589ea (patch)
tree087cf616f0d3749acffc2187e45e387e8a8450f2 /src/flash/stm32x.c
parenta3b6236289fc696d2569ea451ba21415f678a1e0 (diff)
downloadopenocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.gz
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.bz2
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.xz
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.zip
Fix stm32x and pic32mx flash pointer cast alignment warnings, simplify their last word handling.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1626 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/stm32x.c')
-rw-r--r--src/flash/stm32x.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c
index 8b872391..e151fc57 100644
--- a/src/flash/stm32x.c
+++ b/src/flash/stm32x.c
@@ -658,8 +658,11 @@ static int stm32x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 c
while (words_remaining > 0)
{
+ u16 value;
+ memcpy(&value, buffer + bytes_written, sizeof(u16));
+
target_write_u32(target, STM32_FLASH_CR, FLASH_PG);
- target_write_u16(target, address, *(u16*)(buffer + bytes_written));
+ target_write_u16(target, address, value);
status = stm32x_wait_status_busy(bank, 5);
@@ -681,18 +684,11 @@ static int stm32x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 c
if (bytes_remaining)
{
- u8 last_halfword[2] = {0xff, 0xff};
- int i = 0;
-
- while(bytes_remaining > 0)
- {
- last_halfword[i++] = *(buffer + bytes_written);
- bytes_remaining--;
- bytes_written++;
- }
-
+ u16 value = 0xffff;
+ memcpy(&value, buffer + bytes_written, bytes_remaining);
+
target_write_u32(target, STM32_FLASH_CR, FLASH_PG);
- target_write_u16(target, address, *(u16*)last_halfword);
+ target_write_u16(target, address, value);
status = stm32x_wait_status_busy(bank, 5);