Refactor getting bootloader size from lambda to function
This commit is contained in:
parent
355160dedb
commit
289e66160e
@ -332,14 +332,8 @@ void writeEepromByte(uint8_t *addr, uint8_t value)
|
||||
|
||||
} // namespace
|
||||
|
||||
static inline void performChipErase()
|
||||
static inline uint16_t getBootloaderSize()
|
||||
{
|
||||
constexpr auto getEepromEraseFuseBit = []() -> bool {
|
||||
constexpr auto EESAVE = 3;
|
||||
return boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS) & (1 << EESAVE);
|
||||
};
|
||||
|
||||
constexpr auto getBootloaderSize = []() -> uint16_t {
|
||||
const auto highFuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
|
||||
constexpr auto BOOTSZ0 = 1;
|
||||
constexpr auto BOOTSZ1 = 2;
|
||||
@ -351,11 +345,23 @@ static inline void performChipErase()
|
||||
else if (highFuse & (1 << BOOTSZ0))
|
||||
return 1024 * 2;
|
||||
return 2048 * 2;
|
||||
}
|
||||
|
||||
static inline uint32_t getFlashSize()
|
||||
{
|
||||
const auto bootloaderSize = getBootloaderSize();
|
||||
return (FLASHEND - bootloaderSize + 1);
|
||||
}
|
||||
|
||||
static inline void performChipErase()
|
||||
{
|
||||
constexpr auto getEepromEraseFuseBit = []() -> bool {
|
||||
constexpr auto EESAVE = 3;
|
||||
return boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS) & (1 << EESAVE);
|
||||
};
|
||||
|
||||
constexpr auto eraseFlash = [getBootloaderSize]() {
|
||||
const auto bootloaderSize = getBootloaderSize();
|
||||
const auto flashSize = (FLASHEND - bootloaderSize + 1);
|
||||
constexpr auto eraseFlash = []() {
|
||||
const auto flashSize = getFlashSize();
|
||||
|
||||
for (uint16_t i = 0; i < flashSize; i += SPM_PAGESIZE) {
|
||||
boot_page_erase(i);
|
||||
|
Loading…
Reference in New Issue
Block a user