From 6f5fe216db3cc792028ee0901c7cf7cc8ea558d8 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Sun, 5 May 2024 19:56:05 +0300 Subject: [PATCH] stm32_pins: const, save few bytes of RAM --- firmware/controllers/system/efi_gpio.h | 1 - firmware/hw_layer/ports/stm32/stm32_pins.cpp | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index 3081a7fce2..575664876a 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -160,7 +160,6 @@ private: ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin); ioportid_t getHwPort(const char *msg, brain_pin_e brainPin); -ioportid_t * getGpioPorts(); const char *portname(ioportid_t GPIOx); #endif /* EFI_GPIO_HARDWARE */ diff --git a/firmware/hw_layer/ports/stm32/stm32_pins.cpp b/firmware/hw_layer/ports/stm32/stm32_pins.cpp index d66d133d48..8eba029783 100644 --- a/firmware/hw_layer/ports/stm32/stm32_pins.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_pins.cpp @@ -12,7 +12,7 @@ #if EFI_GPIO_HARDWARE -static ioportid_t ports[] = {GPIOA, +static const ioportid_t ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, @@ -53,16 +53,12 @@ static ioportid_t ports[] = {GPIOA, #endif /* STM32_HAS_GPIOK */ }; -ioportid_t * getGpioPorts() { - return ports; -} - int getBrainPinIndex(brain_pin_e brainPin) { return (brainPin - Gpio::A0) % PORT_SIZE; } ioportid_t getBrainPinPort(brain_pin_e brainPin) { - return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } /** @@ -165,7 +161,7 @@ ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) { */ return GPIO_NULL; } - return getGpioPorts()[(brainPin - Gpio::A0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } /**