From 8b02e1115da2625120b0cc0bead155c2db45a687 Mon Sep 17 00:00:00 2001 From: Bricky Date: Mon, 17 Jun 2024 23:10:15 +0100 Subject: [PATCH] misc: change compiler flags to save space, fix some code warnings --- Makefile | 22 ++++++++++------------ app/menu.c | 2 +- app/radio.c | 3 +++ driver/pwm.c | 2 +- helper/dtmf.c | 2 +- ui/font.c | 2 +- ui/font.h | 2 +- ui/helper.c | 13 +++++++------ 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 692a032f..6352efb2 100644 --- a/Makefile +++ b/Makefile @@ -5,25 +5,25 @@ MOTO_STARTUP_TONE ?= 1 ENABLE_AM_FIX ?= 1 ENABLE_ALT_SQUELCH ?= 1 ENABLE_STATUS_BAR_LINE ?= 0 -ENABLE_NOAA ?= 1 +ENABLE_NOAA ?= 0 ENABLE_RX_BAR ?= 1 ENABLE_TX_BAR ?= 1 ENABLE_SLOWER_RSSI_TIMER ?= 1 -ENABLE_SPECTRUM ?= 1 -ENABLE_KEEP_MONITOR_MODE_UP_DN ?= 0 -PCB_VER_2_1 ?= 0 +ENABLE_SPECTRUM ?= 0 +ENABLE_KEEP_MONITOR_MODE_UP_DN ?= 1 +PCB_VER_2_1 ?= 1 # Spectrum presets - 1.4 kB -ENABLE_SPECTRUM_PRESETS ?= 1 +ENABLE_SPECTRUM_PRESETS ?= 0 # FM radio = 2.6 kB ENABLE_FM_RADIO ?= 1 # Register Editor = .5 kB ENABLE_REGISTER_EDIT ?= 0 # Scanlist membership display - 252 B -ENABLE_SCANLIST_DISPLAY ?= 1 +ENABLE_SCANLIST_DISPLAY ?= 0 # Space saving options -ENABLE_LTO ?= 0 +ENABLE_LTO ?= 1 ENABLE_OPTIMIZED ?= 1 @@ -166,7 +166,8 @@ GIT_HASH := $(GIT_HASH_TMP) endif ASFLAGS = -mcpu=cortex-m4 -CFLAGS = -Os -Wall -Werror -mcpu=cortex-m4 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD +CFLAGS = -Os -Wall -Werror -mcpu=cortex-m4 -pipe -free -freorder-blocks-algorithm=stc -std=c2x -MMD +#CFLAGS += -Wextra CFLAGS += -DAT32F421C8T7 CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" @@ -176,12 +177,9 @@ ifeq ($(ENABLE_OPTIMIZED),1) CFLAGS += --specs=nano.specs LDFLAGS += --specs=nano.specs +# Only takes effect when LTO is disabled CFLAGS += -ffunction-sections LDFLAGS += -Wl,--gc-sections - -CFLAGS += -finline-limit=0 - -CFLAGS += -fmerge-all-constants endif ifeq ($(DEBUG),1) diff --git a/app/menu.c b/app/menu.c index 13966dda..31bf42c6 100644 --- a/app/menu.c +++ b/app/menu.c @@ -601,7 +601,7 @@ void MENU_AcceptSetting(void) for (i = 0; i < 8; i++) { gSettingGolay = (gSettingGolay * 10) + (gInputBox[i] - '0'); } - if (gSettingGolay < 0x1000000) { + if (gSettingGolay != 0) { return; } // Illegal code diff --git a/app/radio.c b/app/radio.c index 8adc463b..eacd6596 100644 --- a/app/radio.c +++ b/app/radio.c @@ -323,6 +323,9 @@ void RADIO_EndRX(void) switch (gExtendedSettings.ScanResume) { case 1: // Carrier Operated SCANNER_Countdown = 3000; + // Implicit fallthrough + gpio_bits_reset(GPIOA, BOARD_GPIOA_LED_GREEN); + break; case 2: // Time Operated gpio_bits_reset(GPIOA, BOARD_GPIOA_LED_GREEN); break; diff --git a/driver/pwm.c b/driver/pwm.c index 412799bc..896d09d6 100644 --- a/driver/pwm.c +++ b/driver/pwm.c @@ -44,7 +44,7 @@ void PWM_Pulse(uint16_t Data) tmr_para_init_ex1(&init); init.ch1_output_control_mode = TMR_OUTPUT_CONTROL_PWM_MODE_A; - init.ch1_polarity = TMR_POLARITY_ACTIVE_HIGH; + init.ch1_polarity = (tmr_output_polarity_type)TMR_POLARITY_ACTIVE_HIGH; init.ch1_enable = TRUE; init.ch1_digital_filter = Data; tmr_reset_ex1(TMR3, &init); diff --git a/helper/dtmf.c b/helper/dtmf.c index a9d1947b..10c86ace 100644 --- a/helper/dtmf.c +++ b/helper/dtmf.c @@ -43,7 +43,7 @@ static void Init(void) }; - for (int i = 0; i < ARRAY_SIZE(init_0x9_values); i++) { + for (unsigned int i = 0; i < ARRAY_SIZE(init_0x9_values); i++) { BK4819_WriteRegister(0x09, init_0x9_values[i]); } diff --git a/ui/font.c b/ui/font.c index 7e54c534..be2d5d87 100644 --- a/ui/font.c +++ b/ui/font.c @@ -64,7 +64,7 @@ static uint8_t LoadAndDraw(uint8_t X, uint8_t Y, uint32_t Offset) } } -void FONT_Draw(uint8_t X, uint8_t Y, const uint32_t *pOffsets, uint32_t Count) +void FONT_Draw(uint8_t X, uint8_t Y, uint32_t Count) { uint8_t i, x; diff --git a/ui/font.h b/ui/font.h index 80b7cb09..40cde20a 100644 --- a/ui/font.h +++ b/ui/font.h @@ -20,7 +20,7 @@ #include #include -void FONT_Draw(uint8_t X, uint8_t Y, const uint32_t *pOffsets, uint32_t Count); +void FONT_Draw(uint8_t X, uint8_t Y, uint32_t Count); uint8_t FONT_GetOffsets(const char *String, uint8_t Size, bool bFlag); #endif diff --git a/ui/helper.c b/ui/helper.c index d57f8935..b2407411 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -226,7 +226,7 @@ static const uint8_t BitmapRadar[] = { void UI_DrawString(uint8_t X, uint8_t Y, const char *pString, uint8_t Size) { - FONT_Draw(X, Y, SFLASH_FontOffsets, FONT_GetOffsets(pString, Size, true)); + FONT_Draw(X, Y, FONT_GetOffsets(pString, Size, true)); } void UI_DrawSmallCharacter(uint8_t X, uint8_t Y, char Digit) @@ -714,7 +714,7 @@ void UI_DrawDTMF(void) void UI_DrawFMFrequency(uint16_t Frequency) { - Int2Ascii(gSettings.FmFrequency, 4); + Int2Ascii(Frequency, 4); gShortString[4] = gShortString[3]; gShortString[3] = '.'; gColorForeground = COLOR_BLUE; @@ -963,11 +963,12 @@ void UI_DrawGolay(void) for (i = 0; i < 8; i++) { gSettingGolay = (gSettingGolay * 10) + (gInputBox[i] - '0'); } - if (gSettingGolay > 0xFFFFFF) { - gSettingGolay &= 0xFFFFFF; - Int2Ascii(gSettingGolay, 8); - UI_DrawString(24, 24, gShortString, 8); + if (gSettingGolay != 0) { + return; } + gSettingGolay &= 0xFFFFFF; + Int2Ascii(gSettingGolay, 8); + UI_DrawString(24, 24, gShortString, 8); } void UI_DrawChannelNumber(const char *pString)