简化EEPROM驱动逻辑

改为STLINK-SWD烧录
This commit is contained in:
wu58430 2024-01-05 17:23:20 +08:00
parent 89092efb38
commit a83cb8a8f7
10 changed files with 53 additions and 119 deletions

View file

@ -20,46 +20,16 @@
</configurations> </configurations>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="fix show"> <list default="true" id="cea36e80-e289-4d69-9030-7186d540ac0e" name="更改" comment="113">
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/aircopy.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/aircopy.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Makefile" beforeDir="false" afterPath="$PROJECT_DIR$/Makefile" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/fm.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/fm.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/am_fix.c" beforeDir="false" afterPath="$PROJECT_DIR$/am_fix.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/action.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/action.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/app.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/app.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/dtmf.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/dtmf.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/menu.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/menu.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/menu.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/menu.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/spectrum.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/spectrum.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/uart.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/uart.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/uart.c" beforeDir="false" afterPath="$PROJECT_DIR$/app/uart.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/3.25.2/CMakeCCompiler.cmake" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/3.25.2/CMakeCCompiler.cmake" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/CMakeOutput.log" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/CMakeOutput.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/Makefile" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/Makefile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/cmake_install.cmake" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/cmake_install.cmake" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/uv_k5_firmware_custom_0_17.cbp" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/uv_k5_firmware_custom_0_17.cbp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dp32g030.cfg" beforeDir="false" afterPath="$PROJECT_DIR$/dp32g030.cfg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/driver/eeprom.c" beforeDir="false" afterPath="$PROJECT_DIR$/driver/eeprom.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/driver/eeprom.c" beforeDir="false" afterPath="$PROJECT_DIR$/driver/eeprom.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/firmware" beforeDir="false" afterPath="$PROJECT_DIR$/firmware" afterDir="false" /> <change beforePath="$PROJECT_DIR$/driver/eeprom.h" beforeDir="false" afterPath="$PROJECT_DIR$/driver/eeprom.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/functions.c" beforeDir="false" afterPath="$PROJECT_DIR$/functions.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/main.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/functions.h" beforeDir="false" afterPath="$PROJECT_DIR$/functions.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/misc.c" beforeDir="false" afterPath="$PROJECT_DIR$/misc.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/misc.h" beforeDir="false" afterPath="$PROJECT_DIR$/misc.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/radio.c" beforeDir="false" afterPath="$PROJECT_DIR$/radio.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/radio.h" beforeDir="false" afterPath="$PROJECT_DIR$/radio.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.c" beforeDir="false" afterPath="$PROJECT_DIR$/settings.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/settings.c" beforeDir="false" afterPath="$PROJECT_DIR$/settings.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/aircopy.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/aircopy.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/fmradio.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/fmradio.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/helper.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/helper.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/helper.h" beforeDir="false" afterPath="$PROJECT_DIR$/ui/helper.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/lock.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/lock.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/main.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/main.h" beforeDir="false" afterPath="$PROJECT_DIR$/ui/main.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/menu.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/menu.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/menu.h" beforeDir="false" afterPath="$PROJECT_DIR$/ui/menu.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/scanner.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/scanner.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ui/welcome.c" beforeDir="false" afterPath="$PROJECT_DIR$/ui/welcome.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/version.c" beforeDir="false" afterPath="$PROJECT_DIR$/version.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/win_make.bat" beforeDir="false" afterPath="$PROJECT_DIR$/win_make.bat" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -298,14 +268,7 @@
<workItem from="1704363500769" duration="5676000" /> <workItem from="1704363500769" duration="5676000" />
<workItem from="1704370562673" duration="1618000" /> <workItem from="1704370562673" duration="1618000" />
<workItem from="1704421657950" duration="14943000" /> <workItem from="1704421657950" duration="14943000" />
<workItem from="1704442479624" duration="1663000" /> <workItem from="1704442479624" duration="3981000" />
</task>
<task id="LOCAL-00054" summary="写频">
<created>1701738074321</created>
<option name="number" value="00054" />
<option name="presentableId" value="LOCAL-00054" />
<option name="project" value="LOCAL" />
<updated>1701738074322</updated>
</task> </task>
<task id="LOCAL-00055" summary="写频"> <task id="LOCAL-00055" summary="写频">
<created>1701738086757</created> <created>1701738086757</created>
@ -643,7 +606,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1703581336394</updated> <updated>1703581336394</updated>
</task> </task>
<option name="localTasksCounter" value="103" /> <task id="LOCAL-00103" summary="113">
<created>1704445475471</created>
<option name="number" value="00103" />
<option name="presentableId" value="LOCAL-00103" />
<option name="project" value="LOCAL" />
<updated>1704445475471</updated>
</task>
<option name="localTasksCounter" value="104" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -670,7 +640,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="reduce flash" />
<MESSAGE value="rebuild chinese" /> <MESSAGE value="rebuild chinese" />
<MESSAGE value="MDC RX" /> <MESSAGE value="MDC RX" />
<MESSAGE value="写频" /> <MESSAGE value="写频" />
@ -695,7 +664,8 @@
<MESSAGE value="支持中文编译选项ENABLE_CHINESE_FULL" /> <MESSAGE value="支持中文编译选项ENABLE_CHINESE_FULL" />
<MESSAGE value="中文" /> <MESSAGE value="中文" />
<MESSAGE value="fix show" /> <MESSAGE value="fix show" />
<option name="LAST_COMMIT_MESSAGE" value="fix show" /> <MESSAGE value="113" />
<option name="LAST_COMMIT_MESSAGE" value="113" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View file

