From be06dc365db7e0f8d4d751dc83758da78b97787d Mon Sep 17 00:00:00 2001 From: Dual Tachyon Date: Fri, 1 Sep 2023 12:30:29 +0100 Subject: [PATCH] Added BOARD_FactoryReset. --- app/menu.c | 2 +- board.c | 25 +++++++++++++++++++++++++ board.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/menu.c b/app/menu.c index e8808a2..ce57ef6 100644 --- a/app/menu.c +++ b/app/menu.c @@ -471,7 +471,7 @@ void MENU_AcceptSetting(void) return; case MENU_RESET: - //EepromFactoryReset(gSubMenuSelection); + BOARD_FactoryReset(gSubMenuSelection); return; case MENU_350TX: diff --git a/board.c b/board.c index 25cd4f9..b7f3e18 100644 --- a/board.c +++ b/board.c @@ -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); + } + } +} + diff --git a/board.h b/board.h index 597f536..0d6405f 100644 --- a/board.h +++ b/board.h @@ -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