This commit is contained in:
rusefi 2019-01-28 02:59:14 -05:00
parent 3dab4b5163
commit de2eb04519
8 changed files with 27 additions and 38 deletions

View File

@ -101,9 +101,9 @@ static LoggingWithStorage logger("Engine Controller");
/**
* todo: this should probably become 'static', i.e. private, and propagated around explicitly?
*/
Engine _engine CCM_OPTIONAL;
Engine * engine = &_engine;
#endif /* EFI_PROD_CODE */
Engine ___engine CCM_OPTIONAL;
Engine * engine = &___engine;
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
static msg_t csThread(void) {
chRegSetThreadName("status");

View File

@ -30,18 +30,19 @@
extern board_configuration_s *boardConfiguration; \
extern persistent_config_s *config;
#define COMMON_EXTERN_ENGINE extern Engine *engine; \
#define EXTERN_ENGINE \
extern Engine ___engine; \
extern Engine *engine; \
extern persistent_config_container_s persistentState; \
EXTERN_CONFIG \
extern engine_configuration_s activeConfiguration; \
extern EnginePins enginePins
// Use this macro to declare a function which only takes magic references
#define DECLARE_ENGINE_PARAMETER_SIGNATURE void
// Use this version of the macro as the suffix if method has other parameters
#define DECLARE_ENGINE_PARAMETER_SUFFIX
// Pass this if only magic reference are needed
// Pass this if only magic references are needed
#define PASS_ENGINE_PARAMETER_SIGNATURE
// Pass this after some other parameters are passed
#define PASS_ENGINE_PARAMETER_SUFFIX
@ -58,7 +59,7 @@
*/
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
#define CONFIGB(x) persistentState.persistentConfiguration.engineConfiguration.bc.x
#define ENGINE(x) ___engine.x
#define DEFINE_CONFIG_PARAM(x, y)
#define CONFIG_PARAM(x) CONFIG(x)

View File

@ -50,7 +50,7 @@ static void executorCallback(void *arg) {
// timerIsLate++;
// }
_engine.executor.onTimerCallback();
___engine.executor.onTimerCallback();
}
SingleTimerExecutor::SingleTimerExecutor() {
@ -168,9 +168,9 @@ extern TunerStudioOutputChannels tsOutputChannels;
void executorStatistics() {
if (engineConfiguration->debugMode == DBG_EXECUTOR) {
#if (EFI_TUNER_STUDIO && EFI_SIGNAL_EXECUTOR_ONE_TIMER) || defined(__DOXYGEN__)
tsOutputChannels.debugIntField1 = _engine.executor.timerCallbackCounter;
tsOutputChannels.debugIntField2 = _engine.executor.doExecuteCounter;
tsOutputChannels.debugIntField3 = _engine.executor.scheduleCounter;
tsOutputChannels.debugIntField1 = ___engine.executor.timerCallbackCounter;
tsOutputChannels.debugIntField2 = ___engine.executor.doExecuteCounter;
tsOutputChannels.debugIntField3 = ___engine.executor.scheduleCounter;
#endif /* EFI_TUNER_STUDIO */
}
}

View File

@ -91,12 +91,6 @@ typedef unsigned int time_t;
#define CCM_OPTIONAL
#endif /* EFI_USE_CCM */
#define EXTERN_ENGINE \
extern Engine _engine; \
COMMON_EXTERN_ENGINE
#define ENGINE(x) _engine.x
/**
* low-level function is used here to reduce stack usage
*/

View File

@ -8,6 +8,6 @@
#ifndef GLOBALACCESS_H_
#define GLOBALACCESS_H_
#include "controllers/global_shared.h"
#include "global_shared.h"
#endif /* GLOBALACCESS_H_ */

View File

@ -86,7 +86,6 @@ void applyNewConfiguration(void);
}
#endif /* __cplusplus */
/**
* number of SysClock ticks in one ms
*/
@ -94,10 +93,6 @@ void applyNewConfiguration(void);
#define hal_lld_get_counter_value() 0
#define EXTERN_ENGINE \
COMMON_EXTERN_ENGINE
#define ENGINE(x) engine->x
#endif /* GLOBAL_H_ */

View File

@ -82,7 +82,6 @@ void print(const char *fmt, ...);
persistent_config_s *config = engine->config; \
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
/**
* this macro provides references to engine from EngineTestHelper
*/
@ -93,12 +92,6 @@ void print(const char *fmt, ...);
#define WITH_ENGINE_TEST_HELPER(x) EngineTestHelper eth(x); \
EXPAND_EngineTestHelper;
#define CONFIG(x) engineConfiguration->x
// todo: fix this! this does not work because of 'prepareVoidConfiguration(&activeConfiguration);'
//#define CONFIGB(x) engine->engineConfigurationPtr->bc.x
#define CONFIGB(x) CONFIG(bc.x)
#define ENGINE(x) engine->x
#define CONFIG_PARAM(x) (x)
#endif /* GLOBAL_H_ */

View File

@ -8,17 +8,23 @@
#ifndef GLOBALACCESS_H_
#define GLOBALACCESS_H_
/**
* @see firmware/global.h for explanation
*/
#define DECLARE_ENGINE_PARAMETER_SIGNATURE Engine *engine, engine_configuration_s *engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration
#define DECLARE_ENGINE_PARAMETER_SUFFIX , DECLARE_ENGINE_PARAMETER_SIGNATURE
#define PASS_ENGINE_PARAMETER_SIGNATURE engine, engineConfiguration, config, boardConfiguration
#define PASS_ENGINE_PARAMETER_SUFFIX , PASS_ENGINE_PARAMETER_SIGNATURE
#define DECLARE_CONFIG_PARAMETER_SIGNATURE engine_configuration_s *engineConfiguration, persistent_config_s *config, board_configuration_s *boardConfiguration
#define DECLARE_CONFIG_PARAMETER_SUFFIX , DECLARE_CONFIG_PARAMETER_SIGNATURE
#define PASS_CONFIG_PARAMETER_SIGNATURE engineConfiguration, config, boardConfiguration
#define PASS_CONFIG_PARAMETER_SUFFIX , PASS_CONFIG_PARAMETER_SIGNATURE
/**
* @see firmware/global.h for explanation
*/
#define DECLARE_ENGINE_PARAMETER_SIGNATURE Engine *engine, DECLARE_CONFIG_PARAMETER_SIGNATURE
#define DECLARE_ENGINE_PARAMETER_SUFFIX , DECLARE_ENGINE_PARAMETER_SIGNATURE
#define PASS_ENGINE_PARAMETER_SIGNATURE engine, PASS_CONFIG_PARAMETER_SIGNATURE
#define PASS_ENGINE_PARAMETER_SUFFIX , PASS_ENGINE_PARAMETER_SIGNATURE
#define CONFIG(x) engineConfiguration->x
// todo: fix this! this does not work because of 'prepareVoidConfiguration(&activeConfiguration);'
//#define CONFIGB(x) engine->engineConfigurationPtr->bc.x
#define CONFIGB(x) CONFIG(bc.x)
#define ENGINE(x) engine->x
#endif /* GLOBALACCESS_H_ */