auto-sync
This commit is contained in:
parent
8087cbd567
commit
c84fa2ec2e
|
@ -177,15 +177,15 @@ static void adcConfigListener(Engine *engine) {
|
||||||
calcFastAdcIndexes();
|
calcFastAdcIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnOnHardware(void) {
|
void turnOnHardware(Logging *sharedLogger) {
|
||||||
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
||||||
turnOnTriggerInputPins();
|
turnOnTriggerInputPins(sharedLogger);
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnOffHardware(void) {
|
void applyNewHardwareSettings(engine_configuration_s *oldConfiguration) {
|
||||||
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
||||||
turnOffTriggerInputPins();
|
applyNewTriggerInputPins(oldConfiguration);
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ void initHardware(Logging *l, Engine *engine) {
|
||||||
initTriggerCentral(sharedLogger, engine);
|
initTriggerCentral(sharedLogger, engine);
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
|
|
||||||
turnOnHardware();
|
turnOnHardware(sharedLogger);
|
||||||
|
|
||||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||||
initSpiModules(boardConfiguration);
|
initSpiModules(boardConfiguration);
|
||||||
|
|
|
@ -44,6 +44,7 @@ void unlockSpi(void);
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
void applyNewHardwareSettings(engine_configuration_s *oldConfiguration);
|
||||||
void initHardware(Logging *logging, Engine *engine);
|
void initHardware(Logging *logging, Engine *engine);
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,13 @@
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
#include "wave_analyzer_hw.h"
|
#include "wave_analyzer_hw.h"
|
||||||
|
|
||||||
|
#define TRIGGER_SUPPORTED_CHANNELS 2
|
||||||
|
|
||||||
static ICUDriver *primaryCrankDriver;
|
static ICUDriver *primaryCrankDriver;
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE
|
||||||
|
;
|
||||||
|
static Logging *logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* that's hardware timer input capture IRQ entry point
|
* that's hardware timer input capture IRQ entry point
|
||||||
|
@ -64,7 +68,7 @@ static ICUDriver *turnOnTriggerInputPin(brain_pin_e hwPin) {
|
||||||
shaft_icucfg.channel = ICU_CHANNEL_1;
|
shaft_icucfg.channel = ICU_CHANNEL_1;
|
||||||
|
|
||||||
ICUDriver *driver = getInputCaptureDriver(hwPin);
|
ICUDriver *driver = getInputCaptureDriver(hwPin);
|
||||||
print("initShaftPositionInputCapture %s\r\n", hwPortname(hwPin));
|
scheduleMsg(logger, "turnOnTriggerInputPin %s", hwPortname(hwPin));
|
||||||
// todo: reuse 'setWaveReaderMode' method here?
|
// todo: reuse 'setWaveReaderMode' method here?
|
||||||
if (driver != NULL) {
|
if (driver != NULL) {
|
||||||
efiIcuStart(driver, &shaft_icucfg);
|
efiIcuStart(driver, &shaft_icucfg);
|
||||||
|
@ -73,15 +77,45 @@ static ICUDriver *turnOnTriggerInputPin(brain_pin_e hwPin) {
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnOnTriggerInputPins(void) {
|
static void turnOffTriggerInputPin(brain_pin_e hwPin) {
|
||||||
primaryCrankDriver = turnOnTriggerInputPin(boardConfiguration->triggerInputPins[0]);
|
ICUDriver *driver = getInputCaptureDriver(hwPin);
|
||||||
turnOnTriggerInputPin(boardConfiguration->triggerInputPins[1]);
|
if (driver != NULL) {
|
||||||
|
icuDisable(driver);
|
||||||
print("crank input disabled\r\n");
|
icuStop(driver);
|
||||||
|
scheduleMsg(logger, "turnOffTriggerInputPin %s", hwPortname(hwPin));
|
||||||
|
unmarkPin(hwPin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnOffTriggerInputPins(void) {
|
static void rememberPrimaryChannel(void) {
|
||||||
|
primaryCrankDriver = getInputCaptureDriver(boardConfiguration->triggerInputPins[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void turnOnTriggerInputPins(Logging *sharedLogger) {
|
||||||
|
logger = sharedLogger;
|
||||||
|
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
||||||
|
turnOnTriggerInputPin(boardConfiguration->triggerInputPins[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rememberPrimaryChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyNewTriggerInputPins(engine_configuration_s *oldConfiguration) {
|
||||||
|
// first we will turn off all the changed pins
|
||||||
|
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
||||||
|
if (boardConfiguration->triggerInputPins[i] != oldConfiguration->bc.triggerInputPins[i]) {
|
||||||
|
turnOffTriggerInputPin(oldConfiguration->bc.triggerInputPins[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// then we will enable all the changed pins
|
||||||
|
for (int i = 0; i < TRIGGER_SUPPORTED_CHANNELS; i++) {
|
||||||
|
if (boardConfiguration->triggerInputPins[i] != oldConfiguration->bc.triggerInputPins[i]) {
|
||||||
|
turnOnTriggerInputPin(boardConfiguration->triggerInputPins[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
turnOffTriggerInputPin(oldConfiguration->bc.triggerInputPins[1]);
|
||||||
|
rememberPrimaryChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
#ifndef CRANK_INPUT_H_
|
#ifndef CRANK_INPUT_H_
|
||||||
#define CRANK_INPUT_H_
|
#define CRANK_INPUT_H_
|
||||||
|
|
||||||
void turnOnTriggerInputPins(void);
|
#include "engine.h"
|
||||||
void turnOffTriggerInputPins(void);
|
|
||||||
|
void turnOnTriggerInputPins(Logging *sharedLogger);
|
||||||
|
void applyNewTriggerInputPins(engine_configuration_s *oldConfiguration);
|
||||||
|
|
||||||
#endif /* CRANK_INPUT_H_ */
|
#endif /* CRANK_INPUT_H_ */
|
||||||
|
|
|
@ -168,6 +168,16 @@ void swo_init() {
|
||||||
// *((volatile unsigned *)(ITM_BASE + 0x40304)) = 0x00000100; // Formatter and Flush Control Register
|
// *((volatile unsigned *)(ITM_BASE + 0x40304)) = 0x00000100; // Formatter and Flush Control Register
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static engine_configuration_s activeConfiguration;
|
||||||
|
|
||||||
|
static void rememberCurrentConfiguration(void) {
|
||||||
|
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyNewConfiguration() {
|
||||||
|
applyNewHardwareSettings(&activeConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
void runRusEfi(void) {
|
void runRusEfi(void) {
|
||||||
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
|
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
|
||||||
|
|
||||||
|
@ -214,13 +224,15 @@ void runRusEfi(void) {
|
||||||
#endif
|
#endif
|
||||||
startStatusThreads(engine);
|
startStatusThreads(engine);
|
||||||
|
|
||||||
|
rememberCurrentConfiguration();
|
||||||
|
|
||||||
print("Running main loop\r\n");
|
print("Running main loop\r\n");
|
||||||
main_loop_started = true;
|
main_loop_started = true;
|
||||||
/**
|
/**
|
||||||
* This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
|
* This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
|
||||||
* control is around main_trigger_callback
|
* control is around main_trigger_callback
|
||||||
*/
|
*/
|
||||||
while (TRUE) {
|
while (true) {
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "stack#1");
|
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "stack#1");
|
||||||
|
|
||||||
#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
|
#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
|
||||||
|
|
Loading…
Reference in New Issue