5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
25 #include "datastructs.h"
26 PACK(struct RamBackupUncompressed
{
33 #include "datacopy.cpp"
35 Backup::RamBackupUncompressed ramBackupUncompressed __DMA
;
39 RamBackup
* ramBackup
= &_ramBackup
;
41 RamBackup
* ramBackup
= (RamBackup
*)BKPSRAM_BASE
;
46 copyRadioData(&ramBackupUncompressed
.radio
, &g_eeGeneral
);
47 copyModelData(&ramBackupUncompressed
.model
, &g_model
);
48 ramBackup
->size
= compress(ramBackup
->data
, 4094, (const uint8_t *)&ramBackupUncompressed
, sizeof(ramBackupUncompressed
));
49 TRACE("RamBackupWrite sdsize=%d backupsize=%d rlcsize=%d", sizeof(ModelData
)+sizeof(RadioData
), sizeof(Backup::RamBackupUncompressed
), ramBackup
->size
);
52 bool rambackupRestore()
54 if (ramBackup
->size
== 0)
57 if (uncompress((uint8_t *)&ramBackupUncompressed
, sizeof(ramBackupUncompressed
), ramBackup
->data
, ramBackup
->size
) != sizeof(ramBackupUncompressed
))
60 memset(&g_eeGeneral
, 0, sizeof(g_eeGeneral
));
61 memset(&g_model
, 0, sizeof(g_model
));
62 copyRadioData(&g_eeGeneral
, &ramBackupUncompressed
.radio
);
63 copyModelData(&g_model
, &ramBackupUncompressed
.model
);