mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-27 22:01:26 +03:00
Lots n lots
This commit is contained in:
parent
230fdccf10
commit
f3e347bc5a
16
Makefile
16
Makefile
@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0
|
||||
ENABLE_LTO := 1
|
||||
# UART Programming 2.9 kB
|
||||
ENABLE_UART := 1
|
||||
ENABLE_UART_DEBUG := 1
|
||||
ENABLE_UART_DEBUG := 0
|
||||
# AirCopy 2.5 kB
|
||||
ENABLE_AIRCOPY := 0
|
||||
ENABLE_AIRCOPY_REMEMBER_FREQ := 1
|
||||
@ -32,13 +32,16 @@ ENABLE_VOX := 0
|
||||
ENABLE_REDUCE_LOW_MID_TX_POWER := 1
|
||||
# Tx Alarm 0.6 kB
|
||||
ENABLE_ALARM := 0
|
||||
ENABLE_TX1750 := 0
|
||||
ENABLE_TX1750 := 1
|
||||
# MDC1200 2.8 kB
|
||||
ENABLE_MDC1200 := 1
|
||||
ENABLE_PWRON_PASSWORD := 0
|
||||
ENABLE_RESET_AES_KEY := 1
|
||||
ENABLE_BIG_FREQ := 0
|
||||
ENABLE_SMALL_BOLD := 0
|
||||
# smaa bolf 580 B
|
||||
ENABLE_SMALL_BOLD := 1
|
||||
# smallest font 2 kB
|
||||
ENABLE_SMALLEST_FONT := 0
|
||||
# trim trailing 0.044 kB
|
||||
ENABLE_TRIM_TRAILING_ZEROS := 1
|
||||
ENABLE_KEEP_MEM_NAME := 1
|
||||
@ -51,6 +54,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_CONTRAST := 0
|
||||
ENABLE_BOOT_BEEPS := 0
|
||||
ENABLE_DTMF_CALL_FLASH_LIGHT := 1
|
||||
ENABLE_FLASH_LIGHT_SOS_TONE := 1
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1
|
||||
ENABLE_FREQ_SEARCH_TIMEOUT := 0
|
||||
@ -322,6 +326,9 @@ endif
|
||||
ifeq ($(ENABLE_SMALL_BOLD),1)
|
||||
CFLAGS += -DENABLE_SMALL_BOLD
|
||||
endif
|
||||
ifeq ($(ENABLE_SMALLEST_FONT),1)
|
||||
CFLAGS += -DENABLE_SMALLEST_FONT
|
||||
endif
|
||||
ifeq ($(ENABLE_TRIM_TRAILING_ZEROS),1)
|
||||
CFLAGS += -DENABLE_TRIM_TRAILING_ZEROS
|
||||
endif
|
||||
@ -382,6 +389,9 @@ endif
|
||||
ifeq ($(ENABLE_DTMF_CALL_FLASH_LIGHT),1)
|
||||
CFLAGS += -DENABLE_DTMF_CALL_FLASH_LIGHT
|
||||
endif
|
||||
ifeq ($(ENABLE_FLASH_LIGHT_SOS_TONE),1)
|
||||
CFLAGS += -DENABLE_FLASH_LIGHT_SOS_TONE
|
||||
endif
|
||||
ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1)
|
||||
CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL
|
||||
endif
|
||||
|
@ -70,6 +70,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0 standard CTCSS tail phase shift rath
|
||||
ENABLE_CONTRAST := 0 add contrast menu
|
||||
ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up
|
||||
ENABLE_DTMF_CALL_FLASH_LIGHT := 1 flash the flash light LED when a DTMF call is received
|
||||
ENABLE_FLASH_LIGHT_SOS_TONE := 1 also do SOS in morse
|
||||
ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge
|
||||
ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right)
|
||||
ENABLE_FREQ_SEARCH_TIMEOUT := 0 timeout if FREQ not found when using F+4 search function
|
||||
|
1
am_fix.c
1
am_fix.c
@ -305,7 +305,6 @@
|
||||
case FUNCTION_FOREGROUND:
|
||||
case FUNCTION_NEW_RECEIVE:
|
||||
case FUNCTION_RECEIVE:
|
||||
case FUNCTION_MONITOR:
|
||||
break;
|
||||
}
|
||||
|
||||
|
63
app/action.c
63
app/action.c
@ -55,10 +55,17 @@ static void ACTION_FlashLight(void)
|
||||
case FLASHLIGHT_BLINK:
|
||||
g_flash_light_blink_tick_10ms = 0;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
|
||||
g_flash_light_state = FLASHLIGHT_SOS;
|
||||
|
||||
if (g_current_function == FUNCTION_POWER_SAVE)
|
||||
FUNCTION_Select(FUNCTION_RECEIVE);
|
||||
break;
|
||||
|
||||
case FLASHLIGHT_SOS:
|
||||
#ifdef ENABLE_FLASH_LIGHT_SOS_TONE
|
||||
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
|
||||
#endif
|
||||
|
||||
// Fallthrough
|
||||
|
||||
@ -89,29 +96,39 @@ void ACTION_Power(void)
|
||||
|
||||
void ACTION_Monitor(void)
|
||||
{
|
||||
if (g_current_function != FUNCTION_MONITOR)
|
||||
{ // enable the monitor
|
||||
RADIO_select_vfos();
|
||||
if (!g_monitor_enabled) // (g_current_function != FUNCTION_MONITOR)
|
||||
{ // enable monitor mode
|
||||
|
||||
g_beep_to_play = BEEP_NONE;
|
||||
|
||||
g_monitor_enabled = true;
|
||||
// g_squelch_open = true;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode)
|
||||
// if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST && g_is_noaa_mode)
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
|
||||
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
|
||||
#endif
|
||||
g_monitor_enabled = true;
|
||||
RADIO_setup_registers(true);
|
||||
APP_start_listening(FUNCTION_MONITOR);
|
||||
|
||||
APP_start_listening();
|
||||
return;
|
||||
}
|
||||
|
||||
// disable monitor
|
||||
|
||||
g_monitor_enabled = false;
|
||||
|
||||
if (!g_speaker_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
|
||||
#ifdef g_power_save_expired
|
||||
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
|
||||
{
|
||||
g_noaa_tick_10ms = noaa_tick_10ms;
|
||||
g_schedule_noaa = false;
|
||||
g_schedule_noaa = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -134,12 +151,12 @@ void ACTION_Scan(bool bRestart)
|
||||
if (g_fm_radio_mode)
|
||||
{
|
||||
if (g_current_function != FUNCTION_RECEIVE &&
|
||||
g_current_function != FUNCTION_MONITOR &&
|
||||
g_current_function != FUNCTION_TRANSMIT)
|
||||
g_current_function != FUNCTION_TRANSMIT &&
|
||||
!g_monitor_enabled)
|
||||
{
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
|
||||
g_monitor_enabled = false;
|
||||
// g_monitor_enabled = false;
|
||||
|
||||
if (g_fm_scan_state != FM_SCAN_OFF)
|
||||
{ // already scanning
|
||||
@ -186,6 +203,7 @@ void ACTION_Scan(bool bRestart)
|
||||
{ // not in freq/ctcss/cdcss search mode
|
||||
|
||||
g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
DTMF_clear_RX();
|
||||
|
||||
@ -213,7 +231,7 @@ void ACTION_Scan(bool bRestart)
|
||||
// jump to the next channel
|
||||
APP_channel_next(true, g_scan_state_dir);
|
||||
|
||||
g_scan_pause_10ms = 0;
|
||||
g_scan_pause_tick_10ms = 0;
|
||||
g_scan_pause_time_mode = false;
|
||||
|
||||
g_update_status = true;
|
||||
@ -233,13 +251,14 @@ void ACTION_Scan(bool bRestart)
|
||||
|
||||
// start scanning
|
||||
|
||||
// disable monitor mode
|
||||
g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
APP_channel_next(true, SCAN_STATE_DIR_FORWARD);
|
||||
|
||||
g_scan_pause_10ms = 0; // go NOW
|
||||
g_scan_pause_tick_10ms = 0; // go NOW
|
||||
g_scan_pause_time_mode = false;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -270,14 +289,13 @@ void ACTION_Scan(bool bRestart)
|
||||
// jump to the next channel
|
||||
APP_channel_next(true, g_scan_state_dir);
|
||||
|
||||
g_scan_pause_10ms = 0;
|
||||
g_scan_pause_tick_10ms = 0;
|
||||
g_scan_pause_time_mode = false;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
else
|
||||
{ // stop scanning
|
||||
g_monitor_enabled = false;
|
||||
APP_stop_scan();
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
}
|
||||
@ -324,7 +342,9 @@ void ACTION_Scan(bool bRestart)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
void ACTION_FM(void)
|
||||
{
|
||||
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_MONITOR)
|
||||
if (g_current_function != FUNCTION_TRANSMIT &&
|
||||
// g_current_function != FUNCTION_MONITOR
|
||||
!g_monitor_enabled)
|
||||
{
|
||||
if (g_fm_radio_mode)
|
||||
{
|
||||
@ -332,7 +352,7 @@ void ACTION_Scan(bool bRestart)
|
||||
|
||||
g_input_box_index = 0;
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 80;
|
||||
g_vox_resume_tick_10ms = 80;
|
||||
#endif
|
||||
g_flag_reconfigure_vfos = true;
|
||||
|
||||
@ -340,7 +360,7 @@ void ACTION_Scan(bool bRestart)
|
||||
return;
|
||||
}
|
||||
|
||||
g_monitor_enabled = false;
|
||||
// g_monitor_enabled = false;
|
||||
|
||||
RADIO_select_vfos();
|
||||
RADIO_setup_registers(true);
|
||||
@ -372,10 +392,7 @@ void ACTION_process(const key_code_t Key, const bool key_pressed, const bool key
|
||||
}
|
||||
|
||||
if (!key_held && key_pressed)
|
||||
{
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_held || key_pressed)
|
||||
{
|
||||
|
@ -80,6 +80,8 @@ void AIRCOPY_init(void)
|
||||
// turn the backlight ON
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
BK4819_SetupAircopy(AIRCOPY_DATA_PACKET_SIZE);
|
||||
|
@ -31,7 +31,7 @@ extern const uint8_t orig_pga;
|
||||
void APP_end_tx(void);
|
||||
void APP_stop_scan(void);
|
||||
void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction);
|
||||
bool APP_start_listening(function_type_t Function);
|
||||
bool APP_start_listening(void);
|
||||
uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step);
|
||||
void APP_time_slice_10ms(void);
|
||||
void APP_time_slice_500ms(void);
|
||||
|
@ -439,8 +439,8 @@ bool DTMF_Reply(void)
|
||||
|
||||
if (g_eeprom.dtmf_side_tone)
|
||||
{ // the user will also hear the transmitted tones
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
SYSTEM_DelayMs(Delay);
|
||||
@ -455,8 +455,8 @@ bool DTMF_Reply(void)
|
||||
g_eeprom.dtmf_code_persist_time,
|
||||
g_eeprom.dtmf_code_interval_time);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
BK4819_ExitDTMF_TX(false);
|
||||
|
||||
|
46
app/fm.c
46
app/fm.c
@ -98,16 +98,19 @@ int FM_ConfigureChannelState(void)
|
||||
|
||||
void FM_TurnOff(void)
|
||||
{
|
||||
g_fm_radio_mode = false;
|
||||
g_fm_scan_state = FM_SCAN_OFF;
|
||||
g_fm_radio_mode = false;
|
||||
g_fm_scan_state = FM_SCAN_OFF;
|
||||
g_fm_restore_tick_10ms = 0;
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_speaker_enabled = false;
|
||||
if (!g_monitor_enabled)
|
||||
{
|
||||
g_speaker_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
BK1080_Init(0, false);
|
||||
|
||||
g_update_display = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
@ -125,9 +128,8 @@ void FM_EraseChannels(void)
|
||||
|
||||
void FM_Tune(uint16_t Frequency, int8_t Step, bool flag)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_speaker_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_fm_play_tick_10ms = (g_fm_scan_state == FM_SCAN_OFF) ? fm_play_noscan_10ms : fm_play_scan_10ms;
|
||||
|
||||
@ -169,12 +171,13 @@ void FM_PlayAndUpdate(void)
|
||||
SETTINGS_save_fm();
|
||||
|
||||
g_fm_play_tick_10ms = 0;
|
||||
g_schedule_fm = false;
|
||||
g_ask_to_save = false;
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_schedule_fm = false;
|
||||
g_ask_to_save = false;
|
||||
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
|
||||
@ -402,9 +405,12 @@ static void FM_Key_STAR(bool key_pressed, bool key_held)
|
||||
|
||||
static void FM_Key_EXIT(bool key_pressed, bool key_held)
|
||||
{
|
||||
(void)key_held;
|
||||
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
if (key_held || key_pressed)
|
||||
// if (key_held || key_pressed)
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||
@ -460,12 +466,15 @@ static void FM_Key_EXIT(bool key_pressed, bool key_held)
|
||||
|
||||
static void FM_Key_MENU(bool key_pressed, bool key_held)
|
||||
{
|
||||
(void)key_held;
|
||||
|
||||
unsigned int i;
|
||||
int channel = -1;
|
||||
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
if (key_held || key_pressed)
|
||||
// if (key_held || key_pressed)
|
||||
if (key_pressed)
|
||||
return; // key still pressed
|
||||
|
||||
// see if the frequency is already stored in a channel
|
||||
@ -513,7 +522,7 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
||||
else
|
||||
g_ask_to_delete = true;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -666,8 +675,8 @@ void FM_Play(void)
|
||||
if (!g_eeprom.fm_channel_mode)
|
||||
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_FM);
|
||||
return;
|
||||
@ -694,14 +703,15 @@ void FM_Play(void)
|
||||
|
||||
void FM_Start(void)
|
||||
{
|
||||
g_fm_radio_mode = true;
|
||||
g_fm_scan_state = FM_SCAN_OFF;
|
||||
g_fm_radio_mode = true;
|
||||
g_fm_scan_state = FM_SCAN_OFF;
|
||||
g_fm_restore_tick_10ms = 0;
|
||||
|
||||
BK1080_Init(g_eeprom.fm_frequency_playing, true);
|
||||
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_speaker_enabled = true;
|
||||
g_update_display = true;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
123
app/main.c
123
app/main.c
@ -41,13 +41,14 @@
|
||||
#include "radio.h"
|
||||
#include "settings.h"
|
||||
#include "ui/inputbox.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/main.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
bool scanning_paused(void)
|
||||
{
|
||||
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
|
||||
g_scan_pause_10ms > 0 && g_scan_pause_10ms <= (200 / 10))
|
||||
g_scan_pause_tick_10ms > 0 && g_scan_pause_tick_10ms <= (200 / 10))
|
||||
{ // scanning isn't paused
|
||||
return false;
|
||||
}
|
||||
@ -130,6 +131,7 @@ void toggle_chan_scanlist(void)
|
||||
RADIO_select_vfos();
|
||||
RADIO_ApplyOffset(g_tx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
@ -427,7 +429,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
{ // key held down
|
||||
|
||||
if (key_pressed)
|
||||
{ // and pressed
|
||||
{
|
||||
if (g_current_display_screen == DISPLAY_MAIN)
|
||||
{
|
||||
if (g_input_box_index > 0)
|
||||
@ -473,7 +475,9 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
|
||||
INPUTBOX_append(Key);
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
UI_DisplayMain();
|
||||
|
||||
// g_request_display_screen = DISPLAY_MAIN;
|
||||
|
||||
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering channel number
|
||||
@ -483,9 +487,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
if (g_input_box_index != 3)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -500,7 +503,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
|
||||
@ -508,6 +511,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -521,7 +525,6 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -578,6 +581,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_request_save_channel = 1;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE;
|
||||
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -594,7 +598,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
// g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -611,13 +615,16 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_eeprom.screen_channel[Vfo] = Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
|
||||
g_update_display = true;
|
||||
// g_request_display_screen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
void MAIN_Key_EXIT(bool key_pressed, bool key_held)
|
||||
@ -671,18 +678,36 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_held && key_pressed)
|
||||
{ // exit key held down
|
||||
|
||||
if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode)
|
||||
{ // cancel key input mode (channel/frequency entry)
|
||||
g_dtmf_input_mode = false;
|
||||
g_dtmf_input_box_index = 0;
|
||||
memset(g_dtmf_string, 0, sizeof(g_dtmf_string));
|
||||
g_input_box_index = 0;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
if (!key_held)
|
||||
return;
|
||||
|
||||
if (key_pressed)
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
{
|
||||
ACTION_FM();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode)
|
||||
{ // cancel key input mode (channel/frequency entry)
|
||||
g_dtmf_input_mode = false;
|
||||
g_dtmf_input_box_index = 0;
|
||||
memset(g_dtmf_string, 0, sizeof(g_dtmf_string));
|
||||
g_input_box_index = 0;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_flash_light_state != FLASHLIGHT_OFF && g_flash_light_state != FLASHLIGHT_SOS)
|
||||
{ // the the flash light off
|
||||
g_flash_light_state = FLASHLIGHT_OFF;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -831,14 +856,17 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(Channel))
|
||||
{ // key released in frequency mode
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
(Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
|
||||
{ // key released
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (key_held && !monitor_was_enabled && g_current_function == FUNCTION_MONITOR)
|
||||
if (key_held && !monitor_was_enabled)
|
||||
{ // re-enable the squelch
|
||||
APP_start_listening(FUNCTION_RECEIVE);
|
||||
|
||||
g_monitor_enabled = false;
|
||||
|
||||
APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -898,7 +926,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
uint8_t Next;
|
||||
|
||||
if (IS_FREQ_CHANNEL(Channel))
|
||||
{ // step/down in frequency
|
||||
{ // frequency mode
|
||||
|
||||
frequency_band_t new_band;
|
||||
const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency);
|
||||
@ -947,7 +975,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_monitor_enabled = true;
|
||||
APP_start_listening(FUNCTION_MONITOR);
|
||||
APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -958,9 +986,20 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
return;
|
||||
}
|
||||
|
||||
// suppress audio click
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
// channel mode
|
||||
|
||||
g_tx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (!key_held && key_pressed)
|
||||
monitor_was_enabled = g_monitor_enabled;
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_monitor_enabled = true;
|
||||
APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
|
||||
if (Next == 0xFF)
|
||||
@ -989,20 +1028,23 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
}
|
||||
#endif
|
||||
|
||||
g_request_save_vfo = true;
|
||||
if (!key_held && key_pressed) // save when the user releases the button - save a LOT of eeprom wear
|
||||
g_request_save_vfo = true;
|
||||
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// g_speaker_enabled = false;
|
||||
// g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
|
||||
// jump to the next channel
|
||||
APP_channel_next(false, Direction);
|
||||
|
||||
// go NOW
|
||||
g_scan_pause_10ms = 0;
|
||||
g_scan_pause_tick_10ms = 0;
|
||||
g_scan_pause_time_mode = false;
|
||||
g_squelch_open = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
@ -1020,9 +1062,12 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode && key != KEY_PTT && key != KEY_EXIT)
|
||||
{
|
||||
if (!key_held && key_pressed)
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
if (g_current_display_screen == DISPLAY_FM)
|
||||
{
|
||||
if (!key_held && key_pressed)
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1061,10 +1106,10 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
|
||||
MAIN_Key_MENU(key_pressed, key_held);
|
||||
break;
|
||||
case KEY_UP:
|
||||
MAIN_Key_UP_DOWN(key_pressed, key_held, 1);
|
||||
MAIN_Key_UP_DOWN(key_pressed, key_held, SCAN_STATE_DIR_FORWARD);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
MAIN_Key_UP_DOWN(key_pressed, key_held, -1);
|
||||
MAIN_Key_UP_DOWN(key_pressed, key_held, SCAN_STATE_DIR_REVERSE);
|
||||
break;
|
||||
case KEY_EXIT:
|
||||
MAIN_Key_EXIT(key_pressed, key_held);
|
||||
|
@ -86,7 +86,7 @@ void MENU_start_css_scan(int8_t Direction)
|
||||
|
||||
MENU_SelectNextCode();
|
||||
|
||||
g_scan_pause_10ms = scan_pause_css_10ms;
|
||||
g_scan_pause_tick_10ms = scan_pause_css_10ms;
|
||||
}
|
||||
|
||||
void MENU_stop_css_scan(void)
|
||||
@ -939,7 +939,7 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
g_scan_pause_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_ctcss_10ms : scan_pause_cdcss_10ms;
|
||||
g_scan_pause_tick_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_ctcss_10ms : scan_pause_cdcss_10ms;
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
@ -2014,11 +2014,11 @@ void MENU_process_key(key_code_t Key, bool key_pressed, bool key_held)
|
||||
#endif
|
||||
g_menu_cursor == MENU_BAT_CAL)
|
||||
{
|
||||
g_menu_count_down = menu_timeout_long_500ms;
|
||||
g_menu_tick_10ms = menu_timeout_long_500ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_menu_count_down = menu_timeout_500ms;
|
||||
g_menu_tick_10ms = menu_timeout_500ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include "app/search.h"
|
||||
#include "audio.h"
|
||||
#include "board.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/gpio.h"
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
#include "driver/uart.h"
|
||||
#endif
|
||||
@ -400,6 +402,9 @@ void SEARCH_Start(void)
|
||||
g_rx_vfo->step_setting = BackupStep;
|
||||
g_rx_vfo->step_freq = BackupStepFreq;
|
||||
|
||||
g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
|
@ -345,9 +345,9 @@ uint32_t GetOffsetedF(uint32_t f) {
|
||||
bool IsTXAllowed() { return g_setting_ALL_TX != 2; }
|
||||
|
||||
static void ToggleAudio(bool on) {
|
||||
if (on) {
|
||||
if (on)
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
} else {
|
||||
else {
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
}
|
||||
|
69
audio.c
69
audio.c
@ -68,7 +68,7 @@
|
||||
voice_id_t g_voice_id[8];
|
||||
uint8_t g_voice_read_index;
|
||||
uint8_t g_voice_write_index;
|
||||
volatile uint16_t g_tick_to_play_next_voice_10ms;
|
||||
volatile uint16_t g_play_next_voice_tick_10ms;
|
||||
volatile bool g_flag_play_queued_voice;
|
||||
voice_id_t g_another_voice_id = VOICE_ID_INVALID;
|
||||
|
||||
@ -78,7 +78,8 @@ beep_type_t g_beep_to_play = BEEP_NONE;
|
||||
|
||||
void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
{
|
||||
const uint16_t ToneConfig = BK4819_ReadRegister(0x71);
|
||||
const uint16_t tone_val = BK4819_ReadRegister(0x71);
|
||||
// const uint16_t af_val = BK4819_ReadRegister(0x47);
|
||||
uint16_t ToneFrequency;
|
||||
uint16_t Duration;
|
||||
|
||||
@ -94,14 +95,20 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_flash_light_state == FLASHLIGHT_SOS ||
|
||||
g_current_function == FUNCTION_RECEIVE ||
|
||||
g_monitor_enabled ||
|
||||
GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
// if (g_current_display_screen == DISPLAY_AIRCOPY || g_aircopy_state != AIRCOPY_READY)
|
||||
// return;
|
||||
#endif
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
return; // not while the speakers in use
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
// GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
|
||||
BK4819_RX_TurnOn();
|
||||
@ -150,7 +157,9 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
break;
|
||||
}
|
||||
|
||||
// BK4819_PlayTone(ToneFrequency, true);
|
||||
BK4819_StartTone1(ToneFrequency, 96, true);
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
@ -200,29 +209,24 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
}
|
||||
|
||||
SYSTEM_DelayMs(Duration);
|
||||
|
||||
BK4819_EnterTxMute();
|
||||
|
||||
// SYSTEM_DelayMs(20);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 80;
|
||||
#endif
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
// SYSTEM_DelayMs(5);
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_tick_10ms = 80; // 800ms
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
BK4819_TurnsOffTones_TurnsOnRX();
|
||||
// SYSTEM_DelayMs(5);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
// restore the register
|
||||
BK4819_WriteRegister(0x71, ToneConfig);
|
||||
BK4819_WriteRegister(0x71, tone_val);
|
||||
|
||||
if (g_speaker_enabled)
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
|
||||
// BK4819_SetAF(BK4819_AF_MUTE);
|
||||
// BK4819_WriteRegister(0x47, af_val);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
@ -230,7 +234,14 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
#endif
|
||||
|
||||
if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
|
||||
{
|
||||
BK4819_Sleep();
|
||||
}
|
||||
else
|
||||
if (g_speaker_enabled || g_monitor_enabled)
|
||||
{
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
@ -287,7 +298,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
}
|
||||
|
||||
#ifdef MUTE_AUDIO_FOR_VOICE
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
if (g_current_function == FUNCTION_RECEIVE)
|
||||
BK4819_SetAF(BK4819_AF_MUTE);
|
||||
#endif
|
||||
|
||||
@ -301,7 +312,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 2000;
|
||||
g_vox_resume_tick_10ms = 2000;
|
||||
#endif
|
||||
|
||||
SYSTEM_DelayMs(5);
|
||||
@ -315,7 +326,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
{
|
||||
SYSTEM_DelayMs(Delay * 10);
|
||||
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
if (g_current_function == FUNCTION_RECEIVE)
|
||||
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -330,14 +341,14 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
g_voice_read_index = 0;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 80;
|
||||
g_vox_resume_tick_10ms = 80;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_voice_read_index = 1;
|
||||
g_tick_to_play_next_voice_10ms = Delay;
|
||||
g_play_next_voice_tick_10ms = Delay;
|
||||
g_flag_play_queued_voice = false;
|
||||
|
||||
return;
|
||||
@ -449,11 +460,11 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
|
||||
AUDIO_PlayVoice(VoiceID);
|
||||
|
||||
g_tick_to_play_next_voice_10ms = Delay;
|
||||
g_play_next_voice_tick_10ms = Delay;
|
||||
g_flag_play_queued_voice = false;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 2000;
|
||||
g_vox_resume_tick_10ms = 2000;
|
||||
#endif
|
||||
|
||||
return;
|
||||
@ -463,7 +474,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
// ***********************
|
||||
// unmute the radios audio
|
||||
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
if (g_current_function == FUNCTION_RECEIVE)
|
||||
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -477,7 +488,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
|
||||
// **********************
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_resume_count_down = 80;
|
||||
g_vox_resume_tick_10ms = 80;
|
||||
#endif
|
||||
|
||||
g_voice_write_index = 0;
|
||||
|
2
audio.h
2
audio.h
@ -129,7 +129,7 @@ typedef enum voice_id_e voice_id_t;
|
||||
extern voice_id_t g_voice_id[8];
|
||||
extern uint8_t g_voice_read_index;
|
||||
extern uint8_t g_voice_write_index;
|
||||
extern volatile uint16_t g_tick_to_play_next_voice_10ms;
|
||||
extern volatile uint16_t g_play_next_voice_tick_10ms;
|
||||
extern volatile bool g_flag_play_queued_voice;
|
||||
extern voice_id_t g_another_voice_id;
|
||||
|
||||
|
@ -133,26 +133,16 @@ typedef enum bk4819_gpio_pin_e bk4819_gpio_pin_t;
|
||||
#define BK4819_REG_30_MASK_ENABLE_RX_DSP (0x1U << BK4819_REG_30_SHIFT_ENABLE_RX_DSP)
|
||||
|
||||
enum {
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB = (0x1U << BK4819_REG_30_SHIFT_ENABLE_VCO_CALIB),
|
||||
BK4819_REG_30_DISABLE_VCO_CALIB = (0x0U << BK4819_REG_30_SHIFT_ENABLE_VCO_CALIB),
|
||||
BK4819_REG_30_ENABLE_UNKNOWN = (0x1U << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN),
|
||||
BK4819_REG_30_DISABLE_UNKNOWN = (0x0U << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN),
|
||||
BK4819_REG_30_ENABLE_RX_LINK = (0xFU << BK4819_REG_30_SHIFT_ENABLE_RX_LINK),
|
||||
BK4819_REG_30_DISABLE_RX_LINK = (0x0U << BK4819_REG_30_SHIFT_ENABLE_RX_LINK),
|
||||
BK4819_REG_30_ENABLE_AF_DAC = (0x1U << BK4819_REG_30_SHIFT_ENABLE_AF_DAC),
|
||||
BK4819_REG_30_DISABLE_AF_DAC = (0x0U << BK4819_REG_30_SHIFT_ENABLE_AF_DAC),
|
||||
BK4819_REG_30_ENABLE_DISC_MODE = (0x1U << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE),
|
||||
BK4819_REG_30_DISABLE_DISC_MODE = (0x0U << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE),
|
||||
BK4819_REG_30_ENABLE_PLL_VCO = (0xFU << BK4819_REG_30_SHIFT_ENABLE_PLL_VCO),
|
||||
BK4819_REG_30_DISABLE_PLL_VCO = (0x0U << BK4819_REG_30_SHIFT_ENABLE_PLL_VCO),
|
||||
BK4819_REG_30_ENABLE_PA_GAIN = (0x1U << BK4819_REG_30_SHIFT_ENABLE_PA_GAIN),
|
||||
BK4819_REG_30_DISABLE_PA_GAIN = (0x0U << BK4819_REG_30_SHIFT_ENABLE_PA_GAIN),
|
||||
BK4819_REG_30_ENABLE_MIC_ADC = (0x1U << BK4819_REG_30_SHIFT_ENABLE_MIC_ADC),
|
||||
BK4819_REG_30_DISABLE_MIC_ADC = (0x0U << BK4819_REG_30_SHIFT_ENABLE_MIC_ADC),
|
||||
BK4819_REG_30_ENABLE_TX_DSP = (0x1U << BK4819_REG_30_SHIFT_ENABLE_TX_DSP),
|
||||
BK4819_REG_30_DISABLE_TX_DSP = (0x0U << BK4819_REG_30_SHIFT_ENABLE_TX_DSP),
|
||||
BK4819_REG_30_ENABLE_RX_DSP = (0x1U << BK4819_REG_30_SHIFT_ENABLE_RX_DSP),
|
||||
BK4819_REG_30_DISABLE_RX_DSP = (0x0U << BK4819_REG_30_SHIFT_ENABLE_RX_DSP),
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB = ( 1u << BK4819_REG_30_SHIFT_ENABLE_VCO_CALIB),
|
||||
BK4819_REG_30_ENABLE_UNKNOWN = ( 1u << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN),
|
||||
BK4819_REG_30_ENABLE_RX_LINK = (15u << BK4819_REG_30_SHIFT_ENABLE_RX_LINK),
|
||||
BK4819_REG_30_ENABLE_AF_DAC = ( 1u << BK4819_REG_30_SHIFT_ENABLE_AF_DAC),
|
||||
BK4819_REG_30_ENABLE_DISC_MODE = ( 1u << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE),
|
||||
BK4819_REG_30_ENABLE_PLL_VCO = (15u << BK4819_REG_30_SHIFT_ENABLE_PLL_VCO),
|
||||
BK4819_REG_30_ENABLE_PA_GAIN = ( 1u << BK4819_REG_30_SHIFT_ENABLE_PA_GAIN),
|
||||
BK4819_REG_30_ENABLE_MIC_ADC = ( 1u << BK4819_REG_30_SHIFT_ENABLE_MIC_ADC),
|
||||
BK4819_REG_30_ENABLE_TX_DSP = ( 1u << BK4819_REG_30_SHIFT_ENABLE_TX_DSP),
|
||||
BK4819_REG_30_ENABLE_RX_DSP = ( 1u << BK4819_REG_30_SHIFT_ENABLE_RX_DSP)
|
||||
};
|
||||
|
||||
// REG 3F
|
||||
|
291
driver/bk4819.c
291
driver/bk4819.c
@ -19,6 +19,7 @@
|
||||
#include "bk4819.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "bsp/dp32g030/portcon.h"
|
||||
#include "functions.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/system.h"
|
||||
#include "driver/systick.h"
|
||||
@ -556,6 +557,9 @@ void BK4819_SetTailDetection(const uint32_t freq_10Hz)
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
BK4819_WriteRegister(0x07, BK4819_REG_07_MODE_CTC2 | ((253910 + (freq_10Hz / 2)) / freq_10Hz)); // with rounding
|
||||
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
#endif
|
||||
}
|
||||
|
||||
void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
|
||||
@ -776,8 +780,7 @@ void BK4819_set_rf_frequency(const uint32_t frequency, const bool trigger_update
|
||||
// trigger a PLL/VCO update
|
||||
//
|
||||
const uint16_t reg = BK4819_ReadRegister(0x30);
|
||||
// BK4819_WriteRegister(0x30, reg & ~(1u << 15) & (15u << 4));
|
||||
BK4819_WriteRegister(0x30, 0x0200);
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x30, reg);
|
||||
}
|
||||
}
|
||||
@ -871,11 +874,9 @@ void BK4819_SetupSquelch(
|
||||
|
||||
void BK4819_SetAF(BK4819_af_type_t AF)
|
||||
{
|
||||
// AF Output Inverse Mode = Inverse
|
||||
// Undocumented bits 0x2040
|
||||
//
|
||||
// BK4819_WriteRegister(0x47, 0x6040 | (AF << 8));
|
||||
BK4819_WriteRegister(0x47, (6u << 12) | (AF << 8) | (1u << 6));
|
||||
BK4819_WriteRegister(0x47, 0);
|
||||
// BK4819_WriteRegister(0x47, 0x6040 | (AF << 8)); // 0110 0000 0100 0000
|
||||
BK4819_WriteRegister(0x47, (1u << 14) | (1u << 13) | ((AF & 15u) << 8) | (1u << 6));
|
||||
}
|
||||
|
||||
void BK4819_RX_TurnOn(void)
|
||||
@ -896,21 +897,19 @@ void BK4819_RX_TurnOn(void)
|
||||
//
|
||||
BK4819_WriteRegister(0x37, 0x1F0F); // 0001 1111 0000 1111
|
||||
|
||||
// turn everything off
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
|
||||
// and on again ..
|
||||
//
|
||||
// Enable VCO Calibration
|
||||
// Enable RX Link
|
||||
// Enable AF DAC
|
||||
// Enable PLL/VCO
|
||||
// Disable PA Gain
|
||||
// Disable MIC ADC
|
||||
// Disable TX DSP
|
||||
// Enable RX DSP
|
||||
//
|
||||
BK4819_WriteRegister(0x30, 0xBFF1); // 1 0 1111 1 1 1111 0 0 0 1
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
// BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
// BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
// BK4819_REG_30_ENABLE_TX_DSP |
|
||||
BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_set_rf_filter_path(uint32_t Frequency)
|
||||
@ -1055,8 +1054,12 @@ void BK4819_EnableDTMF(void)
|
||||
|
||||
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool set_dac)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
// BK4819_SetAF(BK4819_AF_MUTE);
|
||||
BK4819_SetAF(BK4819_AF_BEEP);
|
||||
// BK4819_SetAF(BK4819_AF_TONE);
|
||||
|
||||
BK4819_EnterTxMute();
|
||||
|
||||
@ -1065,36 +1068,88 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const
|
||||
if (set_dac)
|
||||
{
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
//BK4819_WriteRegister(0x30, BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_TX_DSP);
|
||||
BK4819_EnableTXLink();
|
||||
BK4819_WriteRegister(0x30, // all of the following must be enable to get an audio beep ! ???
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
BK4819_WriteRegister(0x71, scale_freq(frequency));
|
||||
|
||||
BK4819_ExitTxMute();
|
||||
|
||||
// SYSTEM_DelayMs(2);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // enable speaker
|
||||
// enable speaker
|
||||
SYSTEM_DelayMs(2);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
void BK4819_StopTones(void)
|
||||
void BK4819_StopTones(const bool tx)
|
||||
{
|
||||
// if (!g_speaker_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
BK4819_SetAF(BK4819_AF_MUTE);
|
||||
|
||||
BK4819_EnterTxMute();
|
||||
|
||||
BK4819_WriteRegister(0x70, 0);
|
||||
BK4819_WriteRegister(0x30, 0xC1FE); // 1100 0001 1111 1110
|
||||
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
if (tx)
|
||||
{
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
// BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
// BK4819_REG_30_ENABLE_TX_DSP |
|
||||
BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
BK4819_ExitTxMute();
|
||||
|
||||
// if (g_speaker_enabled || g_monitor_enabled)
|
||||
// {
|
||||
// SYSTEM_DelayMs(2);
|
||||
// GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// }
|
||||
}
|
||||
|
||||
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level)
|
||||
{
|
||||
const uint16_t prev_af = BK4819_ReadRegister(0x47);
|
||||
// const uint16_t prev_af = BK4819_ReadRegister(0x47);
|
||||
BK4819_StartTone1(tone_Hz, level, true);
|
||||
SYSTEM_DelayMs(delay - 2);
|
||||
BK4819_StopTones();
|
||||
BK4819_WriteRegister(0x47, prev_af);
|
||||
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
|
||||
// BK4819_WriteRegister(0x47, prev_af);
|
||||
}
|
||||
|
||||
void BK4819_PlayRoger(void)
|
||||
@ -1108,15 +1163,15 @@ void BK4819_PlayRoger(void)
|
||||
const uint32_t tone2_Hz = 1310;
|
||||
#endif
|
||||
|
||||
const uint16_t prev_af = BK4819_ReadRegister(0x47);
|
||||
// const uint16_t prev_af = BK4819_ReadRegister(0x47);
|
||||
|
||||
BK4819_StartTone1(tone1_Hz, 96, true);
|
||||
SYSTEM_DelayMs(80 - 2);
|
||||
BK4819_StartTone1(tone2_Hz, 96, false);
|
||||
SYSTEM_DelayMs(80);
|
||||
BK4819_StopTones();
|
||||
BK4819_StopTones(true);
|
||||
|
||||
BK4819_WriteRegister(0x47, prev_af);
|
||||
// BK4819_WriteRegister(0x47, prev_af);
|
||||
}
|
||||
|
||||
void BK4819_EnterTxMute(void)
|
||||
@ -1126,13 +1181,13 @@ void BK4819_EnterTxMute(void)
|
||||
|
||||
void BK4819_ExitTxMute(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x50, 0x3B20);
|
||||
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
|
||||
}
|
||||
|
||||
void BK4819_Sleep(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x37, 0x1D00);
|
||||
BK4819_WriteRegister(0x37, 0x1D00); // 0 0 0111 0 1 0000 0 0 0 0
|
||||
}
|
||||
|
||||
void BK4819_TurnsOffTones_TurnsOnRX(void)
|
||||
@ -1145,11 +1200,16 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
// BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_RX_DSP);
|
||||
// BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
// BK4819_REG_30_ENABLE_TX_DSP |
|
||||
BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_Idle(void)
|
||||
@ -1203,11 +1263,27 @@ void BK4819_PrepareTransmit(void)
|
||||
|
||||
void BK4819_TxOn_Beep(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x37, 0x1D0F);
|
||||
BK4819_WriteRegister(0x52, 0x028F);
|
||||
BK4819_WriteRegister(0x37, 0x1D0F); // 0001110100001111
|
||||
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_WriteRegister(0x52, (1u << 15) | (2u << 13) | (0u << 12) | (10u << 6) | (15u << 0));
|
||||
#else
|
||||
BK4819_WriteRegister(0x52, (0u << 15) | (0u << 13) | (0u << 12) | (10u << 6) | (15u << 0)); // 0x028F); // 0 00 0 001010 001111
|
||||
#endif
|
||||
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x30, 0xC1FE);
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
// BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_ExitSubAu(void)
|
||||
@ -1252,7 +1328,7 @@ void BK4819_ExitSubAu(void)
|
||||
BK4819_WriteRegister(0x51, 0);
|
||||
}
|
||||
|
||||
void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void)
|
||||
void BK4819_Conditional_RX_TurnOn(void)
|
||||
{
|
||||
if (g_rx_idle_mode)
|
||||
{
|
||||
@ -1282,57 +1358,42 @@ void BK4819_ExitDTMF_TX(bool bKeep)
|
||||
BK4819_SetAF(BK4819_AF_MUTE);
|
||||
BK4819_WriteRegister(0x70, 0);
|
||||
BK4819_DisableDTMF();
|
||||
BK4819_WriteRegister(0x30, 0xC1FE);
|
||||
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
// BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
|
||||
if (!bKeep)
|
||||
BK4819_ExitTxMute();
|
||||
}
|
||||
|
||||
void BK4819_EnableTXLink(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
BK4819_REG_30_DISABLE_RX_LINK |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
BK4819_REG_30_DISABLE_MIC_ADC |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
BK4819_REG_30_DISABLE_RX_DSP);
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_PlayDTMF(char Code)
|
||||
{
|
||||
/*
|
||||
uint16_t tone1 = 0;
|
||||
uint16_t tone2 = 0;
|
||||
|
||||
switch (Code)
|
||||
{
|
||||
case '0': tone1 = 941; tone2 = 1336; break;
|
||||
case '1': tone1 = 679; tone2 = 1209; break;
|
||||
case '2': tone1 = 697; tone2 = 1336; break;
|
||||
case '3': tone1 = 679; tone2 = 1477; break;
|
||||
case '4': tone1 = 770; tone2 = 1209; break;
|
||||
case '5': tone1 = 770; tone2 = 1336; break;
|
||||
case '6': tone1 = 770; tone2 = 1477; break;
|
||||
case '7': tone1 = 852; tone2 = 1209; break;
|
||||
case '8': tone1 = 852; tone2 = 1336; break;
|
||||
case '9': tone1 = 852; tone2 = 1477; break;
|
||||
case 'A': tone1 = 679; tone2 = 1633; break;
|
||||
case 'B': tone1 = 770; tone2 = 1633; break;
|
||||
case 'C': tone1 = 852; tone2 = 1633; break;
|
||||
case 'D': tone1 = 941; tone2 = 1633; break;
|
||||
case '*': tone1 = 941; tone2 = 1209; break;
|
||||
case '#': tone1 = 941; tone2 = 1477; break;
|
||||
}
|
||||
|
||||
if (tone1 > 0)
|
||||
BK4819_WriteRegister(0x71, (((uint32_t)tone1 * 103244) + 5000) / 10000); // with rounding
|
||||
if (tone2 > 0)
|
||||
BK4819_WriteRegister(0x72, (((uint32_t)tone2 * 103244) + 5000) / 10000); // with rounding
|
||||
*/
|
||||
|
||||
uint32_t index = ((Code >= 65) ? (Code - 55) : ((Code <= 35) ? 15 :((Code <= 42) ? 14 : (Code - '0'))));
|
||||
|
||||
@ -1762,15 +1823,10 @@ void BK4819_SetScanFrequency(uint32_t Frequency)
|
||||
BK4819_RX_TurnOn();
|
||||
}
|
||||
|
||||
void BK4819_Disable(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
}
|
||||
|
||||
void BK4819_StopScan(void)
|
||||
{
|
||||
BK4819_DisableFrequencyScan();
|
||||
BK4819_Disable();
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
}
|
||||
|
||||
uint8_t BK4819_GetDTMF_5TONE_Code(void)
|
||||
@ -1811,7 +1867,7 @@ void BK4819_reset_fsk(void)
|
||||
BK4819_WriteRegister(0x3F, 0); // disable interrupts
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59); // clear FIFO's
|
||||
BK4819_WriteRegister(0x59, (0u << 15) | (0u << 14) | fsk_reg59);
|
||||
BK4819_Idle();
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
@ -2201,10 +2257,10 @@ void BK4819_reset_fsk(void)
|
||||
// clear interrupt flags
|
||||
BK4819_WriteRegister(0x02, 0);
|
||||
|
||||
BK4819_RX_TurnOn();
|
||||
// BK4819_RX_TurnOn();
|
||||
|
||||
// enable interrupts
|
||||
BK4819_WriteRegister(0x3F, BK4819_ReadRegister(0x3F) | BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL);
|
||||
// BK4819_WriteRegister(0x3F, BK4819_ReadRegister(0x3F) | BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2224,17 +2280,18 @@ void BK4819_reset_fsk(void)
|
||||
//BK4819_ExitTxMute();
|
||||
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
|
||||
|
||||
BK4819_WriteRegister(0x30,
|
||||
(1u << 15) | // enable VCO calibration
|
||||
(1u << 14) | // enable something or other
|
||||
(0u << 10) | // diable RX link
|
||||
(1u << 9) | // enable AF DAC
|
||||
(1u << 8) | // enable DISC mode, what's DISC mode ?
|
||||
(15u << 4) | // enable PLL/VCO
|
||||
(1u << 3) | // enable PA gain
|
||||
(0u << 2) | // disable MIC ADC
|
||||
(1u << 1) | // enable TX DSP
|
||||
(0u << 0)); // disable RX DSP
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
|
||||
#if 1
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
@ -2477,7 +2534,7 @@ void BK4819_reset_fsk(void)
|
||||
}
|
||||
}
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // don't need the speaker enabled during TX
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
// disable FSK
|
||||
BK4819_WriteRegister(0x59, fsk_reg59);
|
||||
@ -2499,19 +2556,20 @@ void BK4819_reset_fsk(void)
|
||||
BK4819_WriteRegister(0x50, 0xBB20); // 1011 1011 0010 0000
|
||||
|
||||
//BK4819_SetAF(BK4819_AF_MUTE);
|
||||
BK4819_WriteRegister(0x47, (6u << 12) | (BK4819_AF_MUTE << 8) | (1u << 6) | (0u << 0));
|
||||
BK4819_WriteRegister(0x47, (1u << 14) | (1u << 13) | (BK4819_AF_MUTE << 8) | (1u << 6));
|
||||
|
||||
BK4819_WriteRegister(0x30,
|
||||
(1u << 15) | // enable VCO calibration
|
||||
(1u << 14) | // enable something or other
|
||||
(0u << 10) | // diable RX link
|
||||
(0u << 9) | // disable AF DAC
|
||||
(1u << 8) | // enable DISC mode, what's DISC mode ?
|
||||
(15u << 4) | // enable PLL/VCO
|
||||
(1u << 3) | // enable PA gain
|
||||
(1u << 2) | // enable MIC ADC
|
||||
(1u << 1) | // enable TX DSP
|
||||
(0u << 0)); // disable RX DSP
|
||||
BK4819_WriteRegister(0x30,
|
||||
BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
// BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
|
||||
//BK4819_ExitTxMute();
|
||||
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
|
||||
@ -2521,7 +2579,18 @@ void BK4819_reset_fsk(void)
|
||||
void BK4819_Enable_AfDac_DiscMode_TxDsp(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x30, 0x0302);
|
||||
BK4819_WriteRegister(0x30,
|
||||
// BK4819_REG_30_ENABLE_VCO_CALIB |
|
||||
// BK4819_REG_30_ENABLE_UNKNOWN |
|
||||
// BK4819_REG_30_ENABLE_RX_LINK |
|
||||
BK4819_REG_30_ENABLE_AF_DAC |
|
||||
BK4819_REG_30_ENABLE_DISC_MODE |
|
||||
// BK4819_REG_30_ENABLE_PLL_VCO |
|
||||
// BK4819_REG_30_ENABLE_PA_GAIN |
|
||||
// BK4819_REG_30_ENABLE_MIC_ADC |
|
||||
BK4819_REG_30_ENABLE_TX_DSP |
|
||||
// BK4819_REG_30_ENABLE_RX_DSP |
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_GetVoxAmp(uint16_t *pResult)
|
||||
|
@ -26,7 +26,7 @@ enum BK4819_af_type_e
|
||||
{
|
||||
BK4819_AF_MUTE = 0u, //
|
||||
BK4819_AF_FM = 1u, // FM
|
||||
BK4819_AF_ALAM = 2u, //
|
||||
BK4819_AF_TONE = 2u, //
|
||||
BK4819_AF_BEEP = 3u, //
|
||||
BK4819_AF_BASEBAND1 = 4u, // SSB
|
||||
BK4819_AF_BASEBAND2 = 5u, // SSB
|
||||
@ -104,7 +104,7 @@ void BK4819_DisableVox(void);
|
||||
void BK4819_DisableDTMF(void);
|
||||
void BK4819_EnableDTMF(void);
|
||||
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool set_dac);
|
||||
void BK4819_StopTones(void);
|
||||
void BK4819_StopTones(const bool tx);
|
||||
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level);
|
||||
void BK4819_EnterTxMute(void);
|
||||
void BK4819_ExitTxMute(void);
|
||||
@ -118,12 +118,11 @@ void BK4819_TurnsOffTones_TurnsOnRX(void);
|
||||
|
||||
void BK4819_reset_fsk(void);
|
||||
void BK4819_Idle(void);
|
||||
//void BK4819_ExitBypass(void);
|
||||
void BK4819_PrepareTransmit(void);
|
||||
void BK4819_TxOn_Beep(void);
|
||||
void BK4819_ExitSubAu(void);
|
||||
|
||||
void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void);
|
||||
void BK4819_Conditional_RX_TurnOn(void);
|
||||
|
||||
void BK4819_EnterDTMF_TX(bool bLocalLoopback);
|
||||
void BK4819_ExitDTMF_TX(bool bKeep);
|
||||
@ -150,8 +149,6 @@ void BK4819_DisableFrequencyScan(void);
|
||||
void BK4819_EnableFrequencyScan(void);
|
||||
void BK4819_SetScanFrequency(uint32_t Frequency);
|
||||
|
||||
void BK4819_Disable(void);
|
||||
|
||||
void BK4819_StopScan(void);
|
||||
|
||||
uint8_t BK4819_GetDTMF_5TONE_Code(void);
|
||||
|
@ -25,7 +25,8 @@
|
||||
uint8_t g_ptt_debounce;
|
||||
uint8_t g_key_debounce_press;
|
||||
uint8_t g_key_debounce_repeat;
|
||||
key_code_t g_key_prev = KEY_INVALID;
|
||||
key_code_t g_key_prev = KEY_INVALID;
|
||||
key_code_t g_key_pressed = KEY_INVALID;
|
||||
bool g_key_held;
|
||||
bool g_fkey_pressed;
|
||||
bool g_ptt_is_pressed;
|
||||
@ -124,9 +125,7 @@ key_code_t KEYBOARD_Poll(void)
|
||||
for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++)
|
||||
{
|
||||
uint16_t reg2;
|
||||
|
||||
SYSTICK_DelayUs(1);
|
||||
|
||||
reg2 = GPIOA->DATA;
|
||||
if (reg != reg2)
|
||||
{ // noise
|
||||
@ -159,5 +158,7 @@ key_code_t KEYBOARD_Poll(void)
|
||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
|
||||
GPIO_SetBit( &GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
|
||||
|
||||
g_key_pressed = Key;
|
||||
|
||||
return Key;
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ extern uint8_t g_ptt_debounce;
|
||||
extern uint8_t g_key_debounce_press;
|
||||
extern uint8_t g_key_debounce_repeat;
|
||||
extern key_code_t g_key_prev;
|
||||
extern key_code_t g_key_pressed;
|
||||
extern bool g_key_held;
|
||||
extern bool g_fkey_pressed;
|
||||
extern bool g_ptt_is_pressed;
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
3
font.c
3
font.c
@ -577,6 +577,8 @@ const uint8_t g_font_small_4x5[95][4] =
|
||||
{0x02, 0x1C, 0x48, 0x00}, // '~'
|
||||
};
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SMALLEST_FONT
|
||||
const uint8_t g_font3x5[160][3] =
|
||||
{
|
||||
{0x00, 0x00, 0x00}, // 32 - space
|
||||
@ -740,3 +742,4 @@ const uint8_t g_font3x5[160][3] =
|
||||
{0x03, 0x0b, 0x18}, // 190 - threequarters
|
||||
{0x18, 0x15, 0x10}, // 191 - questiondown
|
||||
};
|
||||
#endif
|
||||
|
5
font.h
5
font.h
@ -26,8 +26,9 @@ extern const uint8_t g_font_small[95][6];
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
extern const uint8_t g_font_small_bold[95][6];
|
||||
#endif
|
||||
//extern const uint8_t g_font_small_4x5[95][4];
|
||||
extern const uint8_t g_font3x5[160][3];
|
||||
#ifdef ENABLE_SMALLEST_FONT
|
||||
extern const uint8_t g_font3x5[160][3];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
63
functions.c
63
functions.c
@ -64,18 +64,18 @@ void FUNCTION_Init(void)
|
||||
g_ctcss_lost = false;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
g_vox_lost = false;
|
||||
g_vox_lost = false;
|
||||
#endif
|
||||
|
||||
g_squelch_open = false;
|
||||
g_squelch_open = false;
|
||||
|
||||
g_flag_tail_tone_elimination_complete = false;
|
||||
g_tail_tone_elimination_tick_10ms = 0;
|
||||
g_found_ctcss = false;
|
||||
g_found_cdcss = false;
|
||||
g_found_ctcss_tick_10ms = 0;
|
||||
g_found_cdcss_tick_10ms = 0;
|
||||
g_end_of_rx_detected_maybe = false;
|
||||
g_flag_tail_tone_elimination_complete = false;
|
||||
g_tail_tone_elimination_tick_10ms = 0;
|
||||
g_found_ctcss = false;
|
||||
g_found_cdcss = false;
|
||||
g_found_ctcss_tick_10ms = 0;
|
||||
g_found_cdcss_tick_10ms = 0;
|
||||
g_end_of_rx_detected_maybe = false;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
g_noaa_tick_10ms = 0;
|
||||
@ -93,10 +93,8 @@ void FUNCTION_Select(function_type_t Function)
|
||||
|
||||
if (was_power_save && Function != FUNCTION_POWER_SAVE)
|
||||
{ // wake up
|
||||
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
|
||||
|
||||
BK4819_Conditional_RX_TurnOn();
|
||||
g_rx_idle_mode = false;
|
||||
|
||||
UI_DisplayStatus(false);
|
||||
}
|
||||
|
||||
@ -135,26 +133,16 @@ void FUNCTION_Select(function_type_t Function)
|
||||
|
||||
return;
|
||||
|
||||
case FUNCTION_MONITOR:
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("func monitor\r\n");
|
||||
#endif
|
||||
|
||||
g_monitor_enabled = true;
|
||||
break;
|
||||
|
||||
case FUNCTION_NEW_RECEIVE:
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("func new receive\r\n");
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case FUNCTION_RECEIVE:
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("func receive\r\n");
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case FUNCTION_POWER_SAVE:
|
||||
@ -162,19 +150,24 @@ void FUNCTION_Select(function_type_t Function)
|
||||
UART_SendText("func power save\r\n");
|
||||
#endif
|
||||
|
||||
g_power_save_10ms = g_eeprom.battery_save * 10;
|
||||
g_power_save_expired = false;
|
||||
if (g_flash_light_state != FLASHLIGHT_SOS)
|
||||
{
|
||||
g_speaker_enabled = false;
|
||||
g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
g_power_save_tick_10ms = g_eeprom.battery_save * 10;
|
||||
g_power_save_expired = false;
|
||||
|
||||
g_rx_idle_mode = true;
|
||||
|
||||
g_monitor_enabled = false;
|
||||
|
||||
BK4819_DisableVox();
|
||||
BK4819_Sleep();
|
||||
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
|
||||
|
||||
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
if (g_current_display_screen != DISPLAY_MENU)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
return;
|
||||
@ -189,9 +182,9 @@ void FUNCTION_Select(function_type_t Function)
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
{ // dual-RX is enabled
|
||||
g_dual_watch_delay_10ms = dual_watch_delay_after_tx_10ms;
|
||||
if (g_dual_watch_delay_10ms < (g_eeprom.scan_hold_time_500ms * 50))
|
||||
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_dual_watch_tick_10ms = dual_watch_delay_after_tx_10ms;
|
||||
if (g_dual_watch_tick_10ms < (g_eeprom.scan_hold_time_500ms * 50))
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
@ -229,13 +222,12 @@ void FUNCTION_Select(function_type_t Function)
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
SYSTEM_DelayMs(20);
|
||||
SYSTEM_DelayMs(2);
|
||||
BK4819_StartTone1(500, 28, true);
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
SYSTEM_DelayMs(60);
|
||||
BK4819_ExitTxMute();
|
||||
@ -264,8 +256,8 @@ void FUNCTION_Select(function_type_t Function)
|
||||
|
||||
SYSTEM_DelayMs(2);
|
||||
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
#ifdef ENABLE_ALARM
|
||||
g_alarm_tone_counter_10ms = 0;
|
||||
@ -326,11 +318,10 @@ void FUNCTION_Select(function_type_t Function)
|
||||
UART_SendText("func panadpter\r\n");
|
||||
#endif
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
g_battery_save_tick_10ms = battery_save_count_10ms;
|
||||
g_schedule_power_save_tick_10ms = battery_save_count_10ms;
|
||||
g_schedule_power_save = false;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
|
@ -23,7 +23,7 @@ enum function_type_e
|
||||
{
|
||||
FUNCTION_FOREGROUND = 0, // idle, scanning
|
||||
FUNCTION_TRANSMIT, // transmitting
|
||||
FUNCTION_MONITOR, // receiving with squelch forced open
|
||||
// FUNCTION_MONITOR, // receiving with squelch forced open
|
||||
FUNCTION_NEW_RECEIVE, // signal just received
|
||||
FUNCTION_RECEIVE, // receive mode
|
||||
FUNCTION_POWER_SAVE, // sleeping
|
||||
|
@ -32,7 +32,7 @@ bool g_low_battery;
|
||||
bool g_low_battery_blink;
|
||||
uint16_t g_battery_check_counter;
|
||||
|
||||
volatile uint16_t g_power_save_10ms;
|
||||
volatile uint16_t g_power_save_tick_10ms;
|
||||
|
||||
/*
|
||||
Based on real measurement
|
||||
@ -145,6 +145,6 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
|
||||
UI_DisplayBattery(g_battery_display_level, g_low_battery_blink);
|
||||
}
|
||||
|
||||
g_low_batteryCountdown = 0;
|
||||
g_low_battery_tick_10ms = 0;
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ extern bool g_charging_with_type_c;
|
||||
extern bool g_low_battery;
|
||||
extern bool g_low_battery_blink;
|
||||
extern uint16_t g_battery_check_counter;
|
||||
extern volatile uint16_t g_power_save_10ms;
|
||||
extern volatile uint16_t g_power_save_tick_10ms;
|
||||
|
||||
unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
|
||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
||||
void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
|
||||
|
||||
#endif
|
||||
|
9
main.c
9
main.c
@ -67,6 +67,9 @@ void Main(void)
|
||||
| SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE
|
||||
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE;
|
||||
|
||||
g_monitor_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
SYSTICK_Init();
|
||||
|
||||
#ifdef ENABLE_UART
|
||||
@ -183,15 +186,15 @@ void Main(void)
|
||||
|
||||
if (g_eeprom.pwr_on_display_mode != PWR_ON_DISPLAY_MODE_NONE)
|
||||
{ // 3 second boot-up screen
|
||||
while (g_boot_counter_10ms > 0)
|
||||
while (g_boot_tick_10ms > 0)
|
||||
{
|
||||
if (KEYBOARD_Poll() != KEY_INVALID)
|
||||
{ // halt boot beeps and cancel boot screen
|
||||
g_boot_counter_10ms = 0;
|
||||
g_boot_tick_10ms = 0;
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_BOOT_BEEPS
|
||||
if ((g_boot_counter_10ms % 25) == 0)
|
||||
if ((g_boot_tick_10ms % 25) == 0)
|
||||
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
|
||||
#endif
|
||||
}
|
||||
|
37
misc.c
37
misc.c
@ -41,7 +41,7 @@ const uint8_t dtmf_rx_timeout_500ms = 10000 / 500; // 10 se
|
||||
const uint8_t dtmf_decode_ring_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
|
||||
const uint8_t dtmf_txstop_500ms = 3000 / 500; // 6 seconds
|
||||
|
||||
const uint8_t serial_config_tick_500ms = 3000 / 500; // 3 seconds
|
||||
const uint8_t serial_config_tick_500ms = 3000 / 500; // 3 seconds
|
||||
|
||||
const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
@ -78,9 +78,9 @@ const uint16_t power_save2_10ms = 200 / 10; // 200ms
|
||||
const uint16_t vox_stop_10ms = 1000 / 10; // 1 second
|
||||
#endif
|
||||
|
||||
const uint16_t noaa_tick_10ms = 5000 / 10; // 5 seconds
|
||||
const uint16_t noaa_tick_2_10ms = 500 / 10; // 500ms
|
||||
const uint16_t noaa_tick_3_10ms = 200 / 10; // 200ms
|
||||
const uint16_t noaa_tick_10ms = 5000 / 10; // 5 seconds
|
||||
const uint16_t noaa_tick_2_10ms = 500 / 10; // 500ms
|
||||
const uint16_t noaa_tick_3_10ms = 200 / 10; // 200ms
|
||||
|
||||
// ***********************************************
|
||||
|
||||
@ -126,7 +126,7 @@ uint8_t g_setting_side1_long;
|
||||
uint8_t g_setting_side2_short;
|
||||
uint8_t g_setting_side2_long;
|
||||
|
||||
bool g_monitor_enabled = false; // true opens the squelch
|
||||
bool g_monitor_enabled;
|
||||
|
||||
uint32_t g_custom_aes_key[4];
|
||||
bool g_has_custom_aes_key;
|
||||
@ -139,12 +139,12 @@ uint16_t g_eeprom_rssi_calib[7][4];
|
||||
|
||||
uint8_t g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
|
||||
|
||||
volatile uint16_t g_battery_save_tick_10ms = battery_save_count_10ms;
|
||||
|
||||
volatile bool g_power_save_expired;
|
||||
volatile uint16_t g_schedule_power_save_tick_10ms = battery_save_count_10ms;
|
||||
volatile bool g_schedule_power_save;
|
||||
|
||||
volatile uint16_t g_dual_watch_delay_10ms;
|
||||
volatile bool g_power_save_expired;
|
||||
|
||||
volatile uint16_t g_dual_watch_tick_10ms;
|
||||
volatile bool g_dual_watch_delay_down_expired = true;
|
||||
|
||||
volatile uint8_t g_serial_config_tick_500ms;
|
||||
@ -161,9 +161,9 @@ volatile uint16_t g_tail_tone_elimination_tick_10ms;
|
||||
#endif
|
||||
|
||||
bool g_speaker_enabled;
|
||||
uint8_t g_key_input_count_down;
|
||||
uint8_t g_key_input_count_down;
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
uint8_t g_key_lock_tick_500ms;
|
||||
uint8_t g_key_lock_tick_500ms;
|
||||
#endif
|
||||
uint8_t g_rtte_count_down;
|
||||
bool g_password_locked;
|
||||
@ -182,7 +182,7 @@ bool g_update_rssi;
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
alarm_state_t g_alarm_state;
|
||||
#endif
|
||||
uint16_t g_menu_count_down;
|
||||
uint16_t g_menu_tick_10ms;
|
||||
bool g_flag_reconfigure_vfos;
|
||||
uint8_t g_vfo_configure_mode;
|
||||
bool g_flag_reset_vfos;
|
||||
@ -210,16 +210,17 @@ bool g_cxcss_tail_found;
|
||||
#ifdef ENABLE_VOX
|
||||
bool g_vox_lost;
|
||||
bool g_vox_noise_detected;
|
||||
uint16_t g_vox_resume_count_down;
|
||||
uint16_t g_vox_pause_count_down;
|
||||
uint16_t g_vox_resume_tick_10ms;
|
||||
uint16_t g_vox_pause_tick_10ms;
|
||||
#endif
|
||||
|
||||
bool g_squelch_open;
|
||||
|
||||
uint8_t g_flash_light_state;
|
||||
uint16_t g_flash_light_blink_tick_10ms;
|
||||
|
||||
bool g_flag_end_tx;
|
||||
uint16_t g_low_batteryCountdown;
|
||||
uint16_t g_low_battery_tick_10ms;
|
||||
|
||||
reception_mode_t g_rx_reception_mode;
|
||||
|
||||
@ -228,7 +229,7 @@ scan_next_chan_t g_scan_current_scan_list;
|
||||
uint8_t g_scan_restore_channel;
|
||||
uint32_t g_scan_restore_frequency;
|
||||
bool g_scan_pause_time_mode; // set if we stopped in SCAN_RESUME_TIME mode
|
||||
volatile uint16_t g_scan_pause_10ms;
|
||||
volatile uint16_t g_scan_pause_tick_10ms;
|
||||
scan_state_dir_t g_scan_state_dir;
|
||||
|
||||
bool g_rx_vfo_is_active;
|
||||
@ -252,7 +253,7 @@ volatile bool g_next_time_slice;
|
||||
volatile uint8_t g_found_cdcss_tick_10ms;
|
||||
volatile uint8_t g_found_ctcss_tick_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
volatile uint16_t g_vox_stop_10ms;
|
||||
volatile uint16_t g_vox_stop_tick_10ms;
|
||||
#endif
|
||||
volatile bool g_next_time_slice_40ms;
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -264,7 +265,7 @@ volatile bool g_flag_tail_tone_elimination_complete;
|
||||
volatile bool g_schedule_fm;
|
||||
#endif
|
||||
|
||||
volatile uint16_t g_boot_counter_10ms = 4000 / 10; // 4 seconds
|
||||
volatile uint16_t g_boot_tick_10ms = 4000 / 10; // 4 seconds
|
||||
|
||||
int16_t g_current_rssi[2] = {0, 0}; // now one per VFO
|
||||
|
||||
|
25
misc.h
25
misc.h
@ -225,12 +225,12 @@ extern uint16_t g_eeprom_rssi_calib[7][4];
|
||||
|
||||
extern uint8_t g_user_channel_attributes[207];
|
||||
|
||||
extern volatile uint16_t g_battery_save_tick_10ms;
|
||||
|
||||
extern volatile bool g_power_save_expired;
|
||||
extern volatile uint16_t g_schedule_power_save_tick_10ms;
|
||||
extern volatile bool g_schedule_power_save;
|
||||
|
||||
extern volatile uint16_t g_dual_watch_delay_10ms;
|
||||
extern volatile bool g_power_save_expired;
|
||||
|
||||
extern volatile uint16_t g_dual_watch_tick_10ms;
|
||||
extern volatile bool g_dual_watch_delay_down_expired;
|
||||
|
||||
extern volatile uint8_t g_serial_config_tick_500ms;
|
||||
@ -252,7 +252,7 @@ extern bool g_speaker_enabled;
|
||||
extern uint8_t g_key_input_count_down;
|
||||
|
||||
#ifdef ENABLE_KEYLOCK
|
||||
extern uint8_t g_key_lock_tick_500ms;
|
||||
extern uint8_t g_key_lock_tick_500ms;
|
||||
#endif
|
||||
|
||||
extern uint8_t g_rtte_count_down;
|
||||
@ -270,7 +270,7 @@ extern uint8_t g_battery_voltage_index;
|
||||
extern css_scan_mode_t g_css_scan_mode;
|
||||
extern bool g_update_rssi;
|
||||
extern alarm_state_t g_alarm_state;
|
||||
extern uint16_t g_menu_count_down;
|
||||
extern uint16_t g_menu_tick_10ms;
|
||||
extern bool g_flag_reconfigure_vfos;
|
||||
extern uint8_t g_vfo_configure_mode;
|
||||
extern bool g_flag_reset_vfos;
|
||||
@ -298,16 +298,17 @@ extern bool g_cxcss_tail_found;
|
||||
#ifdef ENABLE_VOX
|
||||
extern bool g_vox_lost;
|
||||
extern bool g_vox_noise_detected;
|
||||
extern uint16_t g_vox_resume_count_down;
|
||||
extern uint16_t g_vox_pause_count_down;
|
||||
extern uint16_t g_vox_resume_tick_10ms;
|
||||
extern uint16_t g_vox_pause_tick_10ms;
|
||||
#endif
|
||||
|
||||
extern bool g_squelch_open;
|
||||
|
||||
extern uint8_t g_flash_light_state;
|
||||
extern uint16_t g_flash_light_blink_tick_10ms;
|
||||
|
||||
extern bool g_flag_end_tx;
|
||||
extern uint16_t g_low_batteryCountdown;
|
||||
extern uint16_t g_low_battery_tick_10ms;
|
||||
extern reception_mode_t g_rx_reception_mode;
|
||||
|
||||
extern uint8_t g_scan_next_channel; //
|
||||
@ -315,7 +316,7 @@ extern scan_next_chan_t g_scan_current_scan_list; //
|
||||
extern uint8_t g_scan_restore_channel; // the channel we were on before starting the RF scan
|
||||
extern uint32_t g_scan_restore_frequency; // the frequency we were on before starting the RF scan
|
||||
extern bool g_scan_pause_time_mode; // set if we stopped in SCAN_RESUME_TIME mode
|
||||
extern volatile uint16_t g_scan_pause_10ms; // ticks till we move to next channel/frequency
|
||||
extern volatile uint16_t g_scan_pause_tick_10ms; // ticks till we move to next channel/frequency
|
||||
extern scan_state_dir_t g_scan_state_dir; // the direction we're scanning in
|
||||
|
||||
|
||||
@ -337,7 +338,7 @@ extern bool g_unhide_hidden;
|
||||
extern volatile uint8_t g_found_cdcss_tick_10ms;
|
||||
extern volatile uint8_t g_found_ctcss_tick_10ms;
|
||||
#ifdef ENABLE_VOX
|
||||
extern volatile uint16_t g_vox_stop_10ms;
|
||||
extern volatile uint16_t g_vox_stop_tick_10ms;
|
||||
#endif
|
||||
extern volatile bool g_next_time_slice_40ms;
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -349,7 +350,7 @@ extern volatile bool g_flag_tail_tone_elimination_complete;
|
||||
extern volatile bool g_schedule_fm;
|
||||
#endif
|
||||
extern int16_t g_current_rssi[2]; // now one per VFO
|
||||
extern volatile uint16_t g_boot_counter_10ms;
|
||||
extern volatile uint16_t g_boot_tick_10ms;
|
||||
|
||||
unsigned int get_TX_VFO(void);
|
||||
unsigned int get_RX_VFO(void);
|
||||
|
149
radio.c
149
radio.c
@ -384,31 +384,32 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
|
||||
|
||||
RADIO_ConfigureSquelchAndOutputPower(p_vfo);
|
||||
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (p_vfo->am_mode && g_setting_am_fix)
|
||||
{
|
||||
AM_fix_reset(VFO);
|
||||
AM_fix_10ms(VFO);
|
||||
}
|
||||
else
|
||||
{ // don't do agc in FM mode
|
||||
BK4819_DisableAGC();
|
||||
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
|
||||
}
|
||||
#else
|
||||
if (p_vfo->am_mode)
|
||||
{
|
||||
BK4819_EnableAGC();
|
||||
}
|
||||
else
|
||||
{ // don't do agc in FM mode
|
||||
BK4819_DisableAGC();
|
||||
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_AM_FIX
|
||||
if (p_vfo->am_mode && g_setting_am_fix)
|
||||
{
|
||||
AM_fix_reset(VFO);
|
||||
AM_fix_10ms(VFO);
|
||||
}
|
||||
else
|
||||
{ // don't do agc in FM mode
|
||||
BK4819_DisableAGC();
|
||||
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
|
||||
}
|
||||
#else
|
||||
if (p_vfo->am_mode)
|
||||
{
|
||||
BK4819_EnableAGC();
|
||||
}
|
||||
else
|
||||
{ // don't do agc in FM mode
|
||||
BK4819_DisableAGC();
|
||||
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
// if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(Channel))
|
||||
if (IS_FREQ_CHANNEL(Channel))
|
||||
p_vfo->freq_in_channel = BOARD_find_channel(Frequency); // remember if a channel has this frequency
|
||||
p_vfo->freq_in_channel = BOARD_find_channel(Frequency); // find channel that has this frequency
|
||||
}
|
||||
|
||||
void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo)
|
||||
@ -633,9 +634,10 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
uint16_t interrupt_mask;
|
||||
uint32_t Frequency;
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
if (!g_speaker_enabled && !g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
// turn green LED off
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false);
|
||||
|
||||
switch (Bandwidth)
|
||||
@ -661,19 +663,18 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
|
||||
|
||||
while (1)
|
||||
{ // wait for the interrupt to clear ?
|
||||
const uint16_t status_bits = BK4819_ReadRegister(0x0C);
|
||||
if ((status_bits & (1u << 0)) == 0)
|
||||
{ // wait for interrupts to clear
|
||||
const uint16_t int_bits = BK4819_ReadRegister(0x0C);
|
||||
if ((int_bits & (1u << 0)) == 0)
|
||||
break;
|
||||
BK4819_WriteRegister(0x02, 0); // clear the interrupt bits
|
||||
SYSTEM_DelayMs(1);
|
||||
}
|
||||
|
||||
BK4819_WriteRegister(0x3F, 0); // disable interrupts
|
||||
|
||||
// mic gain 0.5dB/step 0 to 31
|
||||
BK4819_WriteRegister(0x7D, 0xE940 | (g_eeprom.mic_sensitivity_tuning & 0x1f));
|
||||
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
|
||||
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable .. doesn't work
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
|
||||
@ -690,10 +691,23 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
g_rx_vfo->squelch_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh,
|
||||
g_rx_vfo->squelch_close_glitch_thresh, g_rx_vfo->squelch_open_glitch_thresh);
|
||||
|
||||
// enable the RX front end
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
|
||||
|
||||
// AF RX Gain and DAC
|
||||
BK4819_WriteRegister(0x48, 0xB3A8); // 1011 00 111010 1000
|
||||
// BK4819_WriteRegister(0x48, 0xB3A8); // 1011 00 111010 1000
|
||||
if (g_rx_vfo->am_mode)
|
||||
{
|
||||
BK4819_WriteRegister(0x48, 0xB3A8); // 1011 0011 1010 1000
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_WriteRegister(0x48,
|
||||
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
|
||||
( 0u << 10) | // AF Rx Gain-1
|
||||
(g_eeprom.volume_gain << 4) | // AF Rx Gain-2
|
||||
(g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
}
|
||||
|
||||
interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
||||
@ -722,7 +736,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
// BK4819_SetTailDetection(670); // 67Hz
|
||||
//#endif
|
||||
|
||||
interrupt_mask = BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
@ -734,24 +748,13 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
// BK4819_SetTailDetection(CTCSS_OPTIONS[Code]);
|
||||
//#endif
|
||||
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CTCSS_FOUND |
|
||||
BK4819_REG_3F_CTCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code));
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CDCSS_FOUND |
|
||||
BK4819_REG_3F_CDCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CDCSS_FOUND | BK4819_REG_3F_CDCSS_LOST;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -765,11 +768,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
else
|
||||
{
|
||||
BK4819_SetCTCSSFrequency(2625);
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CTCSS_FOUND |
|
||||
BK4819_REG_3F_CTCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask |= BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -792,50 +791,21 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
// RX expander
|
||||
BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compand >= 2) ? g_rx_vfo->compand : 0);
|
||||
|
||||
#if 0
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled)
|
||||
#else
|
||||
if (!g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_EnableDTMF();
|
||||
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
}
|
||||
#else
|
||||
if (g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
BK4819_EnableDTMF();
|
||||
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
}
|
||||
#endif
|
||||
BK4819_EnableDTMF();
|
||||
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
BK4819_enable_mdc1200_rx(true);
|
||||
interrupt_mask |= BK4819_ReadRegister(0x3F) | BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL;
|
||||
interrupt_mask |= BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL;
|
||||
#endif
|
||||
|
||||
// enable/disable BK4819 selected interrupts
|
||||
// enable BK4819 interrupts
|
||||
BK4819_WriteRegister(0x3F, interrupt_mask);
|
||||
|
||||
FUNCTION_Init();
|
||||
|
||||
if (switch_to_function_foreground)
|
||||
{
|
||||
if (g_monitor_enabled)
|
||||
APP_start_listening(FUNCTION_MONITOR);
|
||||
else
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -887,9 +857,8 @@ void RADIO_enableTX(const bool fsk_tx)
|
||||
{
|
||||
BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel_bandwidth;
|
||||
|
||||
// disable the speaker
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
|
||||
|
||||
@ -1119,6 +1088,8 @@ void RADIO_EnableCxCSS(void)
|
||||
|
||||
void RADIO_PrepareCssTX(void)
|
||||
{
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
RADIO_PrepareTX();
|
||||
|
||||
SYSTEM_DelayMs(200);
|
||||
@ -1142,10 +1113,12 @@ void RADIO_tx_eot(void)
|
||||
{ // end-of-tx
|
||||
if (g_eeprom.dtmf_side_tone)
|
||||
{
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
SYSTEM_DelayMs(60);
|
||||
}
|
||||
|
||||
BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone);
|
||||
BK4819_PlayDTMFString(
|
||||
g_eeprom.dtmf_key_down_code,
|
||||
@ -1155,8 +1128,8 @@ void RADIO_tx_eot(void)
|
||||
g_eeprom.dtmf_code_persist_time,
|
||||
g_eeprom.dtmf_code_interval_time);
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
g_speaker_enabled = false;
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
else
|
||||
if (g_eeprom.roger_mode == ROGER_MODE_ROGER)
|
||||
|
51
scheduler.c
51
scheduler.c
@ -73,42 +73,55 @@ void SystickHandler(void)
|
||||
DECREMENT(g_found_ctcss_tick_10ms);
|
||||
|
||||
if (g_current_function == FUNCTION_FOREGROUND)
|
||||
DECREMENT_AND_TRIGGER(g_battery_save_tick_10ms, g_schedule_power_save);
|
||||
DECREMENT_AND_TRIGGER(g_schedule_power_save_tick_10ms, g_schedule_power_save);
|
||||
|
||||
if (g_current_function == FUNCTION_POWER_SAVE)
|
||||
DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_expired);
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
if (g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE)
|
||||
DECREMENT(g_dual_watch_delay_10ms);
|
||||
DECREMENT_AND_TRIGGER(g_power_save_tick_10ms, g_power_save_expired);
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
if (g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE)
|
||||
DECREMENT(g_dual_watch_tick_10ms);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch == DUAL_WATCH_OFF)
|
||||
if (g_is_noaa_mode && g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT)
|
||||
if (g_current_function != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(g_noaa_tick_10ms, g_schedule_noaa);
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_eeprom.dual_watch == DUAL_WATCH_OFF &&
|
||||
g_is_noaa_mode &&
|
||||
!g_monitor_enabled &&
|
||||
g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (g_current_function != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(g_noaa_tick_10ms, g_schedule_noaa);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode == CSS_SCAN_MODE_SCANNING)
|
||||
if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT)
|
||||
DECREMENT(g_scan_pause_10ms);
|
||||
if (!g_monitor_enabled && g_current_function != FUNCTION_TRANSMIT)
|
||||
DECREMENT(g_scan_pause_tick_10ms);
|
||||
|
||||
DECREMENT_AND_TRIGGER(g_tail_tone_elimination_tick_10ms, g_flag_tail_tone_elimination_complete);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
DECREMENT_AND_TRIGGER(g_tick_to_play_next_voice_10ms, g_flag_play_queued_voice);
|
||||
DECREMENT_AND_TRIGGER(g_play_next_voice_tick_10ms, g_flag_play_queued_voice);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR)
|
||||
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(g_fm_play_tick_10ms, g_schedule_fm);
|
||||
if (g_fm_scan_state != FM_SCAN_OFF &&
|
||||
!g_monitor_enabled &&
|
||||
g_current_function != FUNCTION_TRANSMIT &&
|
||||
g_current_function != FUNCTION_RECEIVE)
|
||||
{
|
||||
DECREMENT_AND_TRIGGER(g_fm_play_tick_10ms, g_schedule_fm);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
DECREMENT(g_vox_stop_10ms);
|
||||
DECREMENT(g_vox_stop_tick_10ms);
|
||||
#endif
|
||||
|
||||
DECREMENT(g_boot_counter_10ms);
|
||||
DECREMENT(g_boot_tick_10ms);
|
||||
}
|
||||
|
14
ui/fmradio.c
14
ui/fmradio.c
@ -121,11 +121,11 @@ void UI_DisplayFM(void)
|
||||
{ // frequency mode
|
||||
const uint32_t freq = g_eeprom.fm_frequency_playing;
|
||||
NUMBER_ToDigits(freq * 10000, str);
|
||||
#ifdef ENABLE_TRIM_TRAILING_ZEROS
|
||||
UI_DisplayFrequency(str, 30, 4, false, true);
|
||||
#else
|
||||
UI_DisplayFrequency(str, 23, 4, false, true);
|
||||
#endif
|
||||
#ifdef ENABLE_TRIM_TRAILING_ZEROS
|
||||
UI_DisplayFrequency(str, 30, 4, false, true);
|
||||
#else
|
||||
UI_DisplayFrequency(str, 23, 4, false, true);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ // user is entering a frequency
|
||||
@ -143,6 +143,8 @@ void UI_DisplayFM(void)
|
||||
|
||||
// *************************************
|
||||
|
||||
// can't do this during FM radio - audio clicks else
|
||||
if (g_fm_scan_state != FM_SCAN_OFF)
|
||||
{
|
||||
const uint16_t val_07 = BK1080_ReadRegister(0x07);
|
||||
const uint16_t val_0A = BK1080_ReadRegister(0x0A);
|
||||
@ -153,7 +155,7 @@ void UI_DisplayFM(void)
|
||||
(val_07 >> 0) & 0x000f);
|
||||
UI_PrintStringSmall(str, 0, LCD_WIDTH, 6);
|
||||
}
|
||||
|
||||
|
||||
// *************************************
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
|
10
ui/helper.c
10
ui/helper.c
@ -136,12 +136,8 @@ void UI_PrintStringSmall(const char *str, const unsigned int start, const unsign
|
||||
UI_print_string(str, start, end, line, (const uint8_t *)g_font_small_bold, ARRAY_SIZE(g_font_small_bold), ARRAY_SIZE(g_font_small_bold[0]));
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line)
|
||||
{
|
||||
UI_print_string(str, start, end, line, (const uint8_t *)g_font_small_4x5, ARRAY_SIZE(g_font_small_4x5), ARRAY_SIZE(g_font_small_4x5[0]));
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SMALLEST_FONT
|
||||
|
||||
void PutPixel(const unsigned int x, const unsigned int y, const bool fill)
|
||||
{
|
||||
@ -193,6 +189,8 @@ void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
|
||||
{
|
||||
const unsigned int char_width = ARRAY_SIZE(g_font_small[0]);
|
||||
|
@ -27,8 +27,9 @@ void UI_PrintStringSmall(const char *str, const unsigned int start, const unsign
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
void UI_PrintStringSmallBold(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
|
||||
#endif
|
||||
//void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
|
||||
void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned int y, const bool statusbar, const bool fill);
|
||||
#ifdef ENABLE_SMALLEST_FONT
|
||||
void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned int y, const bool statusbar, const bool fill);
|
||||
#endif
|
||||
void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer);
|
||||
void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool flag);
|
||||
void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);
|
||||
|
36
ui/main.c
36
ui/main.c
@ -302,7 +302,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
|
||||
#ifdef ENABLE_RX_SIGNAL_BAR
|
||||
if (g_center_line == CENTER_LINE_RSSI)
|
||||
{ // optional larger RSSI dBm, S-point and bar level
|
||||
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
|
||||
if (g_current_function == FUNCTION_RECEIVE)
|
||||
{
|
||||
UI_DisplayRSSIBar(rssi, true);
|
||||
}
|
||||
@ -355,9 +355,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
|
||||
if (rssi >= level01)
|
||||
rssi_level = 2;
|
||||
else
|
||||
if (rssi >= level0 ||
|
||||
g_current_function == FUNCTION_MONITOR ||
|
||||
g_current_function == FUNCTION_NEW_RECEIVE)
|
||||
if (rssi >= level0 || g_current_function == FUNCTION_NEW_RECEIVE)
|
||||
{
|
||||
rssi_level = 1;
|
||||
}
|
||||
@ -422,7 +420,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
|
||||
|
||||
void UI_DisplayMain(void)
|
||||
{
|
||||
#ifndef ENABLE_BIG_FREQ
|
||||
#if !defined(ENABLE_BIG_FREQ) && defined(ENABLE_SMALLEST_FONT)
|
||||
const unsigned int smallest_char_spacing = ARRAY_SIZE(g_font3x5[0]) + 1;
|
||||
#endif
|
||||
const unsigned int line0 = 0; // text screen line
|
||||
@ -589,9 +587,7 @@ void UI_DisplayMain(void)
|
||||
else
|
||||
{ // receiving .. show the RX symbol
|
||||
mode = 2;
|
||||
if ((g_current_function == FUNCTION_RECEIVE ||
|
||||
g_current_function == FUNCTION_MONITOR ||
|
||||
g_current_function == FUNCTION_NEW_RECEIVE) &&
|
||||
if ((g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_NEW_RECEIVE) &&
|
||||
g_eeprom.rx_vfo == vfo_num)
|
||||
{
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
@ -776,7 +772,7 @@ void UI_DisplayMain(void)
|
||||
|
||||
// no room for these symbols
|
||||
|
||||
#else
|
||||
#elif defined(ENABLE_SMALLEST_FONT)
|
||||
{
|
||||
unsigned int x = LCD_WIDTH + LCD_WIDTH - 1 - (smallest_char_spacing * 1) - (smallest_char_spacing * 4);
|
||||
|
||||
@ -795,6 +791,24 @@ void UI_DisplayMain(void)
|
||||
UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);
|
||||
//x += smallest_char_spacing * 1;
|
||||
}
|
||||
#else
|
||||
{
|
||||
strcpy(str, " ");
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
|
||||
{
|
||||
//g_eeprom.vfo_info[vfo_num].freq_in_channel = BOARD_find_channel(frequency);
|
||||
if (g_eeprom.vfo_info[vfo_num].freq_in_channel <= USER_CHANNEL_LAST)
|
||||
{ // the channel number that contains this VFO frequency
|
||||
str[0] = 'F';
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
str[1] = 'C';
|
||||
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - 1 - (6 * 2), 0, line + 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -903,9 +917,7 @@ void UI_DisplayMain(void)
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE)
|
||||
{ // we're free to use the middle line
|
||||
|
||||
const bool rx = (g_current_function == FUNCTION_RECEIVE ||
|
||||
g_current_function == FUNCTION_MONITOR ||
|
||||
g_current_function == FUNCTION_NEW_RECEIVE);
|
||||
const bool rx = (g_current_function == FUNCTION_RECEIVE);
|
||||
|
||||
#ifdef ENABLE_TX_TIMEOUT_BAR
|
||||
// show the TX timeout count down
|
||||
|
@ -54,8 +54,8 @@ void UI_DisplayStatus(const bool test_display)
|
||||
}
|
||||
else
|
||||
if (g_current_function == FUNCTION_RECEIVE ||
|
||||
g_current_function == FUNCTION_MONITOR ||
|
||||
g_current_function == FUNCTION_NEW_RECEIVE)
|
||||
g_current_function == FUNCTION_NEW_RECEIVE ||
|
||||
g_monitor_enabled)
|
||||
{
|
||||
memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
||||
x1 = x + sizeof(BITMAP_RX);
|
||||
@ -140,7 +140,7 @@ void UI_DisplayStatus(const bool test_display)
|
||||
// DUAL-WATCH indicator
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display)
|
||||
{
|
||||
if (g_dual_watch_delay_10ms > dual_watch_delay_toggle_10ms ||
|
||||
if (g_dual_watch_tick_10ms > dual_watch_delay_toggle_10ms ||
|
||||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
|
||||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
|
||||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
|
||||
@ -157,7 +157,8 @@ void UI_DisplayStatus(const bool test_display)
|
||||
}
|
||||
x += sizeof(BITMAP_TDR_RUNNING);
|
||||
|
||||
if (g_current_function == FUNCTION_MONITOR)
|
||||
// monitor
|
||||
if (g_monitor_enabled)
|
||||
{
|
||||
memcpy(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR));
|
||||
x1 = x + sizeof(BITMAP_MONITOR);
|
||||
|
Loading…
x
Reference in New Issue
Block a user