diff --git a/Makefile b/Makefile index ad594ec..b55843e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 # UART Programming 2.9 kB ENABLE_UART := 1 -ENABLE_UART_DEBUG := 1 +ENABLE_UART_DEBUG := 0 # AirCopy 2.5 kB ENABLE_AIRCOPY := 0 ENABLE_AIRCOPY_REMEMBER_FREQ := 1 diff --git a/app/action.c b/app/action.c index d8aba30..9008d4d 100644 --- a/app/action.c +++ b/app/action.c @@ -85,7 +85,7 @@ void ACTION_Monitor(void) #endif g_monitor_enabled = true; RADIO_setup_registers(true); - APP_start_listening(FUNCTION_MONITOR, false); + APP_start_listening(FUNCTION_MONITOR); return; } diff --git a/app/app.c b/app/app.c index b1fa1ce..ab3a951 100644 --- a/app/app.c +++ b/app/app.c @@ -17,6 +17,9 @@ #include #include // abs() +#ifdef ENABLE_AM_FIX + #include "am_fix.h" +#endif #include "app/action.h" #ifdef ENABLE_AIRCOPY #include "app/aircopy.h" @@ -47,7 +50,6 @@ #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #include "driver/uart.h" #endif -#include "am_fix.h" #include "dtmf.h" #include "external/printf/printf.h" #include "frequencies.h" @@ -230,7 +232,7 @@ static void APP_process_new_receive(void) } } - APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false); + APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } enum end_of_rx_mode_e { @@ -473,7 +475,7 @@ static void APP_process_function(void) #pragma GCC diagnostic pop } -bool APP_start_listening(function_type_t Function, const bool reset_am_fix) +bool APP_start_listening(function_type_t Function) { const unsigned int chan = g_eeprom.rx_vfo; // const unsigned int chan = g_rx_vfo->channel_save; @@ -557,24 +559,6 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix) g_update_status = true; } -#ifdef ENABLE_AM_FIX - { // RF RX front end gain - - if (g_rx_vfo->am_mode && g_setting_am_fix) - { // AM RX mode - if (reset_am_fix) - AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency .. or do we ??? - AM_fix_10ms(chan); - } - else - { // original setting - BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); - } - } -#else - (void)reset_am_fix; -#endif - // AF gain - original QS values if (g_rx_vfo->am_mode) { @@ -1318,7 +1302,7 @@ void APP_process(void) if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE) // && !g_scan_pause_time_mode) { - APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } else if (g_scan_pause_10ms == 0) @@ -1338,7 +1322,7 @@ void APP_process(void) if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode) { - APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } else { // switch to next channel @@ -1353,7 +1337,7 @@ void APP_process(void) if (g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode) { - APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } else { // switch to next frequency @@ -1850,7 +1834,9 @@ void APP_time_slice_10ms(void) #ifdef ENABLE_AM_FIX // if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix) if (g_rx_vfo->am_mode && g_setting_am_fix) + { AM_fix_10ms(g_eeprom.rx_vfo); + } #endif if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode) diff --git a/app/app.h b/app/app.h index f83bbd2..615b8a9 100644 --- a/app/app.h +++ b/app/app.h @@ -31,7 +31,7 @@ extern const uint8_t orig_pga; void APP_end_tx(void); void APP_stop_scan(void); void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction); -bool APP_start_listening(function_type_t Function, const bool reset_am_fix); +bool APP_start_listening(function_type_t Function); uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step); void APP_process(void); void APP_time_slice_10ms(void); diff --git a/app/main.c b/app/main.c index 77df3bf..0999468 100644 --- a/app/main.c +++ b/app/main.c @@ -833,7 +833,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio #ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS if (key_held && !monitor_was_enabled && g_current_function == FUNCTION_MONITOR) { // re-enable the squelch - APP_start_listening(FUNCTION_RECEIVE, false); + APP_start_listening(FUNCTION_RECEIVE); g_monitor_enabled = false; } #endif @@ -953,7 +953,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio if (key_held && key_pressed && !monitor_was_enabled) { // open the squelch if the user holds the key down g_monitor_enabled = true; - APP_start_listening(FUNCTION_MONITOR, false); + APP_start_listening(FUNCTION_MONITOR); } #endif diff --git a/driver/bk4819.c b/driver/bk4819.c index 6210f31..62189dd 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -53,8 +53,11 @@ void BK4819_Init(void) BK4819_WriteRegister(0x37, 0x1D0F); BK4819_WriteRegister(0x36, 0x0022); -// BK4819_DisableAGC(); - BK4819_EnableAGC(); +#ifdef ENABLE_AM_FIX + BK4819_DisableAGC(); +#else + BK4819_EnableAGC(); // only do this in linear modulation modes, not FM +#endif BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable diff --git a/firmware.bin b/firmware.bin index 45b3054..9ccf5eb 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index d331c24..e0f48da 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/main.c b/main.c index 7122413..3dc155f 100644 --- a/main.c +++ b/main.c @@ -32,7 +32,7 @@ #include "driver/st7565.h" #include "driver/system.h" #include "driver/systick.h" -#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) +#if defined(ENABLE_UART) #include "driver/uart.h" #endif #include "helper/battery.h" diff --git a/radio.c b/radio.c index 552c2ad..99af858 100644 --- a/radio.c +++ b/radio.c @@ -21,6 +21,9 @@ #ifdef ENABLE_FMRADIO #include "app/fm.h" #endif +#ifdef ENABLE_AM_FIX + #include "am_fix.h" +#endif #include "audio.h" #include "board.h" #include "bsp/dp32g030/gpio.h" @@ -392,6 +395,29 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur RADIO_ConfigureSquelchAndOutputPower(p_vfo); +#ifdef ENABLE_AM_FIX + if (p_vfo->am_mode && g_setting_am_fix) + { + AM_fix_reset(VFO); + AM_fix_10ms(VFO); + } + else + { // don't do agc in FM mode + BK4819_DisableAGC(); + BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); + } +#else + if (p_vfo->am_mode) + { + BK4819_EnableAGC(); + } + else + { // don't do agc in FM mode + BK4819_DisableAGC(); + BK4819_WriteRegister(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0)); + } +#endif + if (IS_FREQ_CHANNEL(Channel)) p_vfo->freq_in_channel = BOARD_find_channel(Frequency); // remember if a channel has this frequency } @@ -804,7 +830,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) if (switch_to_function_foreground) { if (g_monitor_enabled) - APP_start_listening(FUNCTION_MONITOR, false); + APP_start_listening(FUNCTION_MONITOR); else FUNCTION_Select(FUNCTION_FOREGROUND); }