2018-09-16 20:10:06 -07:00
|
|
|
/*
|
|
|
|
* @file common_headers.h
|
|
|
|
*
|
2018-12-25 13:06:24 -08:00
|
|
|
* Header file shared between firmware, simulator and unit_tests
|
|
|
|
*
|
2018-09-16 20:10:06 -07:00
|
|
|
* @date Sep 16, 2018
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONTROLLERS_CORE_COMMON_HEADERS_H_
|
|
|
|
#define CONTROLLERS_CORE_COMMON_HEADERS_H_
|
|
|
|
|
2019-04-04 20:03:32 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERNC extern "C"
|
|
|
|
#else
|
|
|
|
#define EXTERNC
|
|
|
|
#endif
|
|
|
|
|
2018-09-16 20:10:06 -07:00
|
|
|
#include "efifeatures.h"
|
2018-12-08 13:06:14 -08:00
|
|
|
#include "rusefi_types.h"
|
2018-09-16 20:10:06 -07:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "error_handling.h"
|
|
|
|
#include "auto_generated_enums.h"
|
|
|
|
#include "efilib.h"
|
|
|
|
#include "efitime.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include "datalogging.h"
|
|
|
|
#include "loggingcentral.h"
|
2019-09-18 18:38:45 -07:00
|
|
|
#include "cli_registry.h"
|
2018-09-16 20:10:06 -07:00
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2019-09-01 08:59:39 -07:00
|
|
|
/**
|
|
|
|
* reference to configuration parameter
|
|
|
|
*/
|
2019-06-17 09:18:55 -07:00
|
|
|
#define DISPLAY_CONFIG(x) x
|
2019-09-01 08:59:39 -07:00
|
|
|
/**
|
|
|
|
* The main annotation of live data - reference to dynamic state variable
|
|
|
|
* See also 'TS_GET_STRUCT'
|
|
|
|
*/
|
2019-06-17 09:18:55 -07:00
|
|
|
#define DISPLAY_FIELD(x) x
|
2019-09-01 08:59:39 -07:00
|
|
|
/**
|
|
|
|
* Advanced tag to access fields within data structures
|
|
|
|
* "running.fuel" variable would be referenced as DISPLAY_PREFIX(running).DISPLAY_FIELD(fuel)
|
|
|
|
*/
|
|
|
|
#define DISPLAY_PREFIX(x) x
|
|
|
|
|
|
|
|
/**
|
|
|
|
* we use this 'DISPLAY' macro if value is not used by C++ code in current context and we want to hide it from compiler
|
|
|
|
*/
|
2019-06-17 18:37:11 -07:00
|
|
|
#define DISPLAY(x)
|
2019-06-17 09:18:55 -07:00
|
|
|
|
2019-06-27 03:47:13 -07:00
|
|
|
#define DISPLAY_TAG(x)
|
2019-09-01 08:59:39 -07:00
|
|
|
/**
|
|
|
|
* Just a human-readable comment. '_' underscore symbols become spaces. EOL is handled as new line.
|
|
|
|
*/
|
2019-06-17 09:18:55 -07:00
|
|
|
#define DISPLAY_TEXT(x)
|
2019-08-31 21:45:36 -07:00
|
|
|
#define DISPLAY_STATE(x)
|
2019-09-01 08:59:39 -07:00
|
|
|
/**
|
|
|
|
* Reference to one of 'output' channels/standard gauges.
|
|
|
|
*/
|
2019-06-17 09:18:55 -07:00
|
|
|
#define DISPLAY_SENSOR(x) {}
|
2019-06-18 20:23:30 -07:00
|
|
|
#define DISPLAY_IF(x) x
|
2019-06-17 09:18:55 -07:00
|
|
|
|
2019-11-19 22:35:08 -08:00
|
|
|
#define DECLARE_ENGINE_PTR \
|
2019-09-22 05:22:35 -07:00
|
|
|
Engine *engine = nullptr; \
|
|
|
|
engine_configuration_s *engineConfiguration = nullptr; \
|
|
|
|
persistent_config_s *config = nullptr; \
|
|
|
|
board_configuration_s *boardConfiguration = nullptr;
|
2019-09-21 21:16:46 -07:00
|
|
|
|
|
|
|
|
2019-12-02 20:08:18 -08:00
|
|
|
#define INJECT_ENGINE_REFERENCE(x) \
|
|
|
|
(x)->engine = engine; \
|
|
|
|
(x)->engineConfiguration = engineConfiguration; \
|
|
|
|
(x)->config = config; \
|
|
|
|
(x)->boardConfiguration = boardConfiguration;
|
2019-09-21 21:16:46 -07:00
|
|
|
|
2019-11-19 22:35:08 -08:00
|
|
|
#define EXPAND_Engine \
|
|
|
|
engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; \
|
|
|
|
persistent_config_s *config = engine->config; \
|
|
|
|
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
|
|
|
|
|
2019-11-24 21:02:53 -08:00
|
|
|
#ifndef EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
|
|
|
// We store a special changeable copy of configuration is RAM, so we can just compare them
|
2019-10-21 20:47:40 -07:00
|
|
|
#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
|
2019-11-24 21:02:53 -08:00
|
|
|
#else
|
|
|
|
// We cannot call prepareVoidConfiguration() for activeConfiguration if it's stored in flash,
|
|
|
|
// so we need to tell the firmware that it's "void" (i.e. zeroed, invalid) by setting a special flag variable,
|
|
|
|
// and then we consider 'x' as changed if it's just non-zero.
|
|
|
|
extern bool isActiveConfigurationVoid;
|
|
|
|
#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && engineConfiguration->x != 0))
|
|
|
|
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
|
|
|
|
|
|
|
#define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode))
|
2019-10-21 20:47:40 -07:00
|
|
|
|
2018-09-16 20:10:06 -07:00
|
|
|
#endif /* CONTROLLERS_CORE_COMMON_HEADERS_H_ */
|