IAP compatible.
Fork of IAP by
Import programSTM32_IAP_internal_flash_write
STM32_IAP demo.
Import programSTM32_IAP_test
STM32_IAP test
Diff: IAP_STM32F4.cpp
- Revision:
- 11:937bd817d5bf
- Parent:
- 9:7e19f12b81b4
- Child:
- 12:fd6a08b46228
diff -r a0c5bb26d159 -r 937bd817d5bf IAP_STM32F4.cpp --- a/IAP_STM32F4.cpp Mon Apr 11 20:01:05 2016 +0900 +++ b/IAP_STM32F4.cpp Tue Apr 12 15:09:09 2016 +0000 @@ -89,14 +89,14 @@ int IAP::blank_check( int start, int end ) { - if (start >= FLASH_SECTOR_TOTAL || end >= FLASH_SECTOR_TOTAL) { + if (start > end || start >= FLASH_SECTOR_TOTAL || end >= FLASH_SECTOR_TOTAL) { return INVALID_SECTOR; } static const int offset[8+1] = {0x00000, 0x04000, 0x08000, 0xc000, 0x10000, 0x20000, 0x40000, 0x60000, 0x80000}; - uint8_t* p = reinterpret_cast<uint8_t*>(FLASH_BASE + offset[start]); - uint8_t* e = reinterpret_cast<uint8_t*>(FLASH_BASE + offset[end + 1]); - while(p < e) { - if (*p++ != 0x00) { + uint8_t* it = reinterpret_cast<uint8_t*>(FLASH_BASE + offset[start]); + uint8_t* it_end = reinterpret_cast<uint8_t*>(FLASH_BASE + offset[end + 1]); + for(; it != it_end; it++) { + if (*it != 0xff) { return SECTOR_NOT_BLANK; } }