@ -111,7 +111,7 @@ void AIRCOPY_StorePacket(void)
const uint16_t *pData = &g_FSK_Buffer[2]; const uint16_t *pData = &g_FSK_Buffer[2];
for (unsigned int i = 0; i < 8; i++) { for (unsigned int i = 0; i < 8; i++) {
EEPROM_WriteBuffer(Offset, pData); EEPROM_WriteBuffer(Offset, pData,8);
pData += 4; pData += 4;
Offset += 8; Offset += 8;
} }

View file

@ -125,7 +125,7 @@ void FM_EraseChannels(void)
memset(Template, 0xFF, sizeof(Template)); memset(Template, 0xFF, sizeof(Template));
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template); EEPROM_WriteBuffer(0x0E40 + (i * 8), Template,8);
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels)); memset(gFM_Channels, 0xFF, sizeof(gFM_Channels));
} }

View file

@ -80,7 +80,7 @@ void writeXtalFreqCal(const int32_t value, const bool update_eeprom)
// //
EEPROM_ReadBuffer(0x1F88, &misc, 8); EEPROM_ReadBuffer(0x1F88, &misc, 8);
misc.BK4819_XtalFreqLow = value; misc.BK4819_XtalFreqLow = value;
EEPROM_WriteBuffer(0x1F88, &misc); EEPROM_WriteBuffer(0x1F88, &misc,8);
} }
} }
#endif #endif

View file

@ -309,7 +309,7 @@ static void CMD_051D(const uint8_t *pBuffer) {
bReloadEeprom = true; bReloadEeprom = true;
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword) if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !bIsInLockScreen || pCmd->bAllowPassword)
EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U]); EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U],8);
} }
@ -615,9 +615,9 @@ static void CMD_0538(const uint8_t *pBuffer)//write
if ((Offset > 0xffff || Offset < 0x0E98 || (Offset <= 0xffff && Offset >= 0x0EA0)) || !bIsInLockScreen || if ((Offset > 0xffff || Offset < 0x0E98 || (Offset <= 0xffff && Offset >= 0x0EA0)) || !bIsInLockScreen ||
pCmd->bAllowPassword) { pCmd->bAllowPassword) {
if(add&&i==((pCmd->Size) - 2) / 8+(add==0?0:1)-1) if(add&&i==((pCmd->Size) - 2) / 8+(add==0?0:1)-1)
EEPROM_WriteBuffer_1024(Offset, &pCmd->Data[i * 8U + 2], add); EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U + 2], add);
else else
EEPROM_WriteBuffer_1024(Offset, &pCmd->Data[i * 8U + 2], 8); EEPROM_WriteBuffer(Offset, &pCmd->Data[i * 8U + 2], 8);
// uint8_t back[8]; // uint8_t back[8];
// EEPROM_ReadBuffer(Offset, back, 8); // EEPROM_ReadBuffer(Offset, back, 8);
// UART_Send(back, 8); // UART_Send(back, 8);

