Banish some more magic numbers (#6662)

This commit is contained in:
fauxpark 2019-09-08 01:12:46 +10:00 committed by Drashna Jaelre
parent c21281c593
commit 91bd2117df
2 changed files with 13 additions and 19 deletions

View file

@ -59,11 +59,6 @@
uint16_t bootloader_start;
#endif
#define BOOT_SIZE_256 0b110
#define BOOT_SIZE_512 0b100
#define BOOT_SIZE_1024 0b010
#define BOOT_SIZE_2048 0b000
// compatibility between ATMega8 and ATMega88
#if !defined(MCUCSR)
# if defined(MCUSR)
@ -86,11 +81,11 @@ void bootloader_jump(void) {
#if !defined(BOOTLOADER_SIZE)
uint8_t high_fuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
if (high_fuse & BOOT_SIZE_256) {
if (high_fuse & ~(FUSE_BOOTSZ0 & FUSE_BOOTSZ1)) {
bootloader_start = (FLASH_SIZE - 512) >> 1;
} else if (high_fuse & BOOT_SIZE_512) {
} else if (high_fuse & ~(FUSE_BOOTSZ1)) {
bootloader_start = (FLASH_SIZE - 1024) >> 1;
} else if (high_fuse & BOOT_SIZE_1024) {
} else if (high_fuse & ~(FUSE_BOOTSZ0)) {
bootloader_start = (FLASH_SIZE - 2048) >> 1;
} else {
bootloader_start = (FLASH_SIZE - 4096) >> 1;