From 093087cc07b4b74e53f6f842bf5e08cd518ca403 Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 10 Aug 2010 17:29:07 +0000 Subject: [PATCH] Clean up. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4157 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/flash_stm32.c | 43 +++++--------------------- bertos/cpu/cortex-m3/drv/flash_stm32.h | 9 ------ 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/bertos/cpu/cortex-m3/drv/flash_stm32.c b/bertos/cpu/cortex-m3/drv/flash_stm32.c index 9d7e5974..fc1805e2 100644 --- a/bertos/cpu/cortex-m3/drv/flash_stm32.c +++ b/bertos/cpu/cortex-m3/drv/flash_stm32.c @@ -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, diff --git a/bertos/cpu/cortex-m3/drv/flash_stm32.h b/bertos/cpu/cortex-m3/drv/flash_stm32.h index 5f475c94..51bf35c0 100644 --- a/bertos/cpu/cortex-m3/drv/flash_stm32.h +++ b/bertos/cpu/cortex-m3/drv/flash_stm32.h @@ -38,13 +38,4 @@ #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 */ -- 2.25.1