View file

@ -23,22 +23,7 @@
uint8_t WRITE_SIZE=0; uint8_t WRITE_SIZE=0;
void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size) { void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size) {
if(Size==0)return; if(Size==0)return;
if(Address<0x10000) {
I2C_Start();
I2C_Write(0xA0);
I2C_Write((Address >> 8) & 0xFF);
I2C_Write((Address >> 0) & 0xFF);
I2C_Start();
I2C_Write(0xA1);
I2C_ReadBuffer(pBuffer, Size);
I2C_Stop();
} else{
I2C_Start(); I2C_Start();
uint8_t P0 = (Address / 0x10000) << 1; uint8_t P0 = (Address / 0x10000) << 1;
@ -54,39 +39,19 @@ void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size) {
I2C_ReadBuffer(pBuffer, Size); I2C_ReadBuffer(pBuffer, Size);
I2C_Stop(); I2C_Stop();
}
} }
void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer) { void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer,uint8_t WRITE_SIZE) {
if (pBuffer == NULL ) if (pBuffer == NULL )
return; return;
if (Address < 0x10000) {
uint8_t buffer[8];
EEPROM_ReadBuffer(Address, buffer, 8);
if (memcmp(pBuffer, buffer, 8) == 0) {
return;
}
I2C_Start();
I2C_Write(0xA0);
I2C_Write((Address >> 8) & 0xFF);
I2C_Write((Address >> 0) & 0xFF);
I2C_WriteBuffer(pBuffer, 8);
I2C_Stop();
SYSTEM_DelayMs(8);
// give the EEPROM time to burn the data in (apparently takes 5ms)
}
}
void EEPROM_WriteBuffer_1024(uint32_t Address, const void *pBuffer,uint8_t WRITE_SIZE) {
uint8_t buffer[128]; uint8_t buffer[128];
EEPROM_ReadBuffer(Address, buffer, WRITE_SIZE); EEPROM_ReadBuffer(Address, buffer, WRITE_SIZE);
if (memcmp(pBuffer, buffer, WRITE_SIZE) != 0) { if (memcmp(pBuffer, buffer, WRITE_SIZE) != 0) {
uint8_t P0 = (Address / 0x10000) << 1; uint8_t P0 = (Address / 0x10000) << 1;
I2C_Start(); I2C_Start();
if(Address<0x10000) I2C_Write(0xA0); if(Address<0x10000) I2C_Write(0xA0);
else I2C_Write(0xA0 | P0); else I2C_Write(0xA0 | P0);
I2C_Write((Address >> 8) & 0xFF); I2C_Write((Address >> 8) & 0xFF);
I2C_Write((Address >> 0) & 0xFF); I2C_Write((Address >> 0) & 0xFF);

View file

@ -20,9 +20,8 @@
#include <stdint.h> #include <stdint.h>
void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size); void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size);
void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer); void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer,uint8_t WRITE_SIZE) ;
extern uint8_t WRITE_SIZE; extern uint8_t WRITE_SIZE;
void EEPROM_WriteBuffer_1024(uint32_t Address, const void *pBuffer,uint8_t WRITE_SIZE) ;
#endif #endif

BIN
firmware

Binary file not shown.

6
main.c
View file

