0
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:
OneOfEleven 2023-10-29 22:33:38 +00:00
parent 230fdccf10
commit f3e347bc5a
39 changed files with 951 additions and 770 deletions

View File

@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0
ENABLE_LTO := 1 ENABLE_LTO := 1
# UART Programming 2.9 kB # UART Programming 2.9 kB
ENABLE_UART := 1 ENABLE_UART := 1
ENABLE_UART_DEBUG := 1 ENABLE_UART_DEBUG := 0
# AirCopy 2.5 kB # AirCopy 2.5 kB
ENABLE_AIRCOPY := 0 ENABLE_AIRCOPY := 0
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1
@ -32,13 +32,16 @@ ENABLE_VOX := 0
ENABLE_REDUCE_LOW_MID_TX_POWER := 1 ENABLE_REDUCE_LOW_MID_TX_POWER := 1
# Tx Alarm 0.6 kB # Tx Alarm 0.6 kB
ENABLE_ALARM := 0 ENABLE_ALARM := 0
ENABLE_TX1750 := 0 ENABLE_TX1750 := 1
# MDC1200 2.8 kB # MDC1200 2.8 kB
ENABLE_MDC1200 := 1 ENABLE_MDC1200 := 1
ENABLE_PWRON_PASSWORD := 0 ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 1 ENABLE_RESET_AES_KEY := 1
ENABLE_BIG_FREQ := 0 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 # trim trailing 0.044 kB
ENABLE_TRIM_TRAILING_ZEROS := 1 ENABLE_TRIM_TRAILING_ZEROS := 1
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
@ -51,6 +54,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_CONTRAST := 0 ENABLE_CONTRAST := 0
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_DTMF_CALL_FLASH_LIGHT := 1 ENABLE_DTMF_CALL_FLASH_LIGHT := 1
ENABLE_FLASH_LIGHT_SOS_TONE := 1
ENABLE_SHOW_CHARGE_LEVEL := 0 ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_FREQ_SEARCH_TIMEOUT := 0 ENABLE_FREQ_SEARCH_TIMEOUT := 0
@ -322,6 +326,9 @@ endif
ifeq ($(ENABLE_SMALL_BOLD),1) ifeq ($(ENABLE_SMALL_BOLD),1)
CFLAGS += -DENABLE_SMALL_BOLD CFLAGS += -DENABLE_SMALL_BOLD
endif endif
ifeq ($(ENABLE_SMALLEST_FONT),1)
CFLAGS += -DENABLE_SMALLEST_FONT
endif
ifeq ($(ENABLE_TRIM_TRAILING_ZEROS),1) ifeq ($(ENABLE_TRIM_TRAILING_ZEROS),1)
CFLAGS += -DENABLE_TRIM_TRAILING_ZEROS CFLAGS += -DENABLE_TRIM_TRAILING_ZEROS
endif endif
@ -382,6 +389,9 @@ endif
ifeq ($(ENABLE_DTMF_CALL_FLASH_LIGHT),1) ifeq ($(ENABLE_DTMF_CALL_FLASH_LIGHT),1)
CFLAGS += -DENABLE_DTMF_CALL_FLASH_LIGHT CFLAGS += -DENABLE_DTMF_CALL_FLASH_LIGHT
endif endif
ifeq ($(ENABLE_FLASH_LIGHT_SOS_TONE),1)
CFLAGS += -DENABLE_FLASH_LIGHT_SOS_TONE
endif
ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1) ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1)
CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL
endif endif

View File

@ -70,6 +70,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0 standard CTCSS tail phase shift rath
ENABLE_CONTRAST := 0 add contrast menu ENABLE_CONTRAST := 0 add contrast menu
ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up 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_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_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_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 ENABLE_FREQ_SEARCH_TIMEOUT := 0 timeout if FREQ not found when using F+4 search function

View File

@ -305,7 +305,6 @@
case FUNCTION_FOREGROUND: case FUNCTION_FOREGROUND:
case FUNCTION_NEW_RECEIVE: case FUNCTION_NEW_RECEIVE:
case FUNCTION_RECEIVE: case FUNCTION_RECEIVE:
case FUNCTION_MONITOR:
break; break;
} }

View File

@ -55,10 +55,17 @@ static void ACTION_FlashLight(void)
case FLASHLIGHT_BLINK: case FLASHLIGHT_BLINK:
g_flash_light_blink_tick_10ms = 0; g_flash_light_blink_tick_10ms = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
g_flash_light_state = FLASHLIGHT_SOS; g_flash_light_state = FLASHLIGHT_SOS;
if (g_current_function == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_RECEIVE);
break; break;
case FLASHLIGHT_SOS: case FLASHLIGHT_SOS:
#ifdef ENABLE_FLASH_LIGHT_SOS_TONE
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
#endif
// Fallthrough // Fallthrough
@ -89,29 +96,39 @@ void ACTION_Power(void)
void ACTION_Monitor(void) void ACTION_Monitor(void)
{ {
if (g_current_function != FUNCTION_MONITOR) if (!g_monitor_enabled) // (g_current_function != FUNCTION_MONITOR)
{ // enable the monitor { // enable monitor mode
RADIO_select_vfos();
g_beep_to_play = BEEP_NONE;
g_monitor_enabled = true;
// g_squelch_open = true;
#ifdef ENABLE_NOAA #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; g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
#endif #endif
g_monitor_enabled = true;
RADIO_setup_registers(true); APP_start_listening();
APP_start_listening(FUNCTION_MONITOR);
return; return;
} }
// disable monitor
g_monitor_enabled = false; g_monitor_enabled = false;
if (!g_speaker_enabled)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
if (g_scan_state_dir != SCAN_STATE_DIR_OFF) 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 #ifdef g_power_save_expired
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode) if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
{ {
g_noaa_tick_10ms = noaa_tick_10ms; g_noaa_tick_10ms = noaa_tick_10ms;
g_schedule_noaa = false; g_schedule_noaa = false;
} }
#endif #endif
@ -134,12 +151,12 @@ void ACTION_Scan(bool bRestart)
if (g_fm_radio_mode) if (g_fm_radio_mode)
{ {
if (g_current_function != FUNCTION_RECEIVE && 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); GUI_SelectNextDisplay(DISPLAY_FM);
g_monitor_enabled = false; // g_monitor_enabled = false;
if (g_fm_scan_state != FM_SCAN_OFF) if (g_fm_scan_state != FM_SCAN_OFF)
{ // already scanning { // already scanning
@ -186,6 +203,7 @@ void ACTION_Scan(bool bRestart)
{ // not in freq/ctcss/cdcss search mode { // not in freq/ctcss/cdcss search mode
g_monitor_enabled = false; g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
DTMF_clear_RX(); DTMF_clear_RX();
@ -213,7 +231,7 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel // jump to the next channel
APP_channel_next(true, g_scan_state_dir); 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_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
@ -233,13 +251,14 @@ void ACTION_Scan(bool bRestart)
// start scanning // start scanning
// disable monitor mode
g_monitor_enabled = false; g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
RADIO_setup_registers(true); RADIO_setup_registers(true);
APP_channel_next(true, SCAN_STATE_DIR_FORWARD); 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; g_scan_pause_time_mode = false;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -270,14 +289,13 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel // jump to the next channel
APP_channel_next(true, g_scan_state_dir); 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_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
} }
else else
{ // stop scanning { // stop scanning
g_monitor_enabled = false;
APP_stop_scan(); APP_stop_scan();
g_request_display_screen = DISPLAY_MAIN; g_request_display_screen = DISPLAY_MAIN;
} }
@ -324,7 +342,9 @@ void ACTION_Scan(bool bRestart)
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
void ACTION_FM(void) 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) if (g_fm_radio_mode)
{ {
@ -332,7 +352,7 @@ void ACTION_Scan(bool bRestart)
g_input_box_index = 0; g_input_box_index = 0;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_resume_count_down = 80; g_vox_resume_tick_10ms = 80;
#endif #endif
g_flag_reconfigure_vfos = true; g_flag_reconfigure_vfos = true;
@ -340,7 +360,7 @@ void ACTION_Scan(bool bRestart)
return; return;
} }
g_monitor_enabled = false; // g_monitor_enabled = false;
RADIO_select_vfos(); RADIO_select_vfos();
RADIO_setup_registers(true); 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) if (!key_held && key_pressed)
{
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return; return;
}
if (key_held || key_pressed) if (key_held || key_pressed)
{ {

View File

@ -80,6 +80,8 @@ void AIRCOPY_init(void)
// turn the backlight ON // turn the backlight ON
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
RADIO_setup_registers(true); RADIO_setup_registers(true);
BK4819_SetupAircopy(AIRCOPY_DATA_PACKET_SIZE); BK4819_SetupAircopy(AIRCOPY_DATA_PACKET_SIZE);

610
app/app.c

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ extern const uint8_t orig_pga;
void APP_end_tx(void); void APP_end_tx(void);
void APP_stop_scan(void); void APP_stop_scan(void);
void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction); 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); uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step);
void APP_time_slice_10ms(void); void APP_time_slice_10ms(void);
void APP_time_slice_500ms(void); void APP_time_slice_500ms(void);

View File

@ -439,8 +439,8 @@ bool DTMF_Reply(void)
if (g_eeprom.dtmf_side_tone) if (g_eeprom.dtmf_side_tone)
{ // the user will also hear the transmitted tones { // the user will also hear the transmitted tones
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
} }
SYSTEM_DelayMs(Delay); SYSTEM_DelayMs(Delay);
@ -455,8 +455,8 @@ bool DTMF_Reply(void)
g_eeprom.dtmf_code_persist_time, g_eeprom.dtmf_code_persist_time,
g_eeprom.dtmf_code_interval_time); g_eeprom.dtmf_code_interval_time);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false; g_speaker_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
BK4819_ExitDTMF_TX(false); BK4819_ExitDTMF_TX(false);

View File

@ -98,16 +98,19 @@ int FM_ConfigureChannelState(void)
void FM_TurnOff(void) void FM_TurnOff(void)
{ {
g_fm_radio_mode = false; g_fm_radio_mode = false;
g_fm_scan_state = FM_SCAN_OFF; g_fm_scan_state = FM_SCAN_OFF;
g_fm_restore_tick_10ms = 0; g_fm_restore_tick_10ms = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); if (!g_monitor_enabled)
{
g_speaker_enabled = false; g_speaker_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
}
BK1080_Init(0, false); BK1080_Init(0, false);
g_update_display = true;
g_update_status = true; g_update_status = true;
} }
@ -125,9 +128,8 @@ void FM_EraseChannels(void)
void FM_Tune(uint16_t Frequency, int8_t Step, bool flag) void FM_Tune(uint16_t Frequency, int8_t Step, bool flag)
{ {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false; 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; 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(); SETTINGS_save_fm();
g_fm_play_tick_10ms = 0; g_fm_play_tick_10ms = 0;
g_schedule_fm = false; g_schedule_fm = false;
g_ask_to_save = false; g_ask_to_save = false;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_update_display = true;
} }
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) 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) static void FM_Key_EXIT(bool key_pressed, bool key_held)
{ {
(void)key_held;
g_key_input_count_down = key_input_timeout_500ms; g_key_input_count_down = key_input_timeout_500ms;
if (key_held || key_pressed) // if (key_held || key_pressed)
if (key_pressed)
return; return;
if (g_fm_scan_state == FM_SCAN_OFF) 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) static void FM_Key_MENU(bool key_pressed, bool key_held)
{ {
(void)key_held;
unsigned int i; unsigned int i;
int channel = -1; int channel = -1;
g_key_input_count_down = key_input_timeout_500ms; 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 return; // key still pressed
// see if the frequency is already stored in a channel // 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 else
g_ask_to_delete = true; g_ask_to_delete = true;
} }
return; return;
} }
@ -666,8 +675,8 @@ void FM_Play(void)
if (!g_eeprom.fm_channel_mode) if (!g_eeprom.fm_channel_mode)
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
return; return;
@ -694,14 +703,15 @@ void FM_Play(void)
void FM_Start(void) void FM_Start(void)
{ {
g_fm_radio_mode = true; g_fm_radio_mode = true;
g_fm_scan_state = FM_SCAN_OFF; g_fm_scan_state = FM_SCAN_OFF;
g_fm_restore_tick_10ms = 0; g_fm_restore_tick_10ms = 0;
BK1080_Init(g_eeprom.fm_frequency_playing, true); BK1080_Init(g_eeprom.fm_frequency_playing, true);
g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_update_display = true;
g_update_status = true; g_update_status = true;
} }

View File

@ -41,13 +41,14 @@
#include "radio.h" #include "radio.h"
#include "settings.h" #include "settings.h"
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/ui.h" #include "ui/main.h"
#include "ui/menu.h" #include "ui/menu.h"
#include "ui/ui.h"
bool scanning_paused(void) bool scanning_paused(void)
{ {
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) && 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 { // scanning isn't paused
return false; return false;
} }
@ -130,6 +131,7 @@ void toggle_chan_scanlist(void)
RADIO_select_vfos(); RADIO_select_vfos();
RADIO_ApplyOffset(g_tx_vfo, false); RADIO_ApplyOffset(g_tx_vfo, false);
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo); RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
RADIO_setup_registers(true); RADIO_setup_registers(true);
// find the first channel that contains this frequency // 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 { // key held down
if (key_pressed) if (key_pressed)
{ // and pressed {
if (g_current_display_screen == DISPLAY_MAIN) if (g_current_display_screen == DISPLAY_MAIN)
{ {
if (g_input_box_index > 0) 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); 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)) if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
{ // user is entering channel number { // 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) if (g_input_box_index != 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
g_request_display_screen = DISPLAY_MAIN;
return; return;
} }
@ -500,7 +503,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
g_eeprom.user_channel[Vfo] = (uint8_t)Channel; 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_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_update_display = true;
return; return;
} }
@ -521,7 +525,6 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
return; 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_request_save_channel = 1;
g_vfo_configure_mode = VFO_CONFIGURE; g_vfo_configure_mode = VFO_CONFIGURE;
g_update_display = true;
return; return;
} }
@ -594,7 +598,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
g_another_voice_id = (voice_id_t)Key; g_another_voice_id = (voice_id_t)Key;
#endif #endif
g_request_display_screen = DISPLAY_MAIN; // g_request_display_screen = DISPLAY_MAIN;
return; 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_eeprom.screen_channel[Vfo] = Channel;
g_request_save_vfo = true; g_request_save_vfo = true;
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
g_update_display = true;
return; return;
} }
} }
#endif #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) 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; return;
} }
if (key_held && key_pressed) if (!key_held)
{ // exit key held down return;
if (g_input_box_index > 0 || g_dtmf_input_box_index > 0 || g_dtmf_input_mode) if (key_pressed)
{ // cancel key input mode (channel/frequency entry) return;
g_dtmf_input_mode = false;
g_dtmf_input_box_index = 0; #ifdef ENABLE_FMRADIO
memset(g_dtmf_string, 0, sizeof(g_dtmf_string)); if (g_fm_radio_mode)
g_input_box_index = 0; {
g_request_display_screen = DISPLAY_MAIN; ACTION_FM();
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; 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 (!key_pressed)
{ {
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(Channel)) if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
{ // key released in frequency mode (Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
{ // key released
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS #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 { // re-enable the squelch
APP_start_listening(FUNCTION_RECEIVE);
g_monitor_enabled = false; g_monitor_enabled = false;
APP_start_listening();
} }
#endif #endif
@ -898,7 +926,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
uint8_t Next; uint8_t Next;
if (IS_FREQ_CHANNEL(Channel)) if (IS_FREQ_CHANNEL(Channel))
{ // step/down in frequency { // frequency mode
frequency_band_t new_band; frequency_band_t new_band;
const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency); 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) if (key_held && key_pressed && !monitor_was_enabled)
{ // open the squelch if the user holds the key down { // open the squelch if the user holds the key down
g_monitor_enabled = true; g_monitor_enabled = true;
APP_start_listening(FUNCTION_MONITOR); APP_start_listening();
} }
#endif #endif
@ -958,9 +986,20 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
return; return;
} }
// suppress audio click // channel mode
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false; 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); Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
if (Next == 0xFF) if (Next == 0xFF)
@ -989,20 +1028,23 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
} }
#endif #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; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
return; return;
} }
// g_speaker_enabled = false;
// g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false;
// jump to the next channel // jump to the next channel
APP_channel_next(false, Direction); APP_channel_next(false, Direction);
// go NOW // go NOW
g_scan_pause_10ms = 0; g_scan_pause_tick_10ms = 0;
g_scan_pause_time_mode = false; g_scan_pause_time_mode = false;
g_squelch_open = false; g_squelch_open = false;
g_rx_reception_mode = RX_MODE_NONE; 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 #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && key != KEY_PTT && key != KEY_EXIT) if (g_fm_radio_mode && key != KEY_PTT && key != KEY_EXIT)
{ {
if (!key_held && key_pressed) if (g_current_display_screen == DISPLAY_FM)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; {
return; if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
} }
#endif #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); MAIN_Key_MENU(key_pressed, key_held);
break; break;
case KEY_UP: 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; break;
case KEY_DOWN: 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; break;
case KEY_EXIT: case KEY_EXIT:
MAIN_Key_EXIT(key_pressed, key_held); MAIN_Key_EXIT(key_pressed, key_held);

View File

@ -86,7 +86,7 @@ void MENU_start_css_scan(int8_t Direction)
MENU_SelectNextCode(); 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) void MENU_stop_css_scan(void)
@ -939,7 +939,7 @@ void MENU_SelectNextCode(void)
RADIO_setup_registers(true); 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; g_update_display = true;
} }
@ -2014,11 +2014,11 @@ void MENU_process_key(key_code_t Key, bool key_pressed, bool key_held)
#endif #endif
g_menu_cursor == MENU_BAT_CAL) g_menu_cursor == MENU_BAT_CAL)
{ {
g_menu_count_down = menu_timeout_long_500ms; g_menu_tick_10ms = menu_timeout_long_500ms;
} }
else else
{ {
g_menu_count_down = menu_timeout_500ms; g_menu_tick_10ms = menu_timeout_500ms;
} }
} }
} }

View File

@ -19,7 +19,9 @@
#include "app/search.h" #include "app/search.h"
#include "audio.h" #include "audio.h"
#include "board.h" #include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/gpio.h"
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h" #include "driver/uart.h"
#endif #endif
@ -400,6 +402,9 @@ void SEARCH_Start(void)
g_rx_vfo->step_setting = BackupStep; g_rx_vfo->step_setting = BackupStep;
g_rx_vfo->step_freq = BackupStepFreq; g_rx_vfo->step_freq = BackupStepFreq;
g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
RADIO_setup_registers(true); RADIO_setup_registers(true);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA

View File

@ -345,9 +345,9 @@ uint32_t GetOffsetedF(uint32_t f) {
bool IsTXAllowed() { return g_setting_ALL_TX != 2; } bool IsTXAllowed() { return g_setting_ALL_TX != 2; }
static void ToggleAudio(bool on) { static void ToggleAudio(bool on) {
if (on) { if (on)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
} else { else {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
} }
} }

69
audio.c
View File

@ -68,7 +68,7 @@
voice_id_t g_voice_id[8]; voice_id_t g_voice_id[8];
uint8_t g_voice_read_index; uint8_t g_voice_read_index;
uint8_t g_voice_write_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; volatile bool g_flag_play_queued_voice;
voice_id_t g_another_voice_id = VOICE_ID_INVALID; 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) 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 ToneFrequency;
uint16_t Duration; 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 #ifdef ENABLE_AIRCOPY
// if (g_current_display_screen == DISPLAY_AIRCOPY || g_aircopy_state != AIRCOPY_READY) // if (g_current_display_screen == DISPLAY_AIRCOPY || g_aircopy_state != AIRCOPY_READY)
// return; // return;
#endif #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) if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
@ -150,7 +157,9 @@ void AUDIO_PlayBeep(beep_type_t Beep)
break; break;
} }
// BK4819_PlayTone(ToneFrequency, true);
BK4819_StartTone1(ToneFrequency, 96, true); BK4819_StartTone1(ToneFrequency, 96, true);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -200,29 +209,24 @@ void AUDIO_PlayBeep(beep_type_t Beep)
} }
SYSTEM_DelayMs(Duration); SYSTEM_DelayMs(Duration);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
// SYSTEM_DelayMs(20);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
#ifdef ENABLE_VOX
g_vox_resume_count_down = 80;
#endif
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
// SYSTEM_DelayMs(5); #ifdef ENABLE_VOX
g_vox_resume_tick_10ms = 80; // 800ms
#endif
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
BK4819_TurnsOffTones_TurnsOnRX(); BK4819_TurnsOffTones_TurnsOnRX();
// SYSTEM_DelayMs(5);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
// restore the register BK4819_WriteRegister(0x71, tone_val);
BK4819_WriteRegister(0x71, ToneConfig);
if (g_speaker_enabled) // BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // BK4819_SetAF(BK4819_AF_MUTE);
// BK4819_WriteRegister(0x47, af_val);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (g_fm_radio_mode) if (g_fm_radio_mode)
@ -230,7 +234,14 @@ void AUDIO_PlayBeep(beep_type_t Beep)
#endif #endif
if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode) if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
{
BK4819_Sleep(); BK4819_Sleep();
}
else
if (g_speaker_enabled || g_monitor_enabled)
{
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
}
} }
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -287,7 +298,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
} }
#ifdef MUTE_AUDIO_FOR_VOICE #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); BK4819_SetAF(BK4819_AF_MUTE);
#endif #endif
@ -301,7 +312,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_resume_count_down = 2000; g_vox_resume_tick_10ms = 2000;
#endif #endif
SYSTEM_DelayMs(5); SYSTEM_DelayMs(5);
@ -315,7 +326,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
{ {
SYSTEM_DelayMs(Delay * 10); 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); BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -330,14 +341,14 @@ void AUDIO_PlayBeep(beep_type_t Beep)
g_voice_read_index = 0; g_voice_read_index = 0;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_resume_count_down = 80; g_vox_resume_tick_10ms = 80;
#endif #endif
return; return;
} }
g_voice_read_index = 1; 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; g_flag_play_queued_voice = false;
return; return;
@ -449,11 +460,11 @@ void AUDIO_PlayBeep(beep_type_t Beep)
AUDIO_PlayVoice(VoiceID); AUDIO_PlayVoice(VoiceID);
g_tick_to_play_next_voice_10ms = Delay; g_play_next_voice_tick_10ms = Delay;
g_flag_play_queued_voice = false; g_flag_play_queued_voice = false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_resume_count_down = 2000; g_vox_resume_tick_10ms = 2000;
#endif #endif
return; return;
@ -463,7 +474,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
// *********************** // ***********************
// unmute the radios audio // 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); BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -477,7 +488,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
// ********************** // **********************
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_resume_count_down = 80; g_vox_resume_tick_10ms = 80;
#endif #endif
g_voice_write_index = 0; g_voice_write_index = 0;

View File

@ -129,7 +129,7 @@ typedef enum voice_id_e voice_id_t;
extern voice_id_t g_voice_id[8]; extern voice_id_t g_voice_id[8];
extern uint8_t g_voice_read_index; extern uint8_t g_voice_read_index;
extern uint8_t g_voice_write_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 volatile bool g_flag_play_queued_voice;
extern voice_id_t g_another_voice_id; extern voice_id_t g_another_voice_id;

View File

@ -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) #define BK4819_REG_30_MASK_ENABLE_RX_DSP (0x1U << BK4819_REG_30_SHIFT_ENABLE_RX_DSP)
enum { enum {
BK4819_REG_30_ENABLE_VCO_CALIB = (0x1U << BK4819_REG_30_SHIFT_ENABLE_VCO_CALIB), BK4819_REG_30_ENABLE_VCO_CALIB = ( 1u << 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 = ( 1u << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN),
BK4819_REG_30_ENABLE_UNKNOWN = (0x1U << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN), BK4819_REG_30_ENABLE_RX_LINK = (15u << BK4819_REG_30_SHIFT_ENABLE_RX_LINK),
BK4819_REG_30_DISABLE_UNKNOWN = (0x0U << BK4819_REG_30_SHIFT_ENABLE_UNKNOWN), BK4819_REG_30_ENABLE_AF_DAC = ( 1u << BK4819_REG_30_SHIFT_ENABLE_AF_DAC),
BK4819_REG_30_ENABLE_RX_LINK = (0xFU << BK4819_REG_30_SHIFT_ENABLE_RX_LINK), BK4819_REG_30_ENABLE_DISC_MODE = ( 1u << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE),
BK4819_REG_30_DISABLE_RX_LINK = (0x0U << BK4819_REG_30_SHIFT_ENABLE_RX_LINK), BK4819_REG_30_ENABLE_PLL_VCO = (15u << BK4819_REG_30_SHIFT_ENABLE_PLL_VCO),
BK4819_REG_30_ENABLE_AF_DAC = (0x1U << BK4819_REG_30_SHIFT_ENABLE_AF_DAC), BK4819_REG_30_ENABLE_PA_GAIN = ( 1u << BK4819_REG_30_SHIFT_ENABLE_PA_GAIN),
BK4819_REG_30_DISABLE_AF_DAC = (0x0U << BK4819_REG_30_SHIFT_ENABLE_AF_DAC), BK4819_REG_30_ENABLE_MIC_ADC = ( 1u << BK4819_REG_30_SHIFT_ENABLE_MIC_ADC),
BK4819_REG_30_ENABLE_DISC_MODE = (0x1U << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE), BK4819_REG_30_ENABLE_TX_DSP = ( 1u << BK4819_REG_30_SHIFT_ENABLE_TX_DSP),
BK4819_REG_30_DISABLE_DISC_MODE = (0x0U << BK4819_REG_30_SHIFT_ENABLE_DISC_MODE), BK4819_REG_30_ENABLE_RX_DSP = ( 1u << BK4819_REG_30_SHIFT_ENABLE_RX_DSP)
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),
}; };
// REG 3F // REG 3F

View File

@ -19,6 +19,7 @@
#include "bk4819.h" #include "bk4819.h"
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#include "bsp/dp32g030/portcon.h" #include "bsp/dp32g030/portcon.h"
#include "functions.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/systick.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 // 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 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) 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 // trigger a PLL/VCO update
// //
const uint16_t reg = BK4819_ReadRegister(0x30); const uint16_t reg = BK4819_ReadRegister(0x30);
// BK4819_WriteRegister(0x30, reg & ~(1u << 15) & (15u << 4)); BK4819_WriteRegister(0x30, 0);
BK4819_WriteRegister(0x30, 0x0200);
BK4819_WriteRegister(0x30, reg); BK4819_WriteRegister(0x30, reg);
} }
} }
@ -871,11 +874,9 @@ void BK4819_SetupSquelch(
void BK4819_SetAF(BK4819_af_type_t AF) void BK4819_SetAF(BK4819_af_type_t AF)
{ {
// AF Output Inverse Mode = Inverse BK4819_WriteRegister(0x47, 0);
// Undocumented bits 0x2040 // BK4819_WriteRegister(0x47, 0x6040 | (AF << 8)); // 0110 0000 0100 0000
// BK4819_WriteRegister(0x47, (1u << 14) | (1u << 13) | ((AF & 15u) << 8) | (1u << 6));
// BK4819_WriteRegister(0x47, 0x6040 | (AF << 8));
BK4819_WriteRegister(0x47, (6u << 12) | (AF << 8) | (1u << 6));
} }
void BK4819_RX_TurnOn(void) void BK4819_RX_TurnOn(void)
@ -896,21 +897,19 @@ void BK4819_RX_TurnOn(void)
// //
BK4819_WriteRegister(0x37, 0x1F0F); // 0001 1111 0000 1111 BK4819_WriteRegister(0x37, 0x1F0F); // 0001 1111 0000 1111
// turn everything off
BK4819_WriteRegister(0x30, 0); BK4819_WriteRegister(0x30, 0);
BK4819_WriteRegister(0x30,
// and on again .. BK4819_REG_30_ENABLE_VCO_CALIB |
// // BK4819_REG_30_ENABLE_UNKNOWN |
// Enable VCO Calibration BK4819_REG_30_ENABLE_RX_LINK |
// Enable RX Link BK4819_REG_30_ENABLE_AF_DAC |
// Enable AF DAC BK4819_REG_30_ENABLE_DISC_MODE |
// Enable PLL/VCO BK4819_REG_30_ENABLE_PLL_VCO |
// Disable PA Gain // BK4819_REG_30_ENABLE_PA_GAIN |
// Disable MIC ADC // BK4819_REG_30_ENABLE_MIC_ADC |
// Disable TX DSP // BK4819_REG_30_ENABLE_TX_DSP |
// Enable RX DSP BK4819_REG_30_ENABLE_RX_DSP |
// 0);
BK4819_WriteRegister(0x30, 0xBFF1); // 1 0 1111 1 1 1111 0 0 0 1
} }
void BK4819_set_rf_filter_path(uint32_t Frequency) 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) 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_MUTE);
BK4819_SetAF(BK4819_AF_BEEP); BK4819_SetAF(BK4819_AF_BEEP);
// BK4819_SetAF(BK4819_AF_TONE);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
@ -1065,36 +1068,88 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const
if (set_dac) if (set_dac)
{ {
BK4819_WriteRegister(0x30, 0); 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_WriteRegister(0x30, // all of the following must be enable to get an audio beep ! ???
BK4819_EnableTXLink(); 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_WriteRegister(0x71, scale_freq(frequency));
BK4819_ExitTxMute(); BK4819_ExitTxMute();
// SYSTEM_DelayMs(2); // enable speaker
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // enable speaker
SYSTEM_DelayMs(2); 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_EnterTxMute();
BK4819_WriteRegister(0x70, 0); 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(); 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) 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); BK4819_StartTone1(tone_Hz, level, true);
SYSTEM_DelayMs(delay - 2); SYSTEM_DelayMs(delay - 2);
BK4819_StopTones(); BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
BK4819_WriteRegister(0x47, prev_af); // BK4819_WriteRegister(0x47, prev_af);
} }
void BK4819_PlayRoger(void) void BK4819_PlayRoger(void)
@ -1108,15 +1163,15 @@ void BK4819_PlayRoger(void)
const uint32_t tone2_Hz = 1310; const uint32_t tone2_Hz = 1310;
#endif #endif
const uint16_t prev_af = BK4819_ReadRegister(0x47); // const uint16_t prev_af = BK4819_ReadRegister(0x47);
BK4819_StartTone1(tone1_Hz, 96, true); BK4819_StartTone1(tone1_Hz, 96, true);
SYSTEM_DelayMs(80 - 2); SYSTEM_DelayMs(80 - 2);
BK4819_StartTone1(tone2_Hz, 96, false); BK4819_StartTone1(tone2_Hz, 96, false);
SYSTEM_DelayMs(80); SYSTEM_DelayMs(80);
BK4819_StopTones(); BK4819_StopTones(true);
BK4819_WriteRegister(0x47, prev_af); // BK4819_WriteRegister(0x47, prev_af);
} }
void BK4819_EnterTxMute(void) void BK4819_EnterTxMute(void)
@ -1126,13 +1181,13 @@ void BK4819_EnterTxMute(void)
void BK4819_ExitTxMute(void) void BK4819_ExitTxMute(void)
{ {
BK4819_WriteRegister(0x50, 0x3B20); BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
} }
void BK4819_Sleep(void) void BK4819_Sleep(void)
{ {
BK4819_WriteRegister(0x30, 0); 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) void BK4819_TurnsOffTones_TurnsOnRX(void)
@ -1145,11 +1200,16 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
BK4819_WriteRegister(0x30, 0); BK4819_WriteRegister(0x30, 0);
BK4819_WriteRegister(0x30, BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_VCO_CALIB | BK4819_REG_30_ENABLE_VCO_CALIB |
// BK4819_REG_30_ENABLE_UNKNOWN |
BK4819_REG_30_ENABLE_RX_LINK | BK4819_REG_30_ENABLE_RX_LINK |
BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_PLL_VCO | 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) void BK4819_Idle(void)
@ -1203,11 +1263,27 @@ void BK4819_PrepareTransmit(void)
void BK4819_TxOn_Beep(void) void BK4819_TxOn_Beep(void)
{ {
BK4819_WriteRegister(0x37, 0x1D0F); BK4819_WriteRegister(0x37, 0x1D0F); // 0001110100001111
BK4819_WriteRegister(0x52, 0x028F);
#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, 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) void BK4819_ExitSubAu(void)
@ -1252,7 +1328,7 @@ void BK4819_ExitSubAu(void)
BK4819_WriteRegister(0x51, 0); BK4819_WriteRegister(0x51, 0);
} }
void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void) void BK4819_Conditional_RX_TurnOn(void)
{ {
if (g_rx_idle_mode) if (g_rx_idle_mode)
{ {
@ -1282,57 +1358,42 @@ void BK4819_ExitDTMF_TX(bool bKeep)
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
BK4819_WriteRegister(0x70, 0); BK4819_WriteRegister(0x70, 0);
BK4819_DisableDTMF(); 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) if (!bKeep)
BK4819_ExitTxMute(); BK4819_ExitTxMute();
} }
void BK4819_EnableTXLink(void) void BK4819_EnableTXLink(void)
{ {
BK4819_WriteRegister(0x30, BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_VCO_CALIB | BK4819_REG_30_ENABLE_VCO_CALIB |
BK4819_REG_30_ENABLE_UNKNOWN | 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_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_PLL_VCO | BK4819_REG_30_ENABLE_PLL_VCO |
BK4819_REG_30_ENABLE_PA_GAIN | 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_ENABLE_TX_DSP |
BK4819_REG_30_DISABLE_RX_DSP); // BK4819_REG_30_ENABLE_RX_DSP |
0);
} }
void BK4819_PlayDTMF(char Code) 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')))); 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(); BK4819_RX_TurnOn();
} }
void BK4819_Disable(void)
{
BK4819_WriteRegister(0x30, 0);
}
void BK4819_StopScan(void) void BK4819_StopScan(void)
{ {
BK4819_DisableFrequencyScan(); BK4819_DisableFrequencyScan();
BK4819_Disable(); BK4819_WriteRegister(0x30, 0);
} }
uint8_t BK4819_GetDTMF_5TONE_Code(void) uint8_t BK4819_GetDTMF_5TONE_Code(void)
@ -1811,7 +1867,7 @@ void BK4819_reset_fsk(void)
BK4819_WriteRegister(0x3F, 0); // disable interrupts BK4819_WriteRegister(0x3F, 0); // disable interrupts
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59); // clear FIFO's BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59); // clear FIFO's
BK4819_WriteRegister(0x59, (0u << 15) | (0u << 14) | fsk_reg59); BK4819_WriteRegister(0x59, (0u << 15) | (0u << 14) | fsk_reg59);
BK4819_Idle(); BK4819_WriteRegister(0x30, 0);
} }
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
@ -2201,10 +2257,10 @@ void BK4819_reset_fsk(void)
// clear interrupt flags // clear interrupt flags
BK4819_WriteRegister(0x02, 0); BK4819_WriteRegister(0x02, 0);
BK4819_RX_TurnOn(); // BK4819_RX_TurnOn();
// enable interrupts // 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 else
{ {
@ -2224,17 +2280,18 @@ void BK4819_reset_fsk(void)
//BK4819_ExitTxMute(); //BK4819_ExitTxMute();
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000 BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
BK4819_WriteRegister(0x30, BK4819_WriteRegister(0x30,
(1u << 15) | // enable VCO calibration BK4819_REG_30_ENABLE_VCO_CALIB |
(1u << 14) | // enable something or other BK4819_REG_30_ENABLE_UNKNOWN |
(0u << 10) | // diable RX link // BK4819_REG_30_ENABLE_RX_LINK |
(1u << 9) | // enable AF DAC BK4819_REG_30_ENABLE_AF_DAC |
(1u << 8) | // enable DISC mode, what's DISC mode ? BK4819_REG_30_ENABLE_DISC_MODE |
(15u << 4) | // enable PLL/VCO BK4819_REG_30_ENABLE_PLL_VCO |
(1u << 3) | // enable PA gain BK4819_REG_30_ENABLE_PA_GAIN |
(0u << 2) | // disable MIC ADC // BK4819_REG_30_ENABLE_MIC_ADC |
(1u << 1) | // enable TX DSP BK4819_REG_30_ENABLE_TX_DSP |
(0u << 0)); // disable RX DSP // BK4819_REG_30_ENABLE_RX_DSP |
0);
#if 1 #if 1
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); 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 // disable FSK
BK4819_WriteRegister(0x59, fsk_reg59); BK4819_WriteRegister(0x59, fsk_reg59);
@ -2499,19 +2556,20 @@ void BK4819_reset_fsk(void)
BK4819_WriteRegister(0x50, 0xBB20); // 1011 1011 0010 0000 BK4819_WriteRegister(0x50, 0xBB20); // 1011 1011 0010 0000
//BK4819_SetAF(BK4819_AF_MUTE); //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, BK4819_WriteRegister(0x30,
(1u << 15) | // enable VCO calibration BK4819_REG_30_ENABLE_VCO_CALIB |
(1u << 14) | // enable something or other BK4819_REG_30_ENABLE_UNKNOWN |
(0u << 10) | // diable RX link // BK4819_REG_30_ENABLE_RX_LINK |
(0u << 9) | // disable AF DAC // BK4819_REG_30_ENABLE_AF_DAC |
(1u << 8) | // enable DISC mode, what's DISC mode ? BK4819_REG_30_ENABLE_DISC_MODE |
(15u << 4) | // enable PLL/VCO BK4819_REG_30_ENABLE_PLL_VCO |
(1u << 3) | // enable PA gain BK4819_REG_30_ENABLE_PA_GAIN |
(1u << 2) | // enable MIC ADC BK4819_REG_30_ENABLE_MIC_ADC |
(1u << 1) | // enable TX DSP BK4819_REG_30_ENABLE_TX_DSP |
(0u << 0)); // disable RX DSP // BK4819_REG_30_ENABLE_RX_DSP |
0);
//BK4819_ExitTxMute(); //BK4819_ExitTxMute();
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000 BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
@ -2521,7 +2579,18 @@ void BK4819_reset_fsk(void)
void BK4819_Enable_AfDac_DiscMode_TxDsp(void) void BK4819_Enable_AfDac_DiscMode_TxDsp(void)
{ {
BK4819_WriteRegister(0x30, 0); 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) void BK4819_GetVoxAmp(uint16_t *pResult)

View File

@ -26,7 +26,7 @@ enum BK4819_af_type_e
{ {
BK4819_AF_MUTE = 0u, // BK4819_AF_MUTE = 0u, //
BK4819_AF_FM = 1u, // FM BK4819_AF_FM = 1u, // FM
BK4819_AF_ALAM = 2u, // BK4819_AF_TONE = 2u, //
BK4819_AF_BEEP = 3u, // BK4819_AF_BEEP = 3u, //
BK4819_AF_BASEBAND1 = 4u, // SSB BK4819_AF_BASEBAND1 = 4u, // SSB
BK4819_AF_BASEBAND2 = 5u, // SSB BK4819_AF_BASEBAND2 = 5u, // SSB
@ -104,7 +104,7 @@ void BK4819_DisableVox(void);
void BK4819_DisableDTMF(void); void BK4819_DisableDTMF(void);
void BK4819_EnableDTMF(void); void BK4819_EnableDTMF(void);
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool set_dac); 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_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level);
void BK4819_EnterTxMute(void); void BK4819_EnterTxMute(void);
void BK4819_ExitTxMute(void); void BK4819_ExitTxMute(void);
@ -118,12 +118,11 @@ void BK4819_TurnsOffTones_TurnsOnRX(void);
void BK4819_reset_fsk(void); void BK4819_reset_fsk(void);
void BK4819_Idle(void); void BK4819_Idle(void);
//void BK4819_ExitBypass(void);
void BK4819_PrepareTransmit(void); void BK4819_PrepareTransmit(void);
void BK4819_TxOn_Beep(void); void BK4819_TxOn_Beep(void);
void BK4819_ExitSubAu(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_EnterDTMF_TX(bool bLocalLoopback);
void BK4819_ExitDTMF_TX(bool bKeep); void BK4819_ExitDTMF_TX(bool bKeep);
@ -150,8 +149,6 @@ void BK4819_DisableFrequencyScan(void);
void BK4819_EnableFrequencyScan(void); void BK4819_EnableFrequencyScan(void);
void BK4819_SetScanFrequency(uint32_t Frequency); void BK4819_SetScanFrequency(uint32_t Frequency);
void BK4819_Disable(void);
void BK4819_StopScan(void); void BK4819_StopScan(void);
uint8_t BK4819_GetDTMF_5TONE_Code(void); uint8_t BK4819_GetDTMF_5TONE_Code(void);

View File

@ -25,7 +25,8 @@
uint8_t g_ptt_debounce; uint8_t g_ptt_debounce;
uint8_t g_key_debounce_press; uint8_t g_key_debounce_press;
uint8_t g_key_debounce_repeat; 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_key_held;
bool g_fkey_pressed; bool g_fkey_pressed;
bool g_ptt_is_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++) for (i = 0, k = 0, reg = 0; i < 3 && k < 8; i++, k++)
{ {
uint16_t reg2; uint16_t reg2;
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
reg2 = GPIOA->DATA; reg2 = GPIOA->DATA;
if (reg != reg2) if (reg != reg2)
{ // noise { // noise
@ -159,5 +158,7 @@ key_code_t KEYBOARD_Poll(void)
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6); GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_KEYBOARD_6);
GPIO_SetBit( &GPIOA->DATA, GPIOA_PIN_KEYBOARD_7); GPIO_SetBit( &GPIOA->DATA, GPIOA_PIN_KEYBOARD_7);
g_key_pressed = Key;
return Key; return Key;
} }

View File

@ -49,6 +49,7 @@ extern uint8_t g_ptt_debounce;
extern uint8_t g_key_debounce_press; extern uint8_t g_key_debounce_press;
extern uint8_t g_key_debounce_repeat; extern uint8_t g_key_debounce_repeat;
extern key_code_t g_key_prev; extern key_code_t g_key_prev;
extern key_code_t g_key_pressed;
extern bool g_key_held; extern bool g_key_held;
extern bool g_fkey_pressed; extern bool g_fkey_pressed;
extern bool g_ptt_is_pressed; extern bool g_ptt_is_pressed;

Binary file not shown.

Binary file not shown.

3
font.c
View File

@ -577,6 +577,8 @@ const uint8_t g_font_small_4x5[95][4] =
{0x02, 0x1C, 0x48, 0x00}, // '~' {0x02, 0x1C, 0x48, 0x00}, // '~'
}; };
*/ */
#ifdef ENABLE_SMALLEST_FONT
const uint8_t g_font3x5[160][3] = const uint8_t g_font3x5[160][3] =
{ {
{0x00, 0x00, 0x00}, // 32 - space {0x00, 0x00, 0x00}, // 32 - space
@ -740,3 +742,4 @@ const uint8_t g_font3x5[160][3] =
{0x03, 0x0b, 0x18}, // 190 - threequarters {0x03, 0x0b, 0x18}, // 190 - threequarters
{0x18, 0x15, 0x10}, // 191 - questiondown {0x18, 0x15, 0x10}, // 191 - questiondown
}; };
#endif

5
font.h
View File

@ -26,8 +26,9 @@ extern const uint8_t g_font_small[95][6];
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
extern const uint8_t g_font_small_bold[95][6]; extern const uint8_t g_font_small_bold[95][6];
#endif #endif
//extern const uint8_t g_font_small_4x5[95][4]; #ifdef ENABLE_SMALLEST_FONT
extern const uint8_t g_font3x5[160][3]; extern const uint8_t g_font3x5[160][3];
#endif
#endif #endif

View File

