X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fflash_stm32.c;h=d92e91420cbb67bd5ce3171e76679c03d11ac305;hb=7a825da467bf9ce79329686b37d373c709c9937d;hp=39f16182b2c15dea44ae2b4af572175227746727;hpb=d3dc7525633421767aba136d63f6c4ea574eb597;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/flash_stm32.c b/bertos/cpu/cortex-m3/drv/flash_stm32.c index 39f16182..d92e9142 100644 --- a/bertos/cpu/cortex-m3/drv/flash_stm32.c +++ b/bertos/cpu/cortex-m3/drv/flash_stm32.c @@ -67,6 +67,7 @@ static bool flash_wait(struct KBlock *blk) ticks_t start = timer_clock(); while (true) { + cpu_relax(); if (!(EMB_FLASH->SR & FLASH_FLAG_BSY)) break; @@ -90,8 +91,6 @@ static bool flash_wait(struct KBlock *blk) LOG_ERR("Timeout..\n"); return false; } - - cpu_relax(); } return true; @@ -112,6 +111,8 @@ static bool stm32_erasePage(struct KBlock *blk, uint32_t page_add) return true; } +#if 0 +// not used for now static bool stm32_eraseAll(struct KBlock *blk) { EMB_FLASH->CR |= CR_MER_SET; @@ -124,6 +125,7 @@ static bool stm32_eraseAll(struct KBlock *blk) return true; } +#endif static int stm32_flash_error(struct KBlock *blk) { @@ -139,10 +141,7 @@ static void stm32_flash_clearerror(struct KBlock *blk) static size_t stm32_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size) { - ASSERT(offset == 0); - ASSERT(size == blk->blk_size); - - memcpy(buf, (void *)(idx * blk->blk_size), size); + memcpy(buf, (void *)(idx * blk->blk_size + offset), size); return size; } @@ -174,7 +173,6 @@ static size_t stm32_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const uint32_t addr = idx * blk->blk_size; const uint8_t *buf = (const uint8_t *)_buf; - kprintf("idx[%ld],size[%u]\n", idx, size); while (size) { uint16_t data = (*(buf + 1) << 8) | *buf; @@ -235,7 +233,7 @@ static void common_init(Flash *fls) } -void flash_hw_init(Flash *fls) +void flash_hw_init(Flash *fls, UNUSED_ARG(int, flags)) { common_init(fls); fls->blk.priv.vt = &flash_stm32_buffered_vt; @@ -243,11 +241,11 @@ void flash_hw_init(Flash *fls) fls->blk.priv.buf = flash_buf; /* Load the first block in the cache */ - void *a = 0; - memcpy(fls->blk.priv.buf, a, fls->blk.blk_size); + void *flash_start = 0x0; + memcpy(fls->blk.priv.buf, flash_start, fls->blk.blk_size); } -void flash_hw_initUnbuffered(Flash *fls) +void flash_hw_initUnbuffered(Flash *fls, UNUSED_ARG(int, flags)) { common_init(fls); fls->blk.priv.vt = &flash_stm32_unbuffered_vt;