giving C code access to CONFIG

This commit is contained in:
rusEfi 2020-02-27 01:32:26 -05:00
parent 3312dd8112
commit 89e6a33545
3 changed files with 37 additions and 20 deletions

View File

@ -8,9 +8,7 @@
#pragma once
#include "globalaccess.h"
#include "crc.h"
#include "engine_configuration_generated_structures.h"
#include "persistent_configuration.h"
#ifndef DEFAULT_ENGINE_TYPE
#define DEFAULT_ENGINE_TYPE DEFAULT_FRANKENSO
@ -26,13 +24,6 @@
float getRpmMultiplier(operation_mode_e mode);
void setOperationMode(engine_configuration_s *engineConfiguration, operation_mode_e mode);
typedef struct {
int version;
int size;
persistent_config_s persistentConfiguration;
crc_t value;
} persistent_config_container_s;
void prepareVoidConfiguration(engine_configuration_s *activeConfiguration);
void setTargetRpmCurve(int rpm DECLARE_CONFIG_PARAMETER_SUFFIX);
int getTargetRpmForIdleCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE);

View File

@ -0,0 +1,19 @@
/*
* @file persistent_configuration.h
*
* @date Feb 27, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#include "globalaccess.h"
#include "crc.h"
#include "engine_configuration_generated_structures.h"
typedef struct {
int version;
int size;
persistent_config_s persistentConfiguration;
crc_t value;
} persistent_config_container_s;

View File

@ -32,10 +32,24 @@
#define EXTERN_CONFIG \
extern engine_configuration_s *engineConfiguration; \
extern engine_configuration_s & activeConfiguration; \
extern engine_configuration_s activeConfiguration; \
extern persistent_config_container_s persistentState; \
extern persistent_config_s *config; \
/**
* this macro allows the compiled to figure out the complete static address, that's a performance
* optimization which is hopefully useful at least for anything trigger-related
*
* this is related to the fact that for unit tests we prefer to explicitly pass references in method signature thus code covered by
* unit tests would need to use by-reference access. These macro allow us to have faster by-address access in real firmware and by-reference
* access in unit tests
*/
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
#ifdef __cplusplus
#define EXTERN_ENGINE \
extern Engine ___engine; \
extern Engine *engine; \
@ -58,15 +72,6 @@
#define PASS_CONFIG_PARAMETER_SIGNATURE
#define PASS_CONFIG_PARAMETER_SUFFIX
/**
* this macro allows the compiled to figure out the complete static address, that's a performance
* optimization which is hopefully useful at least for anything trigger-related
*
* this is related to the fact that for unit tests we prefer to explicitly pass references in method signature thus code covered by
* unit tests would need to use by-reference access. These macro allow us to have faster by-address access in real firmware and by-reference
* access in unit tests
*/
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
#define ENGINE(x) ___engine.x
#define DEFINE_CONFIG_PARAM(x, y)
@ -74,3 +79,5 @@
#define PASS_CONFIG_PARAM(x)
#define EXPECTED_REMAINING_STACK 128
#endif /* __cplusplus */