Clean up.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 10 Aug 2010 17:29:07 +0000 (17:29 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 10 Aug 2010 17:29:07 +0000 (17:29 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4157 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/flash_stm32.c
bertos/cpu/cortex-m3/drv/flash_stm32.h

index 9d7e5974703d2682ca75acf183551a1781adad53..fc1805e283fb885c8a178dd6f3f4d20bf0158c3f 100644 (file)
@@ -68,7 +68,7 @@ struct FlashHardware
        uint8_t status;
 };
 
-INLINE bool flash_wait(struct KBlock *blk)
+static bool flash_wait(struct KBlock *blk)
 {
        Flash *fls = FLASH_CAST(blk);
        ticks_t start = timer_clock();
@@ -175,44 +175,19 @@ static size_t stm32_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const
 
        uint32_t addr = idx * blk->blk_size + offset;
        const uint8_t *buf = (const uint8_t *)_buf;
-       size_t count = 0;
 
-       if (addr % 2)
-       {
-               if (!stm32_writeWord(blk, addr - 1, (buf[0] << 8) | 0xFF))
-                       return count;
-
-               buf++;
-               size--;
-               count++;
-               addr++;
-       }
-
-       ASSERT(!(addr % 2));
        while (size)
        {
-               uint16_t data;
-               size_t len;
-               if (size == 1)
-               {
-                       data = 0xFF00 | *buf;
-                       len = 1;
-               }
-               else
-               {
-                       data = ((*buf + 1) << 8) | *buf;
-                       len = 2;
-               }
-
+               uint16_t data = ((*buf + 1) << 8) | *buf;
                if (!stm32_writeWord(blk, addr, data))
-                       return count;
+                       return 0;
 
-               buf += len;
-               size -= len;
-               count += len;
-               addr += len;
+               buf += 2;
+               size -= 2;
+               addr += 2;
        }
-       return count;
+
+       return blk->blk_size;
 }
 
 static const KBlockVTable flash_stm32_buffered_vt =
@@ -229,8 +204,6 @@ static const KBlockVTable flash_stm32_buffered_vt =
        .clearerr = stm32_flash_clearerror,
 };
 
-
-
 static const KBlockVTable flash_stm32_unbuffered_vt =
 {
        .readDirect = stm32_flash_readDirect,
index 5f475c9401512d06566e23fe3ba972d36ef5fff3..51bf35c02cbe7e2139c94f3b5f71fc776c672c99 100644 (file)
 #ifndef FLASH_STM32_H
 #define FLASH_STM32_H
 
-
-/* Flash memory mapping */
-#define FLASH_MEM_SIZE          0x40000 //< 256KiB
-#define FLASH_PAGE_SIZE_BYTES  0x400   //< 1KiB
-
-
-#define FLASH_PAGE_SIZE    FLASH_PAGE_SIZE_BYTES
-
-
 #endif /* FLASH_STM32_H */