@ -64,18 +64,18 @@ void FUNCTION_Init(void)
g_ctcss_lost = false; g_ctcss_lost = false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
g_vox_lost = false; g_vox_lost = false;
#endif #endif
g_squelch_open = false; g_squelch_open = false;
g_flag_tail_tone_elimination_complete = false; g_flag_tail_tone_elimination_complete = false;
g_tail_tone_elimination_tick_10ms = 0; g_tail_tone_elimination_tick_10ms = 0;
g_found_ctcss = false; g_found_ctcss = false;
g_found_cdcss = false; g_found_cdcss = false;
g_found_ctcss_tick_10ms = 0; g_found_ctcss_tick_10ms = 0;
g_found_cdcss_tick_10ms = 0; g_found_cdcss_tick_10ms = 0;
g_end_of_rx_detected_maybe = false; g_end_of_rx_detected_maybe = false;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
g_noaa_tick_10ms = 0; g_noaa_tick_10ms = 0;
@ -93,10 +93,8 @@ void FUNCTION_Select(function_type_t Function)
if (was_power_save && Function != FUNCTION_POWER_SAVE) if (was_power_save && Function != FUNCTION_POWER_SAVE)
{ // wake up { // wake up
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); BK4819_Conditional_RX_TurnOn();
g_rx_idle_mode = false; g_rx_idle_mode = false;
UI_DisplayStatus(false); UI_DisplayStatus(false);
} }
@ -135,26 +133,16 @@ void FUNCTION_Select(function_type_t Function)
return; 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: case FUNCTION_NEW_RECEIVE:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func new receive\r\n"); UART_SendText("func new receive\r\n");
#endif #endif
break; break;
case FUNCTION_RECEIVE: case FUNCTION_RECEIVE:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func receive\r\n"); UART_SendText("func receive\r\n");
#endif #endif
break; break;
case FUNCTION_POWER_SAVE: case FUNCTION_POWER_SAVE:
@ -162,19 +150,24 @@ void FUNCTION_Select(function_type_t Function)
UART_SendText("func power save\r\n"); UART_SendText("func power save\r\n");
#endif #endif
g_power_save_10ms = g_eeprom.battery_save * 10; if (g_flash_light_state != FLASHLIGHT_SOS)
g_power_save_expired = false; {
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_rx_idle_mode = true;
g_monitor_enabled = false;
BK4819_DisableVox(); BK4819_DisableVox();
BK4819_Sleep(); BK4819_Sleep();
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false); 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); GUI_SelectNextDisplay(DISPLAY_MAIN);
return; return;
@ -189,9 +182,9 @@ void FUNCTION_Select(function_type_t Function)
if (g_eeprom.dual_watch != DUAL_WATCH_OFF) if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ // dual-RX is enabled { // dual-RX is enabled
g_dual_watch_delay_10ms = dual_watch_delay_after_tx_10ms; g_dual_watch_tick_10ms = dual_watch_delay_after_tx_10ms;
if (g_dual_watch_delay_10ms < (g_eeprom.scan_hold_time_500ms * 50)) if (g_dual_watch_tick_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 = g_eeprom.scan_hold_time_500ms * 50;
} }
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
@ -229,13 +222,12 @@ void FUNCTION_Select(function_type_t Function)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(20); SYSTEM_DelayMs(2);
BK4819_StartTone1(500, 28, true); BK4819_StartTone1(500, 28, true);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
@ -264,8 +256,8 @@ void FUNCTION_Select(function_type_t Function)
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
g_alarm_tone_counter_10ms = 0; g_alarm_tone_counter_10ms = 0;
@ -326,11 +318,10 @@ void FUNCTION_Select(function_type_t Function)
UART_SendText("func panadpter\r\n"); UART_SendText("func panadpter\r\n");
#endif #endif
break; 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; g_schedule_power_save = false;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO

View File

@ -23,7 +23,7 @@ enum function_type_e
{ {
FUNCTION_FOREGROUND = 0, // idle, scanning FUNCTION_FOREGROUND = 0, // idle, scanning
FUNCTION_TRANSMIT, // transmitting FUNCTION_TRANSMIT, // transmitting
FUNCTION_MONITOR, // receiving with squelch forced open // FUNCTION_MONITOR, // receiving with squelch forced open
FUNCTION_NEW_RECEIVE, // signal just received FUNCTION_NEW_RECEIVE, // signal just received
FUNCTION_RECEIVE, // receive mode FUNCTION_RECEIVE, // receive mode
FUNCTION_POWER_SAVE, // sleeping FUNCTION_POWER_SAVE, // sleeping

View File

@ -32,7 +32,7 @@ bool g_low_battery;
bool g_low_battery_blink; bool g_low_battery_blink;
uint16_t g_battery_check_counter; 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 Based on real measurement
@ -145,6 +145,6 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
UI_DisplayBattery(g_battery_display_level, g_low_battery_blink); UI_DisplayBattery(g_battery_display_level, g_low_battery_blink);
} }
g_low_batteryCountdown = 0; g_low_battery_tick_10ms = 0;
} }
} }

View File

@ -30,9 +30,9 @@ extern bool g_charging_with_type_c;
extern bool g_low_battery; extern bool g_low_battery;
extern bool g_low_battery_blink; extern bool g_low_battery_blink;
extern uint16_t g_battery_check_counter; 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); unsigned int BATTERY_VoltsToPercent(const unsigned int voltage_10mV);
void BATTERY_GetReadings(const bool bDisplayBatteryLevel); void BATTERY_GetReadings(const bool bDisplayBatteryLevel);
#endif #endif

9
main.c
View File

@ -67,6 +67,9 @@ void Main(void)
| SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE | SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE; | SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE;
g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTICK_Init(); SYSTICK_Init();
#ifdef ENABLE_UART #ifdef ENABLE_UART
@ -183,15 +186,15 @@ void Main(void)
if (g_eeprom.pwr_on_display_mode != PWR_ON_DISPLAY_MODE_NONE) if (g_eeprom.pwr_on_display_mode != PWR_ON_DISPLAY_MODE_NONE)
{ // 3 second boot-up screen { // 3 second boot-up screen
while (g_boot_counter_10ms > 0) while (g_boot_tick_10ms > 0)
{ {
if (KEYBOARD_Poll() != KEY_INVALID) if (KEYBOARD_Poll() != KEY_INVALID)
{ // halt boot beeps and cancel boot screen { // halt boot beeps and cancel boot screen
g_boot_counter_10ms = 0; g_boot_tick_10ms = 0;
break; break;
} }
#ifdef ENABLE_BOOT_BEEPS #ifdef ENABLE_BOOT_BEEPS
if ((g_boot_counter_10ms % 25) == 0) if ((g_boot_tick_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL); AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif #endif
} }

37
misc.c
View File

@ -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_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 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 const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds
#ifdef ENABLE_KEYLOCK #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 const uint16_t vox_stop_10ms = 1000 / 10; // 1 second
#endif #endif
const uint16_t noaa_tick_10ms = 5000 / 10; // 5 seconds 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_2_10ms = 500 / 10; // 500ms
const uint16_t noaa_tick_3_10ms = 200 / 10; // 200ms 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_short;
uint8_t g_setting_side2_long; 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]; uint32_t g_custom_aes_key[4];
bool g_has_custom_aes_key; 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]; uint8_t g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t g_battery_save_tick_10ms = battery_save_count_10ms; volatile uint16_t g_schedule_power_save_tick_10ms = battery_save_count_10ms;
volatile bool g_power_save_expired;
volatile bool g_schedule_power_save; 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 bool g_dual_watch_delay_down_expired = true;
volatile uint8_t g_serial_config_tick_500ms; volatile uint8_t g_serial_config_tick_500ms;
@ -161,9 +161,9 @@ volatile uint16_t g_tail_tone_elimination_tick_10ms;
#endif #endif
bool g_speaker_enabled; bool g_speaker_enabled;
uint8_t g_key_input_count_down; uint8_t g_key_input_count_down;
#ifdef ENABLE_KEYLOCK #ifdef ENABLE_KEYLOCK
uint8_t g_key_lock_tick_500ms; uint8_t g_key_lock_tick_500ms;
#endif #endif
uint8_t g_rtte_count_down; uint8_t g_rtte_count_down;
bool g_password_locked; bool g_password_locked;
@ -182,7 +182,7 @@ bool g_update_rssi;
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
alarm_state_t g_alarm_state; alarm_state_t g_alarm_state;
#endif #endif
uint16_t g_menu_count_down; uint16_t g_menu_tick_10ms;
bool g_flag_reconfigure_vfos; bool g_flag_reconfigure_vfos;
uint8_t g_vfo_configure_mode; uint8_t g_vfo_configure_mode;
bool g_flag_reset_vfos; bool g_flag_reset_vfos;
@ -210,16 +210,17 @@ bool g_cxcss_tail_found;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
bool g_vox_lost; bool g_vox_lost;
bool g_vox_noise_detected; bool g_vox_noise_detected;
uint16_t g_vox_resume_count_down; uint16_t g_vox_resume_tick_10ms;
uint16_t g_vox_pause_count_down; uint16_t g_vox_pause_tick_10ms;
#endif #endif
bool g_squelch_open; bool g_squelch_open;
uint8_t g_flash_light_state; uint8_t g_flash_light_state;
uint16_t g_flash_light_blink_tick_10ms; uint16_t g_flash_light_blink_tick_10ms;
bool g_flag_end_tx; bool g_flag_end_tx;
uint16_t g_low_batteryCountdown; uint16_t g_low_battery_tick_10ms;
reception_mode_t g_rx_reception_mode; 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; uint8_t g_scan_restore_channel;
uint32_t g_scan_restore_frequency; uint32_t g_scan_restore_frequency;
bool g_scan_pause_time_mode; // set if we stopped in SCAN_RESUME_TIME mode 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; scan_state_dir_t g_scan_state_dir;
bool g_rx_vfo_is_active; 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_cdcss_tick_10ms;
volatile uint8_t g_found_ctcss_tick_10ms; volatile uint8_t g_found_ctcss_tick_10ms;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
volatile uint16_t g_vox_stop_10ms; volatile uint16_t g_vox_stop_tick_10ms;
#endif #endif
volatile bool g_next_time_slice_40ms; volatile bool g_next_time_slice_40ms;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
@ -264,7 +265,7 @@ volatile bool g_flag_tail_tone_elimination_complete;
volatile bool g_schedule_fm; volatile bool g_schedule_fm;
#endif #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 int16_t g_current_rssi[2] = {0, 0}; // now one per VFO

25
misc.h
View File

@ -225,12 +225,12 @@ extern uint16_t g_eeprom_rssi_calib[7][4];
extern uint8_t g_user_channel_attributes[207]; extern uint8_t g_user_channel_attributes[207];
extern volatile uint16_t g_battery_save_tick_10ms; extern volatile uint16_t g_schedule_power_save_tick_10ms;
extern volatile bool g_power_save_expired;
extern volatile bool g_schedule_power_save; 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 bool g_dual_watch_delay_down_expired;
extern volatile uint8_t g_serial_config_tick_500ms; 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; extern uint8_t g_key_input_count_down;
#ifdef ENABLE_KEYLOCK #ifdef ENABLE_KEYLOCK
extern uint8_t g_key_lock_tick_500ms; extern uint8_t g_key_lock_tick_500ms;
#endif #endif
extern uint8_t g_rtte_count_down; 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 css_scan_mode_t g_css_scan_mode;
extern bool g_update_rssi; extern bool g_update_rssi;
extern alarm_state_t g_alarm_state; 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 bool g_flag_reconfigure_vfos;
extern uint8_t g_vfo_configure_mode; extern uint8_t g_vfo_configure_mode;
extern bool g_flag_reset_vfos; extern bool g_flag_reset_vfos;
@ -298,16 +298,17 @@ extern bool g_cxcss_tail_found;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
extern bool g_vox_lost; extern bool g_vox_lost;
extern bool g_vox_noise_detected; extern bool g_vox_noise_detected;
extern uint16_t g_vox_resume_count_down; extern uint16_t g_vox_resume_tick_10ms;
extern uint16_t g_vox_pause_count_down; extern uint16_t g_vox_pause_tick_10ms;
#endif #endif
extern bool g_squelch_open; extern bool g_squelch_open;
extern uint8_t g_flash_light_state; extern uint8_t g_flash_light_state;
extern uint16_t g_flash_light_blink_tick_10ms; extern uint16_t g_flash_light_blink_tick_10ms;
extern bool g_flag_end_tx; 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 reception_mode_t g_rx_reception_mode;
extern uint8_t g_scan_next_channel; // 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 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 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 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 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_cdcss_tick_10ms;
extern volatile uint8_t g_found_ctcss_tick_10ms; extern volatile uint8_t g_found_ctcss_tick_10ms;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
extern volatile uint16_t g_vox_stop_10ms; extern volatile uint16_t g_vox_stop_tick_10ms;
#endif #endif
extern volatile bool g_next_time_slice_40ms; extern volatile bool g_next_time_slice_40ms;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
@ -349,7 +350,7 @@ extern volatile bool g_flag_tail_tone_elimination_complete;
extern volatile bool g_schedule_fm; extern volatile bool g_schedule_fm;
#endif #endif
extern int16_t g_current_rssi[2]; // now one per VFO 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_TX_VFO(void);
unsigned int get_RX_VFO(void); unsigned int get_RX_VFO(void);

149
radio.c
View File

@ -384,31 +384,32 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
RADIO_ConfigureSquelchAndOutputPower(p_vfo); RADIO_ConfigureSquelchAndOutputPower(p_vfo);
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if (p_vfo->am_mode && g_setting_am_fix) if (p_vfo->am_mode && g_setting_am_fix)
{ {
AM_fix_reset(VFO); AM_fix_reset(VFO);
AM_fix_10ms(VFO); AM_fix_10ms(VFO);
} }
else else
{ // don't do agc in FM mode { // don't do agc in FM mode
BK4819_DisableAGC(); BK4819_DisableAGC();
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
} }
#else #else
if (p_vfo->am_mode) if (p_vfo->am_mode)
{ {
BK4819_EnableAGC(); BK4819_EnableAGC();
} }
else else
{ // don't do agc in FM mode { // don't do agc in FM mode
BK4819_DisableAGC(); BK4819_DisableAGC();
BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
} }
#endif #endif
// if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(Channel))
if (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) 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; uint16_t interrupt_mask;
uint32_t Frequency; uint32_t Frequency;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); if (!g_speaker_enabled && !g_monitor_enabled)
g_speaker_enabled = false; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
// turn green LED off
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false);
switch (Bandwidth) 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 BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
while (1) while (1)
{ // wait for the interrupt to clear ? { // wait for interrupts to clear
const uint16_t status_bits = BK4819_ReadRegister(0x0C); const uint16_t int_bits = BK4819_ReadRegister(0x0C);
if ((status_bits & (1u << 0)) == 0) if ((int_bits & (1u << 0)) == 0)
break; break;
BK4819_WriteRegister(0x02, 0); // clear the interrupt bits BK4819_WriteRegister(0x02, 0); // clear the interrupt bits
SYSTEM_DelayMs(1); SYSTEM_DelayMs(1);
} }
BK4819_WriteRegister(0x3F, 0); // disable interrupts BK4819_WriteRegister(0x3F, 0); // disable interrupts
// mic gain 0.5dB/step 0 to 31 // mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(0x7D, 0xE940 | (g_eeprom.mic_sensitivity_tuning & 0x1f)); 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 #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode) 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_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh,
g_rx_vfo->squelch_close_glitch_thresh, g_rx_vfo->squelch_open_glitch_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); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
// AF RX Gain and DAC // 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; 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 // BK4819_SetTailDetection(670); // 67Hz
//#endif //#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; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
@ -734,24 +748,13 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
// BK4819_SetTailDetection(CTCSS_OPTIONS[Code]); // BK4819_SetTailDetection(CTCSS_OPTIONS[Code]);
//#endif //#endif
interrupt_mask = interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
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;
break; break;
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code)); BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code));
interrupt_mask = interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CDCSS_FOUND | BK4819_REG_3F_CDCSS_LOST;
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;
break; break;
} }
@ -765,11 +768,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
else else
{ {
BK4819_SetCTCSSFrequency(2625); BK4819_SetCTCSSFrequency(2625);
interrupt_mask = interrupt_mask |= BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
BK4819_REG_3F_CTCSS_FOUND |
BK4819_REG_3F_CTCSS_LOST |
BK4819_REG_3F_SQUELCH_FOUND |
BK4819_REG_3F_SQUELCH_LOST;
} }
#endif #endif
@ -792,50 +791,21 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
// RX expander // RX expander
BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compand >= 2) ? g_rx_vfo->compand : 0); BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compand >= 2) ? g_rx_vfo->compand : 0);
#if 0 BK4819_EnableDTMF();
#ifdef ENABLE_KILL_REVIVE interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
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
#ifdef ENABLE_MDC1200 #ifdef ENABLE_MDC1200
BK4819_enable_mdc1200_rx(true); 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 #endif
// enable/disable BK4819 selected interrupts // enable BK4819 interrupts
BK4819_WriteRegister(0x3F, interrupt_mask); BK4819_WriteRegister(0x3F, interrupt_mask);
FUNCTION_Init(); FUNCTION_Init();
if (switch_to_function_foreground) if (switch_to_function_foreground)
{ FUNCTION_Select(FUNCTION_FOREGROUND);
if (g_monitor_enabled)
APP_start_listening(FUNCTION_MONITOR);
else
FUNCTION_Select(FUNCTION_FOREGROUND);
}
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
@ -887,9 +857,8 @@ void RADIO_enableTX(const bool fsk_tx)
{ {
BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel_bandwidth; BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel_bandwidth;
// disable the speaker
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false; g_speaker_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
@ -1119,6 +1088,8 @@ void RADIO_EnableCxCSS(void)
void RADIO_PrepareCssTX(void) void RADIO_PrepareCssTX(void)
{ {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
RADIO_PrepareTX(); RADIO_PrepareTX();
SYSTEM_DelayMs(200); SYSTEM_DelayMs(200);
@ -1142,10 +1113,12 @@ void RADIO_tx_eot(void)
{ // end-of-tx { // end-of-tx
if (g_eeprom.dtmf_side_tone) if (g_eeprom.dtmf_side_tone)
{ {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = true; g_speaker_enabled = true;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
} }
BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone); BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone);
BK4819_PlayDTMFString( BK4819_PlayDTMFString(
g_eeprom.dtmf_key_down_code, 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_persist_time,
g_eeprom.dtmf_code_interval_time); g_eeprom.dtmf_code_interval_time);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_speaker_enabled = false; g_speaker_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
} }
else else
if (g_eeprom.roger_mode == ROGER_MODE_ROGER) if (g_eeprom.roger_mode == ROGER_MODE_ROGER)

View File

@ -73,42 +73,55 @@ void SystickHandler(void)
DECREMENT(g_found_ctcss_tick_10ms); DECREMENT(g_found_ctcss_tick_10ms);
if (g_current_function == FUNCTION_FOREGROUND) 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) if (g_current_function == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_expired); DECREMENT_AND_TRIGGER(g_power_save_tick_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);
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 #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_scan_state_dir == SCAN_STATE_DIR_OFF &&
if (g_is_noaa_mode && g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT) g_css_scan_mode == CSS_SCAN_MODE_OFF &&
if (g_current_function != FUNCTION_RECEIVE) g_eeprom.dual_watch == DUAL_WATCH_OFF &&
DECREMENT_AND_TRIGGER(g_noaa_tick_10ms, g_schedule_noaa); 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 #endif
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode == CSS_SCAN_MODE_SCANNING) 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) if (!g_monitor_enabled && g_current_function != FUNCTION_TRANSMIT)
DECREMENT(g_scan_pause_10ms); DECREMENT(g_scan_pause_tick_10ms);
DECREMENT_AND_TRIGGER(g_tail_tone_elimination_tick_10ms, g_flag_tail_tone_elimination_complete); DECREMENT_AND_TRIGGER(g_tail_tone_elimination_tick_10ms, g_flag_tail_tone_elimination_complete);
#ifdef ENABLE_VOICE #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 #endif
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR) if (g_fm_scan_state != FM_SCAN_OFF &&
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE) !g_monitor_enabled &&
DECREMENT_AND_TRIGGER(g_fm_play_tick_10ms, g_schedule_fm); g_current_function != FUNCTION_TRANSMIT &&
g_current_function != FUNCTION_RECEIVE)
{
DECREMENT_AND_TRIGGER(g_fm_play_tick_10ms, g_schedule_fm);
}
#endif #endif
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
DECREMENT(g_vox_stop_10ms); DECREMENT(g_vox_stop_tick_10ms);
#endif #endif
DECREMENT(g_boot_counter_10ms); DECREMENT(g_boot_tick_10ms);
} }

View File

@ -121,11 +121,11 @@ void UI_DisplayFM(void)
{ // frequency mode { // frequency mode
const uint32_t freq = g_eeprom.fm_frequency_playing; const uint32_t freq = g_eeprom.fm_frequency_playing;
NUMBER_ToDigits(freq * 10000, str); NUMBER_ToDigits(freq * 10000, str);
#ifdef ENABLE_TRIM_TRAILING_ZEROS #ifdef ENABLE_TRIM_TRAILING_ZEROS
UI_DisplayFrequency(str, 30, 4, false, true); UI_DisplayFrequency(str, 30, 4, false, true);
#else #else
UI_DisplayFrequency(str, 23, 4, false, true); UI_DisplayFrequency(str, 23, 4, false, true);
#endif #endif
} }
else else
{ // user is entering a frequency { // 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_07 = BK1080_ReadRegister(0x07);
const uint16_t val_0A = BK1080_ReadRegister(0x0A); const uint16_t val_0A = BK1080_ReadRegister(0x0A);
@ -153,7 +155,7 @@ void UI_DisplayFM(void)
(val_07 >> 0) & 0x000f); (val_07 >> 0) & 0x000f);
UI_PrintStringSmall(str, 0, LCD_WIDTH, 6); UI_PrintStringSmall(str, 0, LCD_WIDTH, 6);
} }
// ************************************* // *************************************
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();

View File

@ -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])); 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 #endif
/*
void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line) #ifdef ENABLE_SMALLEST_FONT
{
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]));
}
*/
void PutPixel(const unsigned int x, const unsigned int y, const bool fill) 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) void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
{ {
const unsigned int char_width = ARRAY_SIZE(g_font_small[0]); const unsigned int char_width = ARRAY_SIZE(g_font_small[0]);

View File

@ -27,8 +27,9 @@ void UI_PrintStringSmall(const char *str, const unsigned int start, const unsign
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
void UI_PrintStringSmallBold(const char *str, const unsigned int start, const unsigned int end, const unsigned int line); void UI_PrintStringSmallBold(const char *str, const unsigned int start, const unsigned int end, const unsigned int line);
#endif #endif
//void UI_PrintStringSmall4x5(const char *str, const unsigned int start, const unsigned int end, const unsigned int line); #ifdef ENABLE_SMALLEST_FONT
void UI_PrintStringSmallest(const void *pString, unsigned int x, const unsigned int y, const bool statusbar, const bool fill); 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_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_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); void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero);

View File

@ -302,7 +302,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
#ifdef ENABLE_RX_SIGNAL_BAR #ifdef ENABLE_RX_SIGNAL_BAR
if (g_center_line == CENTER_LINE_RSSI) if (g_center_line == CENTER_LINE_RSSI)
{ // optional larger RSSI dBm, S-point and bar level { // 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); UI_DisplayRSSIBar(rssi, true);
} }
@ -355,9 +355,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
if (rssi >= level01) if (rssi >= level01)
rssi_level = 2; rssi_level = 2;
else else
if (rssi >= level0 || if (rssi >= level0 || g_current_function == FUNCTION_NEW_RECEIVE)
g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_NEW_RECEIVE)
{ {
rssi_level = 1; 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) 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; const unsigned int smallest_char_spacing = ARRAY_SIZE(g_font3x5[0]) + 1;
#endif #endif
const unsigned int line0 = 0; // text screen line const unsigned int line0 = 0; // text screen line
@ -589,9 +587,7 @@ void UI_DisplayMain(void)
else else
{ // receiving .. show the RX symbol { // receiving .. show the RX symbol
mode = 2; mode = 2;
if ((g_current_function == FUNCTION_RECEIVE || if ((g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_NEW_RECEIVE) &&
g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_NEW_RECEIVE) &&
g_eeprom.rx_vfo == vfo_num) g_eeprom.rx_vfo == vfo_num)
{ {
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
@ -776,7 +772,7 @@ void UI_DisplayMain(void)
// no room for these symbols // 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); 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); UI_PrintStringSmallest("C", x, (line + 0) * 8, false, true);
//x += smallest_char_spacing * 1; //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 #endif
} }
@ -903,9 +917,7 @@ void UI_DisplayMain(void)
g_dtmf_call_state == DTMF_CALL_STATE_NONE) g_dtmf_call_state == DTMF_CALL_STATE_NONE)
{ // we're free to use the middle line { // we're free to use the middle line
const bool rx = (g_current_function == FUNCTION_RECEIVE || const bool rx = (g_current_function == FUNCTION_RECEIVE);
g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_NEW_RECEIVE);
#ifdef ENABLE_TX_TIMEOUT_BAR #ifdef ENABLE_TX_TIMEOUT_BAR
// show the TX timeout count down // show the TX timeout count down

View File

@ -54,8 +54,8 @@ void UI_DisplayStatus(const bool test_display)
} }
else else
if (g_current_function == FUNCTION_RECEIVE || 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)); memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX));
x1 = x + sizeof(BITMAP_RX); x1 = x + sizeof(BITMAP_RX);
@ -140,7 +140,7 @@ void UI_DisplayStatus(const bool test_display)
// DUAL-WATCH indicator // DUAL-WATCH indicator
if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display) 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_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_scan_state_dir != SCAN_STATE_DIR_OFF || g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_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); x += sizeof(BITMAP_TDR_RUNNING);
if (g_current_function == FUNCTION_MONITOR) // monitor
if (g_monitor_enabled)
{ {
memcpy(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR)); memcpy(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR));
x1 = x + sizeof(BITMAP_MONITOR); x1 = x + sizeof(BITMAP_MONITOR);

View File

@ -91,6 +91,7 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
g_scan_state_dir = SCAN_STATE_DIR_OFF; g_scan_state_dir = SCAN_STATE_DIR_OFF;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
g_fm_scan_state = FM_SCAN_OFF; g_fm_scan_state = FM_SCAN_OFF;
g_update_display = true;
#endif #endif
g_ask_for_confirmation = 0; g_ask_for_confirmation = 0;
g_ask_to_save = false; g_ask_to_save = false;