Add backup checksum

save_scan
erikkaashoek 3 years ago
parent aaf72f8adb
commit 6df64d7d38

@ -172,9 +172,17 @@ static THD_FUNCTION(Thread1, arg)
b.RBW = SI4432_rbw_selected+1;
#endif
b.mode = setting.mode;
b.checksum = 0;
uint8_t *c = (uint8_t *)&b;
int ci = USED_BACKUP_SIZE*4;
uint8_t checksum = 0x55;
while (ci--) {
checksum ^= *c++;
}
b.checksum = checksum;
uint32_t *f = (uint32_t *)&b;
uint32_t *t = &backup;
int i = USED_BACKUP_SIZE;
int i = USED_BACKUP_SIZE+1;
while (i--)
*t++ = *f++;
@ -2928,9 +2936,16 @@ int main(void)
backup_t b;
uint32_t *f = &backup;
uint32_t *t = (uint32_t *)&b;
int i = USED_BACKUP_SIZE;
int i = USED_BACKUP_SIZE+1;
while (i--)
*t++ = *f++;
uint8_t *c = (uint8_t *)&b;
int ci = USED_BACKUP_SIZE*3;
uint8_t checksum = 0x55;
while (ci--) {
checksum ^= *c++;
}
if (b.checksum == checksum) {
#ifdef TINYSA4 // Set mode not working reliably
set_mode(b.mode);
switch (b.mode) {
@ -2974,14 +2989,15 @@ int main(void)
}
}
}
}
set_refer_output(-1);
// ui_mode_menu(); // Show menu when autostarting mode
// ui_mode_menu(); // Show menu when autostarting mode
/*
* Set LCD display brightness (use DAC2 for control)
* Starting DAC1 driver, setting up the output pin as analog as suggested by the Reference Manual.
*/
#ifdef __LCD_BRIGHTNESS__
#ifdef __LCD_BRIGHTNESS__
lcd_setBrightness(config._brightness);
#else
DAC->DHR12R2 = config.dac_value; // Setup DAC: CH2 value

@ -1709,6 +1709,7 @@ typedef struct {
uint8_t reflevel;
uint8_t RBW;
uint8_t mode;
uint8_t checksum;
} backup_t;
#pragma pack(pop)

Loading…
Cancel
Save

Powered by TurnKey Linux.