0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

new eeprom structure array (not yet used)

This commit is contained in:
OneOfEleven 2023-10-13 23:27:54 +01:00
parent f35deba315
commit 8fb57d9d19
12 changed files with 329 additions and 50 deletions

View File

@ -148,7 +148,7 @@ void ACTION_Scan(bool bRestart)
g_fm_auto_scan = true; g_fm_auto_scan = true;
g_fm_channel_position = 0; g_fm_channel_position = 0;
Frequency = g_eeprom.fm_lower_limit; Frequency = FM_RADIO_BAND.lower;
} }
else else
{ {

View File

@ -425,7 +425,7 @@ void DTMF_Reply(void)
} }
// send TX-UP DTMF // send TX-UP DTMF
pString = g_eeprom.dtmf_up_code; pString = g_eeprom.dtmf_key_up_code;
break; break;
} }

View File

@ -137,11 +137,11 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool flag)
if (!flag) if (!flag)
{ {
Frequency += Step; Frequency += Step;
if (Frequency < g_eeprom.fm_lower_limit) if (Frequency < FM_RADIO_BAND.lower)
Frequency = g_eeprom.fm_upper_limit; Frequency = FM_RADIO_BAND.upper;
else else
if (Frequency > g_eeprom.fm_upper_limit) if (Frequency > FM_RADIO_BAND.upper)
Frequency = g_eeprom.fm_lower_limit; Frequency = FM_RADIO_BAND.lower;
g_eeprom.fm_frequency_playing = Frequency; g_eeprom.fm_frequency_playing = Frequency;
} }
@ -288,7 +288,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
Frequency /= 10000; Frequency /= 10000;
if (Frequency < g_eeprom.fm_lower_limit || g_eeprom.fm_upper_limit < Frequency) if (Frequency < FM_RADIO_BAND.lower || Frequency > FM_RADIO_BAND.upper)
{ {
g_request_display_screen = DISPLAY_FM; g_request_display_screen = DISPLAY_FM;
return; return;
@ -587,11 +587,11 @@ static void FM_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Step)
else else
{ // no, frequency mode { // no, frequency mode
uint16_t Frequency = g_eeprom.fm_selected_frequency + Step; uint16_t Frequency = g_eeprom.fm_selected_frequency + Step;
if (Frequency < g_eeprom.fm_lower_limit) if (Frequency < FM_RADIO_BAND.lower)
Frequency = g_eeprom.fm_upper_limit; Frequency = FM_RADIO_BAND.upper;
else else
if (Frequency > g_eeprom.fm_upper_limit) if (Frequency > FM_RADIO_BAND.upper)
Frequency = g_eeprom.fm_lower_limit; Frequency = FM_RADIO_BAND.lower;
g_eeprom.fm_frequency_playing = Frequency; g_eeprom.fm_frequency_playing = Frequency;
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
@ -649,7 +649,7 @@ void FM_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
void FM_Play(void) void FM_Play(void)
{ {
if (!FM_CheckFrequencyLock(g_eeprom.fm_frequency_playing, g_eeprom.fm_lower_limit)) if (!FM_CheckFrequencyLock(g_eeprom.fm_frequency_playing, FM_RADIO_BAND.lower))
{ {
if (!g_fm_auto_scan) if (!g_fm_auto_scan)
{ {
@ -677,7 +677,7 @@ void FM_Play(void)
} }
} }
if (g_fm_auto_scan && g_eeprom.fm_frequency_playing >= g_eeprom.fm_upper_limit) if (g_fm_auto_scan && g_eeprom.fm_frequency_playing >= FM_RADIO_BAND.upper)
FM_PlayAndUpdate(); FM_PlayAndUpdate();
else else
FM_Tune(g_eeprom.fm_frequency_playing, g_fm_scan_state, false); FM_Tune(g_eeprom.fm_frequency_playing, g_fm_scan_state, false);

View File

@ -351,11 +351,11 @@ static void cmd_051D(const uint8_t *pBuffer)
#endif #endif
#ifdef ENABLE_PWRON_PASSWORD #ifdef ENABLE_PWRON_PASSWORD
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !g_password_locked || pCmd->allow_password) if ((Offset < 0x0E98 || Offset >= 0x0E9C) || !g_password_locked || pCmd->allow_password)
EEPROM_WriteBuffer(Offset, data); EEPROM_WriteBuffer(Offset, data);
#else #else
if (Offset == 0x0E90) if (Offset == 0x0E98)
memset(data + 8, 0xff, 4); // wipe the password memset(data, 0xff, 4); // wipe the password
EEPROM_WriteBuffer(Offset, data); EEPROM_WriteBuffer(Offset, data);
#endif #endif
} }

18
board.c
View File

@ -573,9 +573,7 @@ void BOARD_EEPROM_load(void)
} __attribute__((packed)) FM; } __attribute__((packed)) FM;
EEPROM_ReadBuffer(0x0E88, &FM, 8); EEPROM_ReadBuffer(0x0E88, &FM, 8);
g_eeprom.fm_lower_limit = 760; if (FM.SelectedFrequency < FM_RADIO_BAND.lower || FM.SelectedFrequency > FM_RADIO_BAND.upper)
g_eeprom.fm_upper_limit = 1080;
if (FM.SelectedFrequency < g_eeprom.fm_lower_limit || FM.SelectedFrequency > g_eeprom.fm_upper_limit)
g_eeprom.fm_selected_frequency = 960; g_eeprom.fm_selected_frequency = 960;
else else
g_eeprom.fm_selected_frequency = FM.SelectedFrequency; g_eeprom.fm_selected_frequency = FM.SelectedFrequency;
@ -624,9 +622,11 @@ void BOARD_EEPROM_load(void)
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
g_eeprom.alarm_mode = (array.alarm_mode < 2) ? array.alarm_mode : true; g_eeprom.alarm_mode = (array.alarm_mode < 2) ? array.alarm_mode : true;
#endif #endif
g_eeprom.roger_mode = (array.roger_mode < 3) ? array.roger_mode : ROGER_MODE_OFF; g_eeprom.roger_mode = (array.roger_mode < 3) ? array.roger_mode : ROGER_MODE_OFF;
g_eeprom.repeater_tail_tone_elimination = (array.repeater_tail_tone_elimination < 11) ? array.repeater_tail_tone_elimination : 0; g_eeprom.repeater_tail_tone_elimination = (array.repeater_tail_tone_elimination < 11) ? array.repeater_tail_tone_elimination : 0;
g_eeprom.tx_vfo = (array.tx_vfo < 2) ? array.tx_vfo : 0; g_eeprom.tx_vfo = (array.tx_vfo < 2) ? array.tx_vfo : 0;
#ifdef ENABLE_AIRCOPY_FREQ #ifdef ENABLE_AIRCOPY_FREQ
{ {
unsigned int i; unsigned int i;
@ -692,21 +692,21 @@ void BOARD_EEPROM_load(void)
// 0EF8..0F07 // 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16); EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(g_eeprom.dtmf_up_code, Data, 16); memmove(g_eeprom.dtmf_key_up_code, Data, 16);
else else
{ {
memset(g_eeprom.dtmf_up_code, 0, sizeof(g_eeprom.dtmf_up_code)); memset(g_eeprom.dtmf_key_up_code, 0, sizeof(g_eeprom.dtmf_key_up_code));
strcpy(g_eeprom.dtmf_up_code, "12345"); strcpy(g_eeprom.dtmf_key_up_code, "12345");
} }
// 0F08..0F17 // 0F08..0F17
EEPROM_ReadBuffer(0x0F08, Data, 16); EEPROM_ReadBuffer(0x0F08, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(g_eeprom.dtmf_down_code, Data, 16); memmove(g_eeprom.dtmf_key_down_code, Data, 16);
else else
{ {
memset(g_eeprom.dtmf_down_code, 0, sizeof(g_eeprom.dtmf_down_code)); memset(g_eeprom.dtmf_key_down_code, 0, sizeof(g_eeprom.dtmf_key_down_code));
strcpy(g_eeprom.dtmf_down_code, "54321"); strcpy(g_eeprom.dtmf_key_down_code, "54321");
} }
// 0F18..0F1F // 0F18..0F1F

Binary file not shown.

Binary file not shown.

View File

@ -21,6 +21,9 @@
// the default AIRCOPY frequency to use // the default AIRCOPY frequency to use
uint32_t g_aircopy_freq = 41002500; uint32_t g_aircopy_freq = 41002500;
// FM broadcast band lower/upper limit
const freq_band_table_t FM_RADIO_BAND = {760, 1080};
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz // the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
const freq_band_table_t BX4819_BAND1 = { 1800000, 63000000}; const freq_band_table_t BX4819_BAND1 = { 1800000, 63000000};
const freq_band_table_t BX4819_BAND2 = {84000000, 130000000}; const freq_band_table_t BX4819_BAND2 = {84000000, 130000000};

View File

@ -40,6 +40,8 @@ typedef struct {
extern uint32_t g_aircopy_freq; extern uint32_t g_aircopy_freq;
extern const freq_band_table_t FM_RADIO_BAND;
extern const freq_band_table_t BX4819_BAND1; extern const freq_band_table_t BX4819_BAND1;
extern const freq_band_table_t BX4819_BAND2; extern const freq_band_table_t BX4819_BAND2;

View File

@ -248,6 +248,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data)); EEPROM_ReadBuffer(Base + 8, Data, sizeof(Data));
g_eeprom.vfo_info[VFO].freq_config_rx.code_type = (Data[2] >> 0) & 0x0F;
g_eeprom.vfo_info[VFO].freq_config_tx.code_type = (Data[2] >> 4) & 0x0F;
Tmp = Data[3] & 0x0F; Tmp = Data[3] & 0x0F;
if (Tmp > TX_OFFSET_FREQ_DIR_SUB) if (Tmp > TX_OFFSET_FREQ_DIR_SUB)
Tmp = 0; Tmp = 0;
@ -265,9 +268,6 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
Tmp = 0; Tmp = 0;
g_eeprom.vfo_info[VFO].scrambling_type = Tmp; g_eeprom.vfo_info[VFO].scrambling_type = Tmp;
g_eeprom.vfo_info[VFO].freq_config_rx.code_type = (Data[2] >> 0) & 0x0F;
g_eeprom.vfo_info[VFO].freq_config_tx.code_type = (Data[2] >> 4) & 0x0F;
Tmp = Data[0]; Tmp = Data[0];
switch (g_eeprom.vfo_info[VFO].freq_config_rx.code_type) switch (g_eeprom.vfo_info[VFO].freq_config_rx.code_type)
{ {
@ -1104,7 +1104,7 @@ void RADIO_SendEndOfTransmission(void)
BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone); BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone);
BK4819_PlayDTMFString( BK4819_PlayDTMFString(
g_eeprom.dtmf_down_code, g_eeprom.dtmf_key_down_code,
0, 0,
g_eeprom.dtmf_first_code_persist_time, g_eeprom.dtmf_first_code_persist_time,
g_eeprom.dtmf_hash_code_persist_time, g_eeprom.dtmf_hash_code_persist_time,

View File

@ -114,6 +114,282 @@ enum mdf_display_mode_e {
}; };
typedef enum mdf_display_mode_e mdf_display_mode_t; typedef enum mdf_display_mode_e mdf_display_mode_t;
// ************************************************
typedef struct {
// [0]
uint8_t rx_ctcss_cdcss_code;
// [1]
uint8_t tx_ctcss_cdcss_code;
// [2]
uint8_t rx_code_type:4;
uint8_t tx_code_type:4;
// [3]
uint8_t tx_offset_dir:4;
uint8_t unused1:4;
// [4]
uint8_t frequency_reverse:1;
uint8_t channel_bandwidth:1;
uint8_t tx_power:2;
uint8_t busy_channel_lockout:1;
uint8_t unused2:3;
// [5]
uint8_t dtmf_decoding_enable:1;
uint8_t dtmf_ptt_id_tx_mode:3;
uint8_t unused3:4;
// [6]
uint8_t step_setting;
// [7]
uint8_t scrambler;
// [8]
uint32_t frequency;
// [12]
uint32_t offset;
} __attribute__((packed)) t_channel;
// 512 bytes
typedef struct {
// 0x1E00
struct {
uint8_t open_rssi_thresh[10];
uint8_t unused1[6];
uint8_t close_rssi_thresh[10];
uint8_t unused2[6];
uint8_t open_noise_thresh[10];
uint8_t unused3[6];
uint8_t close_noise_thresh[10];
uint8_t unused4[6];
uint8_t open_glitch_thresh[10];
uint8_t unused5[6];
uint8_t close_glitch_thresh[10];
uint8_t unused6[6];
} __attribute__((packed)) uhf_squelch[6];
// 0x1E60
struct {
uint8_t open_rssi_thresh[10];
uint8_t unused1[6];
uint8_t close_rssi_thresh[10];
uint8_t unused2[6];
uint8_t open_noise_thresh[10];
uint8_t unused3[6];
uint8_t close_noise_thresh[10];
uint8_t unused4[6];
uint8_t open_glitch_thresh[10];
uint8_t unused5[6];
uint8_t close_glitch_thresh[10];
uint8_t unused6[6];
} __attribute__((packed)) vhf_squelch[6];
// 0x1EC0
uint16_t unknown1[4];
uint16_t rssi[4];
// 0x1ED0
struct
{
uint8_t low_tx_pwr[3];
uint8_t mid_tx_pwr[3];
uint8_t high_tx_pwr[3];
uint8_t unused[7];
} band_setting[7];
// 0x1F40
uint16_t battery[6];
uint8_t unused1[4];
// 0x1F50
struct
{
uint16_t threshold[10];
uint8_t unused[4];
} __attribute__((packed)) vox[2];
// 0x1F80
uint8_t mic_gain_dB2[5];
uint8_t unused4[3];
// 0x1F88
int16_t bk4819_xtal_freq_low;
uint16_t unknown2;
uint16_t unknown3;
uint8_t volume_gain;
uint8_t dac_gain;
uint8_t unused5[8 * 10];
} __attribute__((packed)) t_calibration;
typedef struct {
// 0x0000
t_channel channel[200];
// 0xC80
t_channel vfo[14];
// 0x0D60
struct {
uint8_t band:4;
uint8_t compander:2;
uint8_t scanlist2:1;
uint8_t scanlist1:1;
} __attribute__((packed)) channel_attr[200];
uint8_t unused1[8];
uint8_t unused2[16];
// 0x0E40
uint16_t fm_channel[20];
uint8_t unused3[8];
// 0x0E70
uint8_t call1;
uint8_t squelch;
uint8_t tot;
uint8_t noaa_auto_scan;
uint8_t key_lock;
uint8_t vox_switch;
uint8_t vox_level;
uint8_t mic_sensitivity;
uint8_t unused4;
uint8_t mdf;
uint8_t wx;
uint8_t battery_save;
uint8_t tdr;
uint8_t backlight;
uint8_t site;
uint8_t vfo_open;
// 0x0E80
uint8_t screen_channel_a;
uint8_t channel_a;
uint8_t freq_channel_a;
uint8_t screen_channel_b;
uint8_t channel_b;
uint8_t freq_channel_b;
uint8_t noaa_channel_a;
uint8_t noaa_channel_b;
uint8_t fm_selected_frequency;
uint8_t fm_selected_channel;
uint8_t fm_is_channel_mode;
uint8_t unused5[5];
// 0x0E90
uint8_t beep_control;
uint8_t key1_short;
uint8_t key1_long;
uint8_t key2_short;
uint8_t key2_long;
uint8_t sc_rev;
uint8_t auto_lock;
uint8_t display_mode;
uint32_t power_on_password;
uint8_t unused6[4];
// 0x0EA0
uint8_t voice_prompt;
uint8_t unused7[7];
uint8_t alarm_mode;
uint8_t roger_mode;
uint8_t rp_ste;
uint8_t tx_channel;
uint8_t unused8[4];
// 0x0EB0
uint8_t welcome_line1[16];
uint8_t welcome_line2[16];
// 0x0ED0
uint8_t dtmf_side_tone;
uint8_t dtmf_separate_code;
uint8_t dtmf_group_call_code;
uint8_t dtmf_rsp;
uint8_t dtmf_auto_reset_time;
uint8_t dtmf_preload_time;
uint8_t dtmf_first_code_time;
uint8_t dtmf_hash_code_time;
uint8_t dtmf_code_time;
uint8_t dtmf_code_interval;
uint8_t dtmf_permit_kill;
uint8_t unused9[5];
// 0x0EE0
uint8_t dtmf_ani_id[8];
uint8_t dtmf_kill_code[8];
uint8_t dtmf_revive_code[8];
uint8_t dtmf_key_up_code[16];
uint8_t dtmf_key_down_code[16];
uint8_t s_list_default;
uint8_t scanlist1_enable;
uint8_t scanlist1_channel1;
uint8_t scanlist1_channel2;
uint8_t scanlist2_enable;
uint8_t scanlist2_channel1;
uint8_t scanlist2_channel2;
uint8_t unused10;
// 0x0F20
uint8_t unused11[8];
// 0x0F30
uint8_t aes_key[16];
// 0x0F40
uint8_t f_lock;
uint8_t enable_tx_350;
uint8_t killed;
uint8_t enable_tx_200;
uint8_t enable_tx_500;
uint8_t enable_350;
uint8_t enable_scrambler;
#if 0
// QS
uint8_t unused12[9];
#else
// 1of11
uint8_t tx_enable:1;
uint8_t dtmf_live_decoder:1;
uint8_t battery_text:2;
uint8_t mic_bar:1;
uint8_t am_fix:1;
uint8_t backlight_on_tx_rx:2;
uint8_t unused12[8];
#endif
// 0x0F50
char channel_name[200][16];
// 0x1BD0
uint8_t unused13[16];
uint8_t unused14[16];
uint8_t unused15[16];
// 0x1C00
uint8_t dtmf_contact[16][16];
// 0x1D00
uint8_t unused16[16 * 16];
// 0x1E00
t_calibration calibration;
} __attribute__((packed)) t_eeprom;
// ************************************************
typedef struct { typedef struct {
uint8_t screen_channel[2]; uint8_t screen_channel[2];
uint8_t freq_channel[2]; uint8_t freq_channel[2];
@ -132,8 +408,6 @@ typedef struct {
uint8_t fm_selected_channel; uint8_t fm_selected_channel;
bool fm_is_channel_mode; bool fm_is_channel_mode;
uint16_t fm_frequency_playing; uint16_t fm_frequency_playing;
uint16_t fm_lower_limit;
uint16_t fm_upper_limit;
#endif #endif
uint8_t squelch_level; uint8_t squelch_level;
@ -182,8 +456,8 @@ typedef struct {
char ani_dtmf_id[8]; char ani_dtmf_id[8];
char kill_code[8]; char kill_code[8];
char revive_code[8]; char revive_code[8];
char dtmf_up_code[16]; char dtmf_key_up_code[16];
char dtmf_down_code[16]; char dtmf_key_down_code[16];
uint8_t field57_0x6c; uint8_t field57_0x6c;
uint8_t field58_0x6d; uint8_t field58_0x6d;

View File

@ -878,12 +878,12 @@ void UI_DisplayMenu(void)
case MENU_UPCODE: case MENU_UPCODE:
strcpy(String, "PTT DTMF\nBEGIN\n"); strcpy(String, "PTT DTMF\nBEGIN\n");
strcat(String, g_eeprom.dtmf_up_code); strcat(String, g_eeprom.dtmf_key_up_code);
break; break;
case MENU_DWCODE: case MENU_DWCODE:
strcpy(String, "PTT DTMF\nEND\n"); strcpy(String, "PTT DTMF\nEND\n");
strcat(String, g_eeprom.dtmf_down_code); strcat(String, g_eeprom.dtmf_key_down_code);
break; break;
case MENU_D_RSP: case MENU_D_RSP:
@ -1148,12 +1148,12 @@ void UI_DisplayMenu(void)
UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8); UI_PrintString("SCAN", menu_item_x1, menu_item_x2, 4, 8);
if (g_menu_cursor == MENU_UPCODE) if (g_menu_cursor == MENU_UPCODE)
if (strlen(g_eeprom.dtmf_up_code) > 8) if (strlen(g_eeprom.dtmf_key_up_code) > 8)
UI_PrintString(g_eeprom.dtmf_up_code + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(g_eeprom.dtmf_key_up_code + 8, menu_item_x1, menu_item_x2, 4, 8);
if (g_menu_cursor == MENU_DWCODE) if (g_menu_cursor == MENU_DWCODE)
if (strlen(g_eeprom.dtmf_down_code) > 8) if (strlen(g_eeprom.dtmf_key_down_code) > 8)
UI_PrintString(g_eeprom.dtmf_down_code + 8, menu_item_x1, menu_item_x2, 4, 8); UI_PrintString(g_eeprom.dtmf_key_down_code + 8, menu_item_x1, menu_item_x2, 4, 8);
if (g_menu_cursor == MENU_R_CTCS || if (g_menu_cursor == MENU_R_CTCS ||
g_menu_cursor == MENU_T_CTCS || g_menu_cursor == MENU_T_CTCS ||