summaryrefslogtreecommitdiff
path: root/ucoo/hal/self_programming/self_programming.stm32f4.cc
diff options
context:
space:
mode:
authorNicolas Schodet2015-11-25 17:11:43 +0100
committerNicolas Schodet2019-10-07 00:44:57 +0200
commitcd8dfb2c6cae2cb3c4a9440bb19773cefb1d0eb3 (patch)
treec77322da6186470de532b9ccd9ddd9e2a608094d /ucoo/hal/self_programming/self_programming.stm32f4.cc
parentdde0d4cfe6379e628729fe87aa5849db6cc11366 (diff)
ucoo/hal/self_programming: add STM32F1 support
Diffstat (limited to 'ucoo/hal/self_programming/self_programming.stm32f4.cc')
-rw-r--r--ucoo/hal/self_programming/self_programming.stm32f4.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/ucoo/hal/self_programming/self_programming.stm32f4.cc b/ucoo/hal/self_programming/self_programming.stm32f4.cc
index 9d8aa56..9d352ac 100644
--- a/ucoo/hal/self_programming/self_programming.stm32f4.cc
+++ b/ucoo/hal/self_programming/self_programming.stm32f4.cc
@@ -46,10 +46,17 @@ static const uint32_t sector_addr[] = {
0x81e0000, 0x8200000,
};
+int
+self_programming_flash_size ()
+{
+ return DESIG_FLASH_SIZE * 1024;
+}
+
void
self_programming_erase (uint32_t addr, int count)
{
- assert (addr - sector_addr[0] + count <= DESIG_FLASH_SIZE * 1024);
+ assert (static_cast<int> (addr - sector_addr[0] + count)
+ <= self_programming_flash_size ());
int sector;
for (sector = 0; count && sector < lengthof (sector_addr); sector++)
{
@@ -72,7 +79,8 @@ self_programming_write (uint32_t addr, const char *buf, int count)
assert (addr % 4 == 0);
assert (reinterpret_cast<int> (buf) % 4 == 0);
assert (count % 4 == 0);
- assert (addr - sector_addr[0] + count <= DESIG_FLASH_SIZE * 1024);
+ assert (static_cast<int> (addr - sector_addr[0] + count)
+ <= self_programming_flash_size ());
flash_unlock ();
for (int i = 0; i < count; i += 4)
flash_program_word (addr + i,