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();
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 =
.clearerr = stm32_flash_clearerror,
};
-
-
static const KBlockVTable flash_stm32_unbuffered_vt =
{
.readDirect = stm32_flash_readDirect,
#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 */