@ -158,7 +158,7 @@ void Main(void) {
for (uint32_t i = 0; i < ALL_SIZE; i += 128) { for (uint32_t i = 0; i < ALL_SIZE; i += 128) {
if (i != (uint32_t) (ALL_SIZE / 128) * 128) { if (i != (uint32_t) (ALL_SIZE / 128) * 128) {
WRITE_SIZE = 128; WRITE_SIZE = 128;
EEPROM_WriteBuffer_1024(start_add + i, p_font + i, WRITE_SIZE); EEPROM_WriteBuffer(start_add + i, p_font + i, WRITE_SIZE);
//check //check
uint8_t B[128]; uint8_t B[128];
EEPROM_ReadBuffer(start_add + i, B, 128); EEPROM_ReadBuffer(start_add + i, B, 128);
@ -196,7 +196,7 @@ void Main(void) {
uint8_t tmp[128] = {0}; uint8_t tmp[128] = {0};
WRITE_SIZE = ALL_SIZE - (uint32_t) (ALL_SIZE / 128) * 128; WRITE_SIZE = ALL_SIZE - (uint32_t) (ALL_SIZE / 128) * 128;
memcpy(tmp, p_font + i, WRITE_SIZE); memcpy(tmp, p_font + i, WRITE_SIZE);
EEPROM_WriteBuffer_1024(start_add + i, tmp, WRITE_SIZE); EEPROM_WriteBuffer(start_add + i, tmp, WRITE_SIZE);
//check //check
uint8_t B[128]; uint8_t B[128];
memset(B, 0, sizeof(B)); memset(B, 0, sizeof(B));
@ -373,7 +373,7 @@ void Main(void) {
// uint32_t add=0; // uint32_t add=0;
// uint8_t data_write[8]; // uint8_t data_write[8];
// memset(data_write,'Z',sizeof (data_write)); // memset(data_write,'Z',sizeof (data_write));
// EEPROM_WriteBuffer_1024(start_add + add,data_write , WRITE_SIZE); // EEPROM_WriteBuffer(start_add + add,data_write , WRITE_SIZE);
// uint8_t B[128]; // uint8_t B[128];
// EEPROM_ReadBuffer(start_add + add, B, WRITE_SIZE); // EEPROM_ReadBuffer(start_add + add, B, WRITE_SIZE);
// if (memcmp(B, data_write, WRITE_SIZE) != 0) { // if (memcmp(B, data_write, WRITE_SIZE) != 0) {

View file

@ -269,8 +269,8 @@ EEPROM_ReadBuffer(0x0EF0, Data, sizeof(gEeprom.REVIVE_CODE));
// 0F30..0F3F // 0F30..0F3F
char B[8]; char B[8];
memset(B,0XFF,8); memset(B,0XFF,8);
EEPROM_WriteBuffer(0x0F30, B); EEPROM_WriteBuffer(0x0F30, B,8);
EEPROM_WriteBuffer(0x0F38, B); EEPROM_WriteBuffer(0x0F38, B,8);
EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey));
bHasCustomAesKey = false; bHasCustomAesKey = false;
@ -422,7 +422,7 @@ void SETTINGS_FactoryReset(bool bIsAll)
)) ))
) )
{ {
EEPROM_WriteBuffer(i, Template); EEPROM_WriteBuffer(i, Template,8);
} }
} }
@ -460,9 +460,9 @@ void SETTINGS_SaveFM(void)
State.Frequency = gEeprom.FM_SelectedFrequency; State.Frequency = gEeprom.FM_SelectedFrequency;
State.IsChannelSelected = gEeprom.FM_IsMrMode; State.IsChannelSelected = gEeprom.FM_IsMrMode;
EEPROM_WriteBuffer(0x0E88, &State); EEPROM_WriteBuffer(0x0E88, &State,8);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4]); EEPROM_WriteBuffer(0x0E40 + (i * 8), &gFM_Channels[i * 4],8);
} }
#endif #endif
@ -485,7 +485,7 @@ void SETTINGS_SaveVfoIndices(void)
State[7] = gEeprom.NoaaChannel[1]; State[7] = gEeprom.NoaaChannel[1];
#endif #endif
EEPROM_WriteBuffer(0x0E80, State); EEPROM_WriteBuffer(0x0E80, State,8);
} }
void SETTINGS_SaveSettings(void) void SETTINGS_SaveSettings(void)
@ -510,7 +510,7 @@ void SETTINGS_SaveSettings(void)
State[6] = 0; State[6] = 0;
#endif #endif
State[7] = gEeprom.MIC_SENSITIVITY; State[7] = gEeprom.MIC_SENSITIVITY;
EEPROM_WriteBuffer(0x0E70, State); EEPROM_WriteBuffer(0x0E70, State,8);
State[0] = (/*gEeprom.BACKLIGHT_MIN*/0 << 4) + gEeprom.BACKLIGHT_MAX; State[0] = (/*gEeprom.BACKLIGHT_MIN*/0 << 4) + gEeprom.BACKLIGHT_MAX;
State[1] = gEeprom.CHANNEL_DISPLAY_MODE; State[1] = gEeprom.CHANNEL_DISPLAY_MODE;
@ -520,7 +520,7 @@ void SETTINGS_SaveSettings(void)
State[5] = gEeprom.BACKLIGHT_TIME; State[5] = gEeprom.BACKLIGHT_TIME;
State[6] = gEeprom.TAIL_TONE_ELIMINATION; State[6] = gEeprom.TAIL_TONE_ELIMINATION;
State[7] = gEeprom.VFO_OPEN; State[7] = gEeprom.VFO_OPEN;
EEPROM_WriteBuffer(0x0E78, State); EEPROM_WriteBuffer(0x0E78, State,8);
State[0] = gEeprom.BEEP_CONTROL; State[0] = gEeprom.BEEP_CONTROL;
// State[0] |= 0;//gEeprom.KEY_M_LONG_PRESS_ACTION << 1; // State[0] |= 0;//gEeprom.KEY_M_LONG_PRESS_ACTION << 1;
@ -538,13 +538,13 @@ void SETTINGS_SaveSettings(void)
State[5] = gEeprom.SCAN_RESUME_MODE; State[5] = gEeprom.SCAN_RESUME_MODE;
State[6] = 0;//gEeprom.AUTO_KEYPAD_LOCK; State[6] = 0;//gEeprom.AUTO_KEYPAD_LOCK;
State[7] = 0;//gEeprom.POWER_ON_DISPLAY_MODE; State[7] = 0;//gEeprom.POWER_ON_DISPLAY_MODE;
EEPROM_WriteBuffer(0x0E90, State); EEPROM_WriteBuffer(0x0E90, State,8);
memset(Password, 0xFF, sizeof(Password)); memset(Password, 0xFF, sizeof(Password));
#ifdef ENABLE_PWRON_PASSWORD #ifdef ENABLE_PWRON_PASSWORD
Password[0] = gEeprom.POWER_ON_PASSWORD; Password[0] = gEeprom.POWER_ON_PASSWORD;
#endif #endif
EEPROM_WriteBuffer(0x0E98, Password); EEPROM_WriteBuffer(0x0E98, Password,8);
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -554,7 +554,7 @@ void SETTINGS_SaveSettings(void)
State[1] = gEeprom.S0_LEVEL; State[1] = gEeprom.S0_LEVEL;
State[2] = gEeprom.S9_LEVEL; State[2] = gEeprom.S9_LEVEL;
#endif #endif
EEPROM_WriteBuffer(0x0EA0, State); EEPROM_WriteBuffer(0x0EA0, State,8);
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
State[0] = gEeprom.ALARM_MODE; State[0] = gEeprom.ALARM_MODE;
#else #else
@ -564,7 +564,7 @@ void SETTINGS_SaveSettings(void)
State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION;
State[3] = gEeprom.TX_VFO; State[3] = gEeprom.TX_VFO;
State[4] = gEeprom.BATTERY_TYPE; State[4] = gEeprom.BATTERY_TYPE;
EEPROM_WriteBuffer(0x0EA8, State); EEPROM_WriteBuffer(0x0EA8, State,8);
State[0] = gEeprom.DTMF_SIDE_TONE; State[0] = gEeprom.DTMF_SIDE_TONE;
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
@ -576,7 +576,7 @@ void SETTINGS_SaveSettings(void)
State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U; State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U;
State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U; State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U;
State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U; State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U;
EEPROM_WriteBuffer(0x0ED0, State); EEPROM_WriteBuffer(0x0ED0, State,8);
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U; State[0] = gEeprom.DTMF_CODE_PERSIST_TIME / 10U;
@ -584,7 +584,7 @@ void SETTINGS_SaveSettings(void)
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
State[2] = gEeprom.PERMIT_REMOTE_KILL; State[2] = gEeprom.PERMIT_REMOTE_KILL;
#endif #endif
EEPROM_WriteBuffer(0x0ED8, State); EEPROM_WriteBuffer(0x0ED8, State,8);
State[0] = gEeprom.SCAN_LIST_DEFAULT; State[0] = gEeprom.SCAN_LIST_DEFAULT;
State[1] = gEeprom.SCAN_LIST_ENABLED[0]; State[1] = gEeprom.SCAN_LIST_ENABLED[0];
@ -594,7 +594,7 @@ void SETTINGS_SaveSettings(void)
State[5] = gEeprom.SCANLIST_PRIORITY_CH1[1]; State[5] = gEeprom.SCANLIST_PRIORITY_CH1[1];
State[6] = gEeprom.SCANLIST_PRIORITY_CH2[1]; State[6] = gEeprom.SCANLIST_PRIORITY_CH2[1];
State[7] = 0xFF; State[7] = 0xFF;
EEPROM_WriteBuffer(0x0F18, State); EEPROM_WriteBuffer(0x0F18, State,8);
memset(State, 0xFF, sizeof(State)); memset(State, 0xFF, sizeof(State));
State[0] = gSetting_F_LOCK; State[0] = gSetting_F_LOCK;
@ -615,7 +615,7 @@ void SETTINGS_SaveSettings(void)
#endif #endif
State[7] = (State[7] & ~(3u << 6)) | ((2 & 3u) << 6); State[7] = (State[7] & ~(3u << 6)) | ((2 & 3u) << 6);
EEPROM_WriteBuffer(0x0F40, State); EEPROM_WriteBuffer(0x0F40, State,8);
} }
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)
@ -640,7 +640,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
State._32[0] = pVFO->freq_config_RX.Frequency; State._32[0] = pVFO->freq_config_RX.Frequency;
State._32[1] = pVFO->TX_OFFSET_FREQUENCY; State._32[1] = pVFO->TX_OFFSET_FREQUENCY;
EEPROM_WriteBuffer(OffsetVFO + 0, State._32); EEPROM_WriteBuffer(OffsetVFO + 0, State._32,8);
State._8[0] = pVFO->freq_config_RX.Code; State._8[0] = pVFO->freq_config_RX.Code;
State._8[1] = pVFO->freq_config_TX.Code; State._8[1] = pVFO->freq_config_TX.Code;
@ -658,7 +658,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
; ;
State._8[6] = pVFO->STEP_SETTING; State._8[6] = pVFO->STEP_SETTING;
State._8[7] = pVFO->SCRAMBLING_TYPE; State._8[7] = pVFO->SCRAMBLING_TYPE;
EEPROM_WriteBuffer(OffsetVFO + 8, State._8); EEPROM_WriteBuffer(OffsetVFO + 8, State._8,8);
SETTINGS_UpdateChannel(Channel, pVFO, true); SETTINGS_UpdateChannel(Channel, pVFO, true);
@ -679,11 +679,11 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration) void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration)
{ {
uint16_t buf[4]; uint16_t buf[4];
EEPROM_WriteBuffer(0x1F40, batteryCalibration); EEPROM_WriteBuffer(0x1F40, batteryCalibration,8);
EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf)); EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = batteryCalibration[4]; buf[0] = batteryCalibration[4];
buf[1] = batteryCalibration[5]; buf[1] = batteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf); EEPROM_WriteBuffer(0x1F48, buf,8);
} }
void SETTINGS_SaveChannelName(uint8_t channel, const char * name) void SETTINGS_SaveChannelName(uint8_t channel, const char * name)
@ -691,8 +691,8 @@ void SETTINGS_SaveChannelName(uint8_t channel, const char * name)
uint16_t offset = channel * 16; uint16_t offset = channel * 16;
uint8_t buf[16] = {0}; uint8_t buf[16] = {0};
memcpy(buf, name, MIN(strlen(name), 10u)); memcpy(buf, name, MIN(strlen(name), 10u));
EEPROM_WriteBuffer(0x0F50 + offset, buf); EEPROM_WriteBuffer(0x0F50 + offset, buf,8);
EEPROM_WriteBuffer(0x0F58 + offset, buf + 8); EEPROM_WriteBuffer(0x0F58 + offset, buf + 8,8);
} }
void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep) void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
@ -722,7 +722,7 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep)
} }
state[channel & 7u] = att.__val; state[channel & 7u] = att.__val;
EEPROM_WriteBuffer(offset, state); EEPROM_WriteBuffer(offset, state,8);
gMR_ChannelAttributes[channel] = att; gMR_ChannelAttributes[channel] = att;
@ -781,5 +781,5 @@ void SETTINGS_WriteBuildOptions(void)
| (1 << 4) | (1 << 4)
#endif #endif
; ;
EEPROM_WriteBuffer(0x1FF0, buf); EEPROM_WriteBuffer(0x1FF0, buf,8);
} }