PUBLIC_API_WEAK or BOARD_WEAK #6748

This commit is contained in:
Andrey 2024-07-27 12:36:35 -04:00 committed by rusefillc
parent e902e9cb81
commit 1530b3dbd9
12 changed files with 22 additions and 26 deletions

View File

@ -51,7 +51,7 @@ static void setupDefaultSensorInputs() {
static bool isFirstInvocation = true;
/*BOARD_WEAK*/ int hackHellenBoardId(int detectedId) {
/*PUBLIC_API_WEAK*/ int hackHellenBoardId(int detectedId) {
if (detectedId == BOARD_ID_VAG121_D) {
// wow something bad has happened to that batch of boards?!
return BOARD_ID_154HYUNDAI_C;

View File

@ -166,7 +166,7 @@ static const struct mc33810_config mc33810 = {
.en = {.port = GPIOG, .pad = 9} // H144_GP_IO4 hopefully
};
/*BOARD_WEAK*/ void boardInitHardware() {
/*PUBLIC_API_WEAK*/ void boardInitHardware() {
static OutputPin spi3CsEtb;
static OutputPin spi3CsWastegate;

View File

@ -59,7 +59,7 @@ static void printUid() {
* But it looks like our manner of __attribute__((weak)) declaration works at well, and I hope it will not cause
* problems in the future.
*/
BOARD_WEAK void boardSayHello() {
PUBLIC_API_WEAK void boardSayHello() {
}
static void sayHello() {

View File

@ -279,7 +279,7 @@ float getSanitizedPedal() {
return clampPercentValue(pedalPosition.value_or(0));
}
BOARD_WEAK float boardAdjustEtbTarget(float currentEtbTarget) {
PUBLIC_API_WEAK float boardAdjustEtbTarget(float currentEtbTarget) {
return currentEtbTarget;
}
@ -937,7 +937,7 @@ static pid_s* getPidForDcFunction(dc_function_e function) {
}
}
BOARD_WEAK ValueProvider3D* pedal2TpsProvider() {
PUBLIC_API_WEAK ValueProvider3D* pedal2TpsProvider() {
return &pedal2tpsMap;
}

View File

@ -1104,16 +1104,16 @@ void commonFrankensoAnalogInputs() {
}
// These symbols are weak so that a board_configuration.cpp file can override them
BOARD_WEAK void setBoardDefaultConfiguration() { }
PUBLIC_API_WEAK void setBoardDefaultConfiguration() { }
// specific firmware builds are meant for specific hardware. In order to provide best user experience on well-known boards sometimes we reduce user flexibility.
BOARD_WEAK_SOMETHING_WEIRD void setBoardConfigOverrides() { }
PUBLIC_API_WEAK_SOMETHING_WEIRD void setBoardConfigOverrides() { }
BOARD_WEAK int hackHellenBoardId(int detectedId) { return detectedId; }
PUBLIC_API_WEAK int hackHellenBoardId(int detectedId) { return detectedId; }
BOARD_WEAK void onBoardStandBy() { }
PUBLIC_API_WEAK void onBoardStandBy() { }
BOARD_WEAK_SOMETHING_WEIRD int getBoardMetaOutputsCount() { return 0; }
PUBLIC_API_WEAK_SOMETHING_WEIRD int getBoardMetaOutputsCount() { return 0; }
// default implementation: treat all outputs as low side
BOARD_WEAK int getBoardMetaLowSideOutputsCount() { return getBoardMetaOutputsCount(); }
BOARD_WEAK Gpio* getBoardMetaOutputs() { return nullptr; }
BOARD_WEAK int getBoardMetaDcOutputsCount() { return 0; }
PUBLIC_API_WEAK int getBoardMetaLowSideOutputsCount() { return getBoardMetaOutputsCount(); }
PUBLIC_API_WEAK Gpio* getBoardMetaOutputs() { return nullptr; }
PUBLIC_API_WEAK int getBoardMetaDcOutputsCount() { return 0; }

View File

@ -21,16 +21,13 @@
#define MOCK_UNDEFINED -1
// why is Windows compiler not happy around simulator?! feature or defect?!
#if !defined(EFI_SIM_IS_WINDOWS) || !EFI_SIM_IS_WINDOWS
// todo: dup of PUBLIC_API_WEAK?
#define BOARD_WEAK_SOMETHING_WEIRD __attribute__((weak))
#define PUBLIC_API_WEAK_SOMETHING_WEIRD __attribute__((weak))
#else
#define BOARD_WEAK_SOMETHING_WEIRD
#define PUBLIC_API_WEAK_SOMETHING_WEIRD
#endif
// todo: dup of PUBLIC_API_WEAK?
#define BOARD_WEAK __attribute__((weak))
void setCrankOperationMode();
void setCamOperationMode();
void setTwoStrokeOperationMode();

View File

@ -185,7 +185,7 @@ static void processCanRxImu(const CANRxFrame& frame) {
extern bool verboseRxCan;
BOARD_WEAK void boardProcessCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) { }
PUBLIC_API_WEAK void boardProcessCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) { }
void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) {
if ((engineConfiguration->verboseCan && busIndex == 0) || verboseRxCan) {

View File

@ -47,6 +47,5 @@
// see also validateStack
#define hasLotsOfRemainingStack() (getCurrentRemainingStack() > EXPECTED_REMAINING_STACK)
// this macro helps locate all board API methods
// todo: dup of BOARD_WEAK?
// this macro helps locate all board Public API methods
#define PUBLIC_API_WEAK __attribute__((weak))

View File

@ -642,7 +642,7 @@ static int lua_vincpy(lua_State* l) {
return 0;
}
BOARD_WEAK void boardConfigureLuaHooks(lua_State* lState) { }
PUBLIC_API_WEAK void boardConfigureLuaHooks(lua_State* lState) { }
void configureRusefiLuaHooks(lua_State* lState) {
boardConfigureLuaHooks(lState);

View File

@ -744,7 +744,7 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
return true;
}
BOARD_WEAK bool boardAllowTriggerActions() { return true; }
PUBLIC_API_WEAK bool boardAllowTriggerActions() { return true; }
angle_t TriggerCentral::findNextTriggerToothAngle(int p_currentToothIndex) {
int currentToothIndex = p_currentToothIndex;

View File

@ -8,7 +8,7 @@
#include "pch.h"
float BOARD_WEAK getAnalogInputDividerCoefficient(adc_channel_e) {
float PUBLIC_API_WEAK getAnalogInputDividerCoefficient(adc_channel_e) {
return engineConfiguration->analogInputDividerCoefficient;
}

View File

@ -34,7 +34,7 @@ float getVoltageDivided(const char *msg, adc_channel_e hwChannel) {
return getVoltage(msg, hwChannel) * getAnalogInputDividerCoefficient(hwChannel);
}
float BOARD_WEAK boardAdjustVoltage(float voltage, adc_channel_e hwChannel) {
float PUBLIC_API_WEAK boardAdjustVoltage(float voltage, adc_channel_e hwChannel) {
// a hack useful when we do not trust voltage just after board EN was turned on. is this just hiding electrical design flaws?
return voltage;
}