diff --git a/Makefile b/Makefile index 040bda0..52f4113 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,7 @@ AS = arm-none-eabi-gcc CC = LD = arm-none-eabi-gcc + ifeq ($(ENABLE_CLANG),0) CC += arm-none-eabi-gcc # Use GCC's linker to avoid undefined symbol errors @@ -182,18 +183,18 @@ endif CFLAGS = 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=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=gnu11 -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=gnu11 -MMD 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 endif ifeq ($(ENABLE_LTO),1) CFLAGS += -flto=2 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 endif @@ -311,13 +312,13 @@ endif LDFLAGS += --specs=nano.specs 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 endif ifeq ($(DEBUG),1) ASFLAGS += -g - CFLAGS += -g + CFLAGS += -g LDFLAGS += -g endif diff --git a/README.md b/README.md index 2c97717..980e30d 100644 --- a/README.md +++ b/README.md @@ -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) .. ``` -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_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_AIRCOPY := 0 easier to just enter frequency with butts ENABLE_FMRADIO := 0 WBFM VHF broadcast band receiver diff --git a/driver/bk4819.c b/driver/bk4819.c index aa96c20..3715df3 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -602,8 +602,8 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b { // make the RX bandwidth the same with weak signals val = (0u << 15) | // 0 - (5u << 12) | // *3 RF filter bandwidth - (5u << 9) | // *0 RF filter bandwidth when signal is weak + (4u << 12) | // *3 RF filter bandwidth + (4u << 9) | // *0 RF filter bandwidth when signal is weak (6u << 6) | // *0 AFTxLPF2 filter Band Width (2u << 4) | // 2 BW Mode Selection (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 val = // 0x3028); // 0 011 000 000 10 1 0 00 (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 (6u << 6) | // *0 AFTxLPF2 filter Band Width (2u << 4) | // 2 BW Mode Selection @@ -629,8 +629,8 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b { val = (0u << 15) | // 0 - (5u << 12) | // *4 RF filter bandwidth - (5u << 9) | // *0 RF filter bandwidth when signal is weak + (4u << 12) | // *4 RF filter bandwidth + (4u << 9) | // *0 RF filter bandwidth when signal is weak (0u << 6) | // *1 AFTxLPF2 filter Band Width (0u << 4) | // 0 BW Mode Selection (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 (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 (0u << 6) | // *1 AFTxLPF2 filter Band Width (0u << 4) | // 0 BW Mode Selection diff --git a/firmware.bin b/firmware.bin index 59626d0..1c41ed7 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 55c1ef6..09cbff6 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/radio.c b/radio.c index 8d3f212..f712f2d 100644 --- a/radio.c +++ b/radio.c @@ -431,13 +431,13 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) if (gEeprom.SQUELCH_LEVEL == 0) { // squelch == 0 (off) - pInfo->SquelchOpenRSSIThresh = 0; - pInfo->SquelchOpenNoiseThresh = 127; - pInfo->SquelchCloseGlitchThresh = 255; + pInfo->SquelchOpenRSSIThresh = 0; // 0 ~ 255 + pInfo->SquelchOpenNoiseThresh = 127; // 127 ~ 0 + pInfo->SquelchCloseGlitchThresh = 255; // 255 ~ 0 - pInfo->SquelchCloseRSSIThresh = 0; - pInfo->SquelchCloseNoiseThresh = 127; - pInfo->SquelchOpenGlitchThresh = 255; + pInfo->SquelchCloseRSSIThresh = 0; // 0 ~ 255 + pInfo->SquelchCloseNoiseThresh = 127; // 127 ~ 0 + pInfo->SquelchOpenGlitchThresh = 255; // 255 ~ 0 } else { // 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 + 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 // 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 - pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 8) / 9; - pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 8) / 9; + #if 0 + rssi_open = (rssi_open * 8) / 9; + rssi_close = (rssi_close * 8) / 9; - pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8; - pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8; + noise_open = (noise_open * 9) / 8; + noise_close = (noise_close * 9) / 8; - pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8; - pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8; + glitch_open = (glitch_open * 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 - if (pInfo->SquelchOpenNoiseThresh > 127) - pInfo->SquelchOpenNoiseThresh = 127; - - if (pInfo->SquelchCloseNoiseThresh > 127) - pInfo->SquelchCloseNoiseThresh = 127; + pInfo->SquelchOpenRSSIThresh = (rssi_open > 255) ? 255 : rssi_open; + pInfo->SquelchCloseRSSIThresh = (rssi_close > 255) ? 255 : rssi_close; + pInfo->SquelchOpenNoiseThresh = (noise_open > 127) ? 127 : noise_open; + pInfo->SquelchCloseNoiseThresh = (noise_close > 127) ? 127 : noise_close; + pInfo->SquelchOpenGlitchThresh = (glitch_open > 255) ? 255 : glitch_open; + pInfo->SquelchCloseGlitchThresh = (glitch_close > 255) ? 255 : glitch_close; } Band = FREQUENCY_GetBand(pInfo->pTX->Frequency);