mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
Added version string sanity checking to prevent boot problems and serial comm problems
This commit is contained in:
parent
5755a92daa
commit
74d31a616f
147
app/app.c
147
app/app.c
@ -1499,6 +1499,41 @@ void APP_TimeSlice10ms(void)
|
|||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***********
|
||||||
|
|
||||||
|
if (g_flag_SaveVfo)
|
||||||
|
{
|
||||||
|
SETTINGS_SaveVfoIndices();
|
||||||
|
g_flag_SaveVfo = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_flag_SaveSettings)
|
||||||
|
{
|
||||||
|
SETTINGS_SaveSettings();
|
||||||
|
g_flag_SaveSettings = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (g_flag_SaveFM)
|
||||||
|
{
|
||||||
|
SETTINGS_SaveFM();
|
||||||
|
g_flag_SaveFM = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (g_flag_save_channel)
|
||||||
|
{
|
||||||
|
SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel);
|
||||||
|
g_flag_save_channel = false;
|
||||||
|
|
||||||
|
RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE);
|
||||||
|
RADIO_SetupRegisters(true);
|
||||||
|
|
||||||
|
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ***********
|
||||||
|
|
||||||
if (g_serial_config_count_down_500ms > 0)
|
if (g_serial_config_count_down_500ms > 0)
|
||||||
{ // config upload/download is running
|
{ // config upload/download is running
|
||||||
if (g_update_display)
|
if (g_update_display)
|
||||||
@ -1508,6 +1543,8 @@ void APP_TimeSlice10ms(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***********
|
||||||
|
|
||||||
#ifdef ENABLE_BOOT_BEEPS
|
#ifdef ENABLE_BOOT_BEEPS
|
||||||
if (g_boot_counter_10ms > 0 && (g_boot_counter_10ms % 25) == 0)
|
if (g_boot_counter_10ms > 0 && (g_boot_counter_10ms % 25) == 0)
|
||||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||||
@ -2240,7 +2277,8 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
// reset the state so as to remove it from the screen
|
// reset the state so as to remove it from the screen
|
||||||
if (Key != KEY_INVALID && Key != KEY_PTT)
|
if (Key != KEY_INVALID && Key != KEY_PTT)
|
||||||
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
|
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
|
||||||
|
/*
|
||||||
|
// remember the current backlight state (on / off)
|
||||||
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||||
|
|
||||||
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.backlight > 0)
|
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.backlight > 0)
|
||||||
@ -2249,15 +2287,30 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
g_beep_to_play = BEEP_NONE;
|
g_beep_to_play = BEEP_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// turn the backlight on
|
||||||
|
if (key_pressed)
|
||||||
|
if (Key != KEY_PTT || g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3)
|
||||||
|
backlight_turn_on();
|
||||||
|
|
||||||
if (g_current_function == FUNCTION_POWER_SAVE)
|
if (g_current_function == FUNCTION_POWER_SAVE)
|
||||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||||
|
|
||||||
|
// stay awake - for now
|
||||||
g_battery_save_count_down_10ms = battery_save_count_10ms;
|
g_battery_save_count_down_10ms = battery_save_count_10ms;
|
||||||
|
|
||||||
|
// keep the auto keylock at bay
|
||||||
if (g_eeprom.auto_keypad_lock)
|
if (g_eeprom.auto_keypad_lock)
|
||||||
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
|
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
|
||||||
|
|
||||||
|
if (g_fkey_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
|
||||||
|
{ // cancel the F-key
|
||||||
|
g_fkey_pressed = false;
|
||||||
|
g_update_status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ********************
|
||||||
|
|
||||||
if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
if (g_eeprom.key_lock && g_current_function != FUNCTION_TRANSMIT && Key != KEY_PTT)
|
||||||
{ // keyboard is locked
|
{ // keyboard is locked
|
||||||
|
|
||||||
@ -2288,61 +2341,26 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
if (!key_pressed || key_held)
|
if (!key_pressed || key_held)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
backlight_turn_on();
|
// keypad is locked, let the user know
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (!g_fm_radio_mode)
|
|
||||||
#endif
|
|
||||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
|
||||||
|
|
||||||
// keypad is locked, tell the user
|
|
||||||
g_keypad_locked = 4; // 2 second pop-up
|
g_keypad_locked = 4; // 2 second pop-up
|
||||||
g_update_display = true;
|
g_update_display = true;
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (!g_fm_radio_mode) // don't beep when the FM radio is on, it cause bad gaps and loud clicks
|
||||||
|
#endif
|
||||||
|
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!key_pressed)
|
// key beep
|
||||||
{
|
if (Key != KEY_PTT && !key_held && key_pressed)
|
||||||
if (g_flag_SaveVfo)
|
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||||
{
|
|
||||||
SETTINGS_SaveVfoIndices();
|
|
||||||
g_flag_SaveVfo = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_flag_SaveSettings)
|
// ********************
|
||||||
{
|
|
||||||
SETTINGS_SaveSettings();
|
|
||||||
g_flag_SaveSettings = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
if (Key == KEY_EXIT && key_held && key_pressed)
|
||||||
if (g_flag_SaveFM)
|
|
||||||
{
|
|
||||||
SETTINGS_SaveFM();
|
|
||||||
g_flag_SaveFM = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (g_flag_save_channel)
|
|
||||||
{
|
|
||||||
SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel);
|
|
||||||
g_flag_save_channel = false;
|
|
||||||
|
|
||||||
RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE);
|
|
||||||
RADIO_SetupRegisters(true);
|
|
||||||
|
|
||||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key_pressed)
|
|
||||||
{
|
|
||||||
if (Key != KEY_PTT || g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3)
|
|
||||||
backlight_turn_on();
|
|
||||||
|
|
||||||
if (Key == KEY_EXIT && key_held)
|
|
||||||
{ // exit key held pressed
|
{ // exit key held pressed
|
||||||
|
|
||||||
// clear the live DTMF decoder
|
// clear the live DTMF decoder
|
||||||
@ -2357,30 +2375,23 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
cancelUserInputModes();
|
cancelUserInputModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_screen_to_display == DISPLAY_MENU) // 1of11
|
if (key_pressed && g_screen_to_display == DISPLAY_MENU)
|
||||||
g_menu_count_down = menu_timeout_500ms;
|
g_menu_count_down = menu_timeout_500ms;
|
||||||
|
|
||||||
if (g_dtmf_decode_ring_count_down_500ms > 0)
|
// cancel the ringing
|
||||||
{ // cancel the ringing
|
if (key_pressed && g_dtmf_decode_ring_count_down_500ms > 0)
|
||||||
g_dtmf_decode_ring_count_down_500ms = 0;
|
g_dtmf_decode_ring_count_down_500ms = 0;
|
||||||
|
|
||||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
// ********************
|
||||||
|
|
||||||
if (Key != KEY_PTT)
|
|
||||||
{
|
|
||||||
// g_ptt_was_released = true; // why is this being set ?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||||
|
|
||||||
|
if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||||
|
{ // FREQ/CTCSS/CDCSS scanning
|
||||||
|
|
||||||
if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F)
|
if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F)
|
||||||
{
|
{
|
||||||
if (g_scan_state_dir != SCAN_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
|
||||||
{ // FREQ/CTCSS/DCS scanning
|
|
||||||
if (key_pressed && !key_held)
|
if (key_pressed && !key_held)
|
||||||
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
|
||||||
return;
|
return;
|
||||||
@ -2389,6 +2400,8 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
// ********************
|
||||||
|
|
||||||
if (Key == KEY_PTT && g_ptt_was_pressed)
|
if (Key == KEY_PTT && g_ptt_was_pressed)
|
||||||
{
|
{
|
||||||
flag = key_held;
|
flag = key_held;
|
||||||
@ -2400,12 +2413,11 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this bit of code has caused soooooo many problems due
|
// this bit of code has caused soooooo many problems due
|
||||||
// to this causing key releases to be totally ignored :( .. 1of11
|
// to this causing key releases to be ignored :( .. 1of11
|
||||||
if (Key != KEY_PTT && g_ptt_was_released)
|
if (Key != KEY_PTT && g_ptt_was_released)
|
||||||
{
|
{
|
||||||
if (key_held)
|
if (key_held)
|
||||||
flag = true;
|
flag = true;
|
||||||
// if (!key_pressed)
|
|
||||||
if (key_pressed) // I now use key released for button press detections
|
if (key_pressed) // I now use key released for button press detections
|
||||||
{
|
{
|
||||||
flag = true;
|
flag = true;
|
||||||
@ -2417,17 +2429,11 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_fkey_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
|
|
||||||
{ // cancel the F-key
|
|
||||||
g_fkey_pressed = false;
|
|
||||||
g_update_status = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
UART_printf("proc key 2 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
|
UART_printf("proc key 2 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!flag)
|
if (!flag) // this flag is responsible for keys being ignored :(
|
||||||
{
|
{
|
||||||
if (g_current_function == FUNCTION_TRANSMIT)
|
if (g_current_function == FUNCTION_TRANSMIT)
|
||||||
{ // transmitting
|
{ // transmitting
|
||||||
@ -2515,7 +2521,6 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
|
|||||||
{
|
{
|
||||||
case DISPLAY_MAIN:
|
case DISPLAY_MAIN:
|
||||||
MAIN_ProcessKeys(Key, key_pressed, key_held);
|
MAIN_ProcessKeys(Key, key_pressed, key_held);
|
||||||
// key_held = false; // allow the channel setting to be saved
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
|
@ -206,10 +206,14 @@ static void SendVersion(void)
|
|||||||
{
|
{
|
||||||
reply_0514_t reply;
|
reply_0514_t reply;
|
||||||
|
|
||||||
|
unsigned int slen = strlen(Version_str);
|
||||||
|
if (slen > (sizeof(reply.Data.Version) - 1))
|
||||||
|
slen = sizeof(reply.Data.Version) - 1;
|
||||||
|
|
||||||
memset(&reply, 0, sizeof(reply));
|
memset(&reply, 0, sizeof(reply));
|
||||||
reply.Header.ID = 0x0515;
|
reply.Header.ID = 0x0515;
|
||||||
reply.Header.Size = sizeof(reply.Data);
|
reply.Header.Size = sizeof(reply.Data);
|
||||||
strcpy(reply.Data.Version, Version);
|
memmove(reply.Data.Version, Version_str, slen);
|
||||||
reply.Data.has_custom_aes_key = g_has_custom_aes_key;
|
reply.Data.has_custom_aes_key = g_has_custom_aes_key;
|
||||||
reply.Data.password_locked = g_password_locked;
|
reply.Data.password_locked = g_password_locked;
|
||||||
reply.Data.Challenge[0] = g_challenge[0];
|
reply.Data.Challenge[0] = g_challenge[0];
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
2
main.c
2
main.c
@ -71,7 +71,7 @@ void Main(void)
|
|||||||
g_boot_counter_10ms = 250; // 2.5 sec
|
g_boot_counter_10ms = 250; // 2.5 sec
|
||||||
|
|
||||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||||
UART_SendText(UART_Version);
|
UART_SendText(UART_Version_str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Not implementing authentic device checks
|
// Not implementing authentic device checks
|
||||||
|
44
ui/welcome.c
44
ui/welcome.c
@ -41,9 +41,9 @@ void UI_DisplayReleaseKeys(void)
|
|||||||
|
|
||||||
void UI_DisplayWelcome(void)
|
void UI_DisplayWelcome(void)
|
||||||
{
|
{
|
||||||
char WelcomeString0[16];
|
char str0[17];
|
||||||
char WelcomeString1[16];
|
char str1[17];
|
||||||
char WelcomeString2[16];
|
char str2[17];
|
||||||
|
|
||||||
memset(g_status_line, 0, sizeof(g_status_line));
|
memset(g_status_line, 0, sizeof(g_status_line));
|
||||||
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
|
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
|
||||||
@ -59,34 +59,38 @@ void UI_DisplayWelcome(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(WelcomeString0, 0, sizeof(WelcomeString0));
|
unsigned int slen = strlen(Version_str);
|
||||||
memset(WelcomeString1, 0, sizeof(WelcomeString1));
|
if (slen > (sizeof(str2) - 1))
|
||||||
memset(WelcomeString2, 0, sizeof(WelcomeString2));
|
slen = sizeof(str2) - 1;
|
||||||
|
|
||||||
|
memset(str0, 0, sizeof(str0));
|
||||||
|
memset(str1, 0, sizeof(str1));
|
||||||
|
memset(str2, 0, sizeof(str2));
|
||||||
|
|
||||||
if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_VOLTAGE)
|
if (g_eeprom.pwr_on_display_mode == PWR_ON_DISPLAY_MODE_VOLTAGE)
|
||||||
{
|
{
|
||||||
strcpy(WelcomeString0, "VOLTAGE");
|
strcpy(str0, "VOLTAGE");
|
||||||
sprintf(WelcomeString1, "%u.%02uV %u%%",
|
sprintf(str1, "%u.%02uV %u%%",
|
||||||
g_battery_voltage_average / 100,
|
g_battery_voltage_average / 100,
|
||||||
g_battery_voltage_average % 100,
|
g_battery_voltage_average % 100,
|
||||||
BATTERY_VoltsToPercent(g_battery_voltage_average));
|
BATTERY_VoltsToPercent(g_battery_voltage_average));
|
||||||
|
|
||||||
#if 0
|
|
||||||
sprintf(WelcomeString2, "Current %u", g_usb_current); // needs scaling into mA
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EEPROM_ReadBuffer(0x0EB0, WelcomeString0, 16);
|
EEPROM_ReadBuffer(0x0EB0, str0, 16);
|
||||||
EEPROM_ReadBuffer(0x0EC0, WelcomeString1, 16);
|
EEPROM_ReadBuffer(0x0EC0, str1, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_PrintString(WelcomeString0, 0, 127, 0, 10);
|
memmove(str2, Version_str, slen);
|
||||||
UI_PrintString(WelcomeString1, 0, 127, 2, 10);
|
|
||||||
#if 0
|
UI_PrintString(str0, 0, 127, 0, 10);
|
||||||
UI_PrintStringSmall(WelcomeString2, 0, 127, 4);
|
UI_PrintString(str1, 0, 127, 2, 10);
|
||||||
#endif
|
|
||||||
UI_PrintString(Version, 0, 127, 5, 10);
|
if (strlen(str2) <= 12)
|
||||||
|
UI_PrintString(str2, 0, 127, 5, 10);
|
||||||
|
else
|
||||||
|
UI_PrintStringSmallBold(str2, 0, 127, 5);
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
ST7565_BlitStatusLine(); // blank status line
|
ST7565_BlitStatusLine(); // blank status line
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_OF_ELEVEN_VER
|
#ifndef ONE_OF_ELEVEN_VER
|
||||||
const char Version[] = "OEFW-"VER;
|
const char Version_str[] = "OEFW-"VER;
|
||||||
const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n";
|
const char UART_Version_str[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n";
|
||||||
#else
|
#else
|
||||||
const char Version[] = "1o11-"VER;
|
const char Version_str[] = "1o11-"VER;
|
||||||
const char UART_Version[] = "UV-K5 Firmware, Open Edition, 1o11-"VER"\r\n";
|
const char UART_Version_str[] = "UV-K5 Firmware, Open Edition, 1o11-"VER"\r\n";
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user