0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-29 14:51:26 +03:00

fix main.c compile

This commit is contained in:
OneOfEleven 2023-10-27 17:27:31 +01:00
parent eb03123666
commit 7bd83cdd32
10 changed files with 48 additions and 33 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

View File

@ -85,7 +85,7 @@ void ACTION_Monitor(void)
#endif #endif
g_monitor_enabled = true; g_monitor_enabled = true;
RADIO_setup_registers(true); RADIO_setup_registers(true);
APP_start_listening(FUNCTION_MONITOR, false); APP_start_listening(FUNCTION_MONITOR);
return; return;
} }

View File

@ -17,6 +17,9 @@
#include <string.h> #include <string.h>
#include <stdlib.h> // abs() #include <stdlib.h> // abs()
#ifdef ENABLE_AM_FIX
#include "am_fix.h"
#endif
#include "app/action.h" #include "app/action.h"
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
#include "app/aircopy.h" #include "app/aircopy.h"
@ -47,7 +50,6 @@
#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
#include "am_fix.h"
#include "dtmf.h" #include "dtmf.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "frequencies.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 { enum end_of_rx_mode_e {
@ -473,7 +475,7 @@ static void APP_process_function(void)
#pragma GCC diagnostic pop #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_eeprom.rx_vfo;
// const unsigned int chan = g_rx_vfo->channel_save; // 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; 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 // AF gain - original QS values
if (g_rx_vfo->am_mode) 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) 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 else
if (g_scan_pause_10ms == 0) 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) 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 else
{ // switch to next channel { // switch to next channel
@ -1353,7 +1337,7 @@ void APP_process(void)
if (g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode) 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 else
{ // switch to next frequency { // switch to next frequency
@ -1850,7 +1834,9 @@ void APP_time_slice_10ms(void)
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_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) if (g_rx_vfo->am_mode && g_setting_am_fix)
{
AM_fix_10ms(g_eeprom.rx_vfo); AM_fix_10ms(g_eeprom.rx_vfo);
}
#endif #endif
if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode) if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode)

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, 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); uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step);
void APP_process(void); void APP_process(void);
void APP_time_slice_10ms(void); void APP_time_slice_10ms(void);

View File

@ -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 #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 && g_current_function == FUNCTION_MONITOR)
{ // re-enable the squelch { // re-enable the squelch
APP_start_listening(FUNCTION_RECEIVE, false); APP_start_listening(FUNCTION_RECEIVE);
g_monitor_enabled = false; g_monitor_enabled = false;
} }
#endif #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) 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, false); APP_start_listening(FUNCTION_MONITOR);
} }
#endif #endif

View File

@ -53,8 +53,11 @@ void BK4819_Init(void)
BK4819_WriteRegister(0x37, 0x1D0F); BK4819_WriteRegister(0x37, 0x1D0F);
BK4819_WriteRegister(0x36, 0x0022); BK4819_WriteRegister(0x36, 0x0022);
// BK4819_DisableAGC(); #ifdef ENABLE_AM_FIX
BK4819_EnableAGC(); 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 BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable

Binary file not shown.

Binary file not shown.

2
main.c
View File

@ -32,7 +32,7 @@
#include "driver/st7565.h" #include "driver/st7565.h"
#include "driver/system.h" #include "driver/system.h"
#include "driver/systick.h" #include "driver/systick.h"
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) #if defined(ENABLE_UART)
#include "driver/uart.h" #include "driver/uart.h"
#endif #endif
#include "helper/battery.h" #include "helper/battery.h"

28
radio.c
View File

@ -21,6 +21,9 @@
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
#include "app/fm.h" #include "app/fm.h"
#endif #endif
#ifdef ENABLE_AM_FIX
#include "am_fix.h"
#endif
#include "audio.h" #include "audio.h"
#include "board.h" #include "board.h"
#include "bsp/dp32g030/gpio.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); 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)) 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); // 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 (switch_to_function_foreground)
{ {
if (g_monitor_enabled) if (g_monitor_enabled)
APP_start_listening(FUNCTION_MONITOR, false); APP_start_listening(FUNCTION_MONITOR);
else else
FUNCTION_Select(FUNCTION_FOREGROUND); FUNCTION_Select(FUNCTION_FOREGROUND);
} }