From 2a114b4f95453366e3f7a8249bc310be60f9ea84 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 24 Mar 2024 22:06:58 -0400 Subject: [PATCH] PUBLIC_API_WEAK --- firmware/controllers/actuators/fan_control.cpp | 2 +- firmware/controllers/algo/engine_configuration.cpp | 6 +++--- firmware/controllers/can/can_tx.cpp | 2 +- firmware/controllers/core/common_headers.h | 3 +++ firmware/hw_layer/hardware.cpp | 6 +++--- firmware/hw_layer/ports/stm32/stm32_common.cpp | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/actuators/fan_control.cpp b/firmware/controllers/actuators/fan_control.cpp index 6c64bfd9b9..5393366c46 100644 --- a/firmware/controllers/actuators/fan_control.cpp +++ b/firmware/controllers/actuators/fan_control.cpp @@ -4,7 +4,7 @@ #include "bench_test.h" -__attribute__((weak)) bool fansDisabledByBoardStatus() { +PUBLIC_API_WEAK bool fansDisabledByBoardStatus() { return false; } diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index d48ac3255d..4adfddad68 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -165,12 +165,12 @@ void onBurnRequest() { * this hook is about https://github.com/rusefi/rusefi/wiki/Custom-Firmware and https://github.com/rusefi/rusefi/wiki/Canned-Tune-Process * */ -__attribute__((weak)) void boardTuneDefaults() { } +PUBLIC_API_WEAK void boardTuneDefaults() { } -__attribute__((weak)) void boardEngineTypeTune(engine_type_e engineType) { } +PUBLIC_API_WEAK void boardEngineTypeTune(engine_type_e engineType) { } // Weak link a stub so that every board doesn't have to implement this function -__attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s* /*previousConfiguration*/) { } +PUBLIC_API_WEAK void boardOnConfigurationChange(engine_configuration_s* /*previousConfiguration*/) { } /** * this is the top-level method which should be called in case of any changes to engine configuration diff --git a/firmware/controllers/can/can_tx.cpp b/firmware/controllers/can/can_tx.cpp index 0d2ddb2b98..51cf14cd7a 100644 --- a/firmware/controllers/can/can_tx.cpp +++ b/firmware/controllers/can/can_tx.cpp @@ -26,7 +26,7 @@ CanWrite::CanWrite() { } -__attribute__((weak)) bool boardEnableSendWidebandInfo() { return true; } +PUBLIC_API_WEAK bool boardEnableSendWidebandInfo() { return true; } void CanWrite::PeriodicTask(efitick_t nowNt) { UNUSED(nowNt); diff --git a/firmware/controllers/core/common_headers.h b/firmware/controllers/core/common_headers.h index 429787a6be..df168777c5 100644 --- a/firmware/controllers/core/common_headers.h +++ b/firmware/controllers/core/common_headers.h @@ -44,3 +44,6 @@ // see also validateStack #define hasLotsOfRemainingStack() (getCurrentRemainingStack() > EXPECTED_REMAINING_STACK) + +// this macro helps locate all board API methods +#define PUBLIC_API_WEAK __attribute__((weak)) diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index e3f5a4b221..ac0d8eb071 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -561,10 +561,10 @@ void startHardware() { } // Weak link a stub so that every board doesn't have to implement this function -__attribute__((weak)) void boardInitHardware() { } -__attribute__((weak)) void boardInitHardwareExtra() { } +PUBLIC_API_WEAK void boardInitHardware() { } +PUBLIC_API_WEAK void boardInitHardwareExtra() { } -__attribute__((weak)) void setPinConfigurationOverrides() { } +PUBLIC_API_WEAK void setPinConfigurationOverrides() { } #if HAL_USE_I2C const I2CConfig i2cfg = { diff --git a/firmware/hw_layer/ports/stm32/stm32_common.cpp b/firmware/hw_layer/ports/stm32/stm32_common.cpp index 907cd00090..f49d44ae06 100644 --- a/firmware/hw_layer/ports/stm32/stm32_common.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_common.cpp @@ -228,7 +228,7 @@ bool isStm32F42x() { // Stubs for per-board low power helpers -__attribute__((weak)) void boardPrepareForStop() { +PUBLIC_API_WEAK void boardPrepareForStop() { // Default implementation - wake up on PA0 - boards should override this palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_RISING_EDGE); } @@ -261,7 +261,7 @@ void boardPreparePA0ForStandby() { #endif } -__attribute__((weak)) void boardPrepareForStandby() { +PUBLIC_API_WEAK void boardPrepareForStandby() { boardPreparePA0ForStandby(); }