RX bandwidth and squelch update

This commit is contained in:
OneOfEleven 2023-10-05 13:42:14 +01:00
parent 0cf4e1fe36
commit 2372949eb9
6 changed files with 66 additions and 32 deletions

View File

@ -153,6 +153,7 @@ AS = arm-none-eabi-gcc
CC = CC =
LD = arm-none-eabi-gcc LD = arm-none-eabi-gcc
ifeq ($(ENABLE_CLANG),0) ifeq ($(ENABLE_CLANG),0)
CC += arm-none-eabi-gcc CC += arm-none-eabi-gcc
# Use GCC's linker to avoid undefined symbol errors # Use GCC's linker to avoid undefined symbol errors
@ -182,18 +183,18 @@ endif
CFLAGS = CFLAGS =
ifeq ($(ENABLE_CLANG),0) ifeq ($(ENABLE_CLANG),0)
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD #CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c99 -MMD
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD #CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD
# CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD #CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD
else else
# Oz needed to make it fit on flash # Oz needed to make it fit on flash
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
endif endif
ifeq ($(ENABLE_LTO),1) ifeq ($(ENABLE_LTO),1)
CFLAGS += -flto=2 CFLAGS += -flto=2
else else
# We get most of the space savings if LTO creates problems # We get most of the space savings if LTO creates problems
CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -ffunction-sections -fdata-sections
endif endif
@ -311,13 +312,13 @@ endif
LDFLAGS += --specs=nano.specs LDFLAGS += --specs=nano.specs
ifeq ($(ENABLE_LTO),0) ifeq ($(ENABLE_LTO),0)
# Throw away unneeded func/data sections like LTO does # Throw away unneeded func/data sections like LTO does
LDFLAGS += -Wl,--gc-sections LDFLAGS += -Wl,--gc-sections
endif endif
ifeq ($(DEBUG),1) ifeq ($(DEBUG),1)
ASFLAGS += -g ASFLAGS += -g
CFLAGS += -g CFLAGS += -g
LDFLAGS += -g LDFLAGS += -g
endif endif

View File

@ -26,10 +26,10 @@ You can customize the firmware by enabling/disabling various compile options.
You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) .. You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) ..
``` ```
ENABLE_CLANG := 0 experimental, builds with clang instead of gcc (LTO will be disabled if you enable this) ENABLE_CLANG := 0 **experimental, builds with clang instead of gcc (LTO will be disabled if you enable this)
ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming) ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming)
ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (overlay will be disabled if you enable this) ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this)
ENABLE_UART := 1 without this you can't configure radio via PC ! ENABLE_UART := 1 without this you can't configure radio via PC !
ENABLE_AIRCOPY := 0 easier to just enter frequency with butts ENABLE_AIRCOPY := 0 easier to just enter frequency with butts
ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver

View File

@ -602,8 +602,8 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
{ // make the RX bandwidth the same with weak signals { // make the RX bandwidth the same with weak signals
val = val =
(0u << 15) | // 0 (0u << 15) | // 0
(5u << 12) | // *3 RF filter bandwidth (4u << 12) | // *3 RF filter bandwidth
(5u << 9) | // *0 RF filter bandwidth when signal is weak (4u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width (6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection (2u << 4) | // 2 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
@ -614,7 +614,7 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
{ // with weak RX signals the RX bandwidth is reduced { // with weak RX signals the RX bandwidth is reduced
val = // 0x3028); // 0 011 000 000 10 1 0 00 val = // 0x3028); // 0 011 000 000 10 1 0 00
(0u << 15) | // 0 (0u << 15) | // 0
(5u << 12) | // *3 RF filter bandwidth (4u << 12) | // *3 RF filter bandwidth
(2u << 9) | // *0 RF filter bandwidth when signal is weak (2u << 9) | // *0 RF filter bandwidth when signal is weak
(6u << 6) | // *0 AFTxLPF2 filter Band Width (6u << 6) | // *0 AFTxLPF2 filter Band Width
(2u << 4) | // 2 BW Mode Selection (2u << 4) | // 2 BW Mode Selection
@ -629,8 +629,8 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
{ {
val = val =
(0u << 15) | // 0 (0u << 15) | // 0
(5u << 12) | // *4 RF filter bandwidth (4u << 12) | // *4 RF filter bandwidth
(5u << 9) | // *0 RF filter bandwidth when signal is weak (4u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width (0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection (0u << 4) | // 0 BW Mode Selection
(1u << 3) | // 1 (1u << 3) | // 1
@ -641,7 +641,7 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
{ {
val = // 0x4048); // 0 100 000 001 00 1 0 00 val = // 0x4048); // 0 100 000 001 00 1 0 00
(0u << 15) | // 0 (0u << 15) | // 0
(5u << 12) | // *4 RF filter bandwidth (4u << 12) | // *4 RF filter bandwidth
(2u << 9) | // *0 RF filter bandwidth when signal is weak (2u << 9) | // *0 RF filter bandwidth when signal is weak
(0u << 6) | // *1 AFTxLPF2 filter Band Width (0u << 6) | // *1 AFTxLPF2 filter Band Width
(0u << 4) | // 0 BW Mode Selection (0u << 4) | // 0 BW Mode Selection

Binary file not shown.

Binary file not shown.

67
radio.c
View File

@ -431,13 +431,13 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
if (gEeprom.SQUELCH_LEVEL == 0) if (gEeprom.SQUELCH_LEVEL == 0)
{ // squelch == 0 (off) { // squelch == 0 (off)
pInfo->SquelchOpenRSSIThresh = 0; pInfo->SquelchOpenRSSIThresh = 0; // 0 ~ 255
pInfo->SquelchOpenNoiseThresh = 127; pInfo->SquelchOpenNoiseThresh = 127; // 127 ~ 0
pInfo->SquelchCloseGlitchThresh = 255; pInfo->SquelchCloseGlitchThresh = 255; // 255 ~ 0
pInfo->SquelchCloseRSSIThresh = 0; pInfo->SquelchCloseRSSIThresh = 0; // 0 ~ 255
pInfo->SquelchCloseNoiseThresh = 127; pInfo->SquelchCloseNoiseThresh = 127; // 127 ~ 0
pInfo->SquelchOpenGlitchThresh = 255; pInfo->SquelchOpenGlitchThresh = 255; // 255 ~ 0
} }
else else
{ // squelch >= 1 { // squelch >= 1
@ -452,6 +452,13 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90 EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90
EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100 EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100
uint16_t rssi_open = pInfo->SquelchOpenRSSIThresh;
uint16_t rssi_close = pInfo->SquelchCloseRSSIThresh;
uint16_t noise_open = pInfo->SquelchOpenNoiseThresh;
uint16_t noise_close = pInfo->SquelchCloseNoiseThresh;
uint16_t glitch_open = pInfo->SquelchOpenGlitchThresh;
uint16_t glitch_close = pInfo->SquelchCloseGlitchThresh;
#if ENABLE_SQUELCH_MORE_SENSITIVE #if ENABLE_SQUELCH_MORE_SENSITIVE
// make squelch a little more sensitive // make squelch a little more sensitive
// //
@ -459,21 +466,47 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
// //
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values // note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 8) / 9; #if 0
pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 8) / 9; rssi_open = (rssi_open * 8) / 9;
rssi_close = (rssi_close * 8) / 9;
pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8; noise_open = (noise_open * 9) / 8;
pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8; noise_close = (noise_close * 9) / 8;
pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8; glitch_open = (glitch_open * 9) / 8;
pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8; glitch_close = (glitch_close * 9) / 8;
#else
// even more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
rssi_open = (rssi_open * 1) / 2;
rssi_close = (rssi_close * 1) / 2;
noise_open = (noise_open * 2) / 1;
noise_close = (noise_close * 2) / 1;
glitch_open = (glitch_open * 2) / 1;
glitch_close = (glitch_close * 2) / 1;
#endif
#else
// more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
rssi_open = (rssi_open * 3) / 4;
rssi_close = (rssi_close * 3) / 4;
noise_open = (noise_open * 4) / 3;
noise_close = (noise_close * 4) / 3;
glitch_open = (glitch_open * 4) / 3;
glitch_close = (glitch_close * 4) / 3;
#endif #endif
if (pInfo->SquelchOpenNoiseThresh > 127) pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open;
pInfo->SquelchOpenNoiseThresh = 127; pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close;
pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open;
if (pInfo->SquelchCloseNoiseThresh > 127) pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close;
pInfo->SquelchCloseNoiseThresh = 127; pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open;
pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close;
} }
Band = FREQUENCY_GetBand(pInfo->pTX->Frequency); Band = FREQUENCY_GetBand(pInfo->pTX->Frequency);