|
|
|
@ -64,7 +64,7 @@ void flash_unlock(void)
|
|
|
|
FLASH->KEYR = 0xCDEF89AB;
|
|
|
|
FLASH->KEYR = 0xCDEF89AB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define rotate(x) ((x<<1) | (x&(1<<31)?1:0))
|
|
|
|
#define rotate(x) (((x)<<1) | ((x)&(1<<31)?1:0))
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
static uint32_t
|
|
|
|
checksum(const void *start, size_t len)
|
|
|
|
checksum(const void *start, size_t len)
|
|
|
|
@ -73,7 +73,7 @@ checksum(const void *start, size_t len)
|
|
|
|
uint32_t *tail = (uint32_t*)(start + len);
|
|
|
|
uint32_t *tail = (uint32_t*)(start + len);
|
|
|
|
uint32_t value = 0;
|
|
|
|
uint32_t value = 0;
|
|
|
|
while (p < tail)
|
|
|
|
while (p < tail)
|
|
|
|
value = rotate(value) | *p++;
|
|
|
|
value = rotate(value) + *p++;
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -142,8 +142,7 @@ caldata_save(int id)
|
|
|
|
dst = (uint16_t*)saveareas[id];
|
|
|
|
dst = (uint16_t*)saveareas[id];
|
|
|
|
|
|
|
|
|
|
|
|
current_props.magic = CONFIG_MAGIC;
|
|
|
|
current_props.magic = CONFIG_MAGIC;
|
|
|
|
current_props.checksum = 0;
|
|
|
|
current_props.checksum = checksum(¤t_props, sizeof current_props - sizeof current_props.checksum);
|
|
|
|
current_props.checksum = checksum(¤t_props, sizeof current_props);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash_unlock();
|
|
|
|
flash_unlock();
|
|
|
|
|
|
|
|
|
|
|
|
|