Added BOARD_FactoryReset.

This commit is contained in:
Dual Tachyon 2023-09-01 12:30:29 +01:00
parent 33f9f21c4f
commit be06dc365d
3 changed files with 27 additions and 1 deletions

View File

@ -471,7 +471,7 @@ void MENU_AcceptSetting(void)
return;
case MENU_RESET:
//EepromFactoryReset(gSubMenuSelection);
BOARD_FactoryReset(gSubMenuSelection);
return;
case MENU_350TX:

25
board.c
View File

@ -825,3 +825,28 @@ void BOARD_EEPROM_LoadMoreSettings(void)
BK4819_WriteRegister(BK4819_REG_3B, gEeprom.BK4819_XTAL_FREQ_LOW + 22656);
}
void BOARD_FactoryReset(bool bIsAll)
{
uint8_t Template[8];
uint16_t i;
memset(Template, 0xFF, sizeof(Template));
for (i = 0x0C80; i < 0x1E00; i += 8) {
if (
!(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes
!(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable
!(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts
!(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings
!(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt
(bIsAll || (
!(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes
!(i >= 0x0F18 && i < 0x0F30) && // Scan List
!(i >= 0x0F50 && i < 0x1C00) && // MR Channel NAmes
!(i >= 0x0E40 && i < 0x0E70) && // FM Channels
!(i >= 0x0E88 && i < 0x0E90))) // FM settings
) {
EEPROM_WriteBuffer(i, Template);
}
}
}

View File

@ -27,6 +27,7 @@ void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void);
void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void);
void BOARD_FactoryReset(bool bIsAll);
#endif