rusEFI
The most advanced open source ECU
Functions
settings.h File Reference

Detailed Description

This file is about configuring engine via the human-readable protocol.

Date
Dec 30, 2012
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file settings.h.

Functions

void initSettings ()
 
void printSpiState ()
 
void printConfiguration ()
 Prints current engine configuration to human-readable console. More...
 
void scheduleStopEngine ()
 
void setEngineTypeAndSave (int value)
 
void setEngineType (int value, bool isWriteToFlash=true)
 
void readPin (const char *pinName)
 
void printDateTime ()
 
void setDateTime (const char *const isoDateTime)
 

Function Documentation

◆ initSettings()

void initSettings ( )

Definition at line 629 of file settings.cpp.

629  {
630 #if EFI_SIMULATOR
631  printf("initSettings\n");
632 #endif // EFI_SIMULATOR
633 
634  // todo: start saving values into flash right away?
635 
636 #if EFI_ENGINE_CONTROL
637  // used by HW CI
638  addConsoleAction(CMD_INDIVIDUAL_INJECTION, setIndividualCoilsIgnition);
639  addConsoleAction("showconfig", printConfiguration);
640  addConsoleActionF("set_whole_timing_map", setWholeTimingMapCmd);
641 #endif // EFI_ENGINE_CONTROL
642 
643  addConsoleAction("stopengine", (Void) scheduleStopEngine);
644 
645  // todo: refactor this - looks like all boolean flags should be controlled with less code duplication
646  addConsoleActionI("enable_spi", enableSpi);
647  addConsoleActionI("disable_spi", disableSpi);
648 
649  addConsoleActionS(CMD_ENABLE, enable);
650  addConsoleActionS(CMD_DISABLE, disable);
651 
652  addConsoleActionSS(CMD_SET, setValue);
653  addConsoleActionS(CMD_GET, getValue);
654 
655 #if EFI_PROD_CODE
656  addConsoleActionSS(CMD_IGNITION_PIN, setIgnitionPin);
657  addConsoleActionSS(CMD_TRIGGER_PIN, setTriggerInputPin);
658  addConsoleActionSS(CMD_TRIGGER_SIMULATOR_PIN, setTriggerSimulatorPin);
659 
660  addConsoleActionI(CMD_ECU_UNLOCK, unlockEcu);
661 
662  addConsoleActionS(CMD_ALTERNATOR_PIN, setAlternatorPin);
663  addConsoleActionS(CMD_IDLE_PIN, setIdlePin);
664 
665  addConsoleActionS("bench_clearpin", benchClearPin);
666  addConsoleActionS("bench_setpin", benchSetPin);
667  addConsoleActionS("readpin", readPin);
668  addConsoleAction("hw_qc_mode", [](){
669  extern bool qcDirectPinControlMode;
670  qcDirectPinControlMode = true;
671  });
672  addConsoleActionS("bench_set_output_mode", [](const char *pinName){
674  if (pin == Gpio::Invalid) {
675  return;
676  }
677  efiSetPadModeWithoutOwnershipAcquisition("manual-mode", pin, PAL_MODE_OUTPUT_PUSHPULL);
678  });
679 
680 #if HAL_USE_ADC
681  addConsoleAction("adc_report", printFullAdcReport);
682  addConsoleActionSS("set_analog_input_pin", setAnalogInputPin);
683 #endif // HAL_USE_ADC
684  addConsoleActionSS(CMD_LOGIC_PIN, setLogicInputPin);
685 #endif // EFI_PROD_CODE
686 }
void printFullAdcReport(void)
Definition: adc_inputs.cpp:87
bool qcDirectPinControlMode
void addConsoleActionF(const char *token, VoidFloat callback)
void addConsoleActionS(const char *token, VoidCharPtr callback)
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionSS(const char *token, VoidCharPtrCharPtr callback)
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
void(* Void)(void)
Definition: cli_registry.h:52
Gpio
@ Invalid
void unlockEcu(int password)
Definition: engine2.cpp:269
void efiSetPadModeWithoutOwnershipAcquisition(const char *msg, brain_pin_e brainPin, iomode_t mode)
Definition: io_pins.cpp:61
static void enableSpi(int index)
Definition: settings.cpp:445
static brain_pin_e parseBrainPinWithErrorMessage(const char *pinName)
Definition: settings.cpp:172
static void enable(const char *param)
Definition: settings.cpp:437
static void setIgnitionPin(const char *indexStr, const char *pinName)
Definition: settings.cpp:186
static void benchSetPin(const char *pinName)
Definition: settings.cpp:227
static void getValue(const char *paramStr)
Definition: settings.cpp:460
static void disableSpi(int index)
Definition: settings.cpp:449
static void setIndividualCoilsIgnition()
Definition: settings.cpp:142
static void setValue(const char *paramStr, const char *valueStr)
Definition: settings.cpp:553
static void setAlternatorPin(const char *pinName)
Definition: settings.cpp:251
void readPin(const char *pinName)
Definition: settings.cpp:201
static void benchClearPin(const char *pinName)
Definition: settings.cpp:223
void printConfiguration()
Prints current engine configuration to human-readable console.
Definition: settings.cpp:55
void scheduleStopEngine()
Definition: settings.cpp:456
static void setWholeTimingMapCmd(float value)
Definition: settings.cpp:162
static void setTriggerSimulatorPin(const char *indexStr, const char *pinName)
Definition: settings.cpp:274
static void setTriggerInputPin(const char *indexStr, const char *pinName)
Definition: settings.cpp:261
static void setAnalogInputPin(const char *sensorStr, const char *pinName)
Definition: settings.cpp:290
static void setIdlePin(const char *pinName)
Definition: settings.cpp:247
static void setLogicInputPin(const char *indexStr, const char *pinName)
Definition: settings.cpp:326
static void disable(const char *param)
Definition: settings.cpp:441
brain_pin_e pin
Definition: stm32_adc.cpp:15
printf("\n")

Referenced by commonInitEngineController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printConfiguration()

void printConfiguration ( )

Prints current engine configuration to human-readable console.

Definition at line 55 of file settings.cpp.

55  {
56 
57  efiPrintf("Template %s/%d trigger %s/%s/%d", getEngine_type_e(engineConfiguration->engineType),
61 
62  efiPrintf("configurationVersion=%d", engine->getGlobalConfigurationVersion());
63 
64 #if EFI_PROD_CODE
65  printSpiState();
66 #endif // EFI_PROD_CODE
67 }
const char * getEngine_load_mode_e(engine_load_mode_e value)
const char * getTrigger_type_e(trigger_type_e value)
const char * getEngine_type_e(engine_type_e value)
int getGlobalConfigurationVersion(void) const
Definition: engine.cpp:317
Engine * engine
engine_configuration_s * engineConfiguration
void printSpiState()
Definition: settings.cpp:44

Referenced by initSettings(), setAlgorithmInt(), setCrankingInjectionMode(), setCrankingRpm(), setCrankingTimingAngle(), setEngineType(), setFiringOrder(), setGlobalTriggerAngleOffset(), setInjectionMode(), setRpmHardLimit(), and setTriggerType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printDateTime()

void printDateTime ( )

Definition at line 688 of file settings.cpp.

688  {
689 #if EFI_RTC
691 #else // EFI_RTC
692  efiPrintf("Cannot print time: RTC not supported");
693 #endif // EFI_RTC
694 }
void printRtcDateTime()
Definition: rtc_helper.cpp:42

Referenced by getValue(), and initRtc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printSpiState()

void printSpiState ( )

◆ readPin()

void readPin ( const char *  pinName)

Definition at line 201 of file settings.cpp.

201  {
203  if (pin == Gpio::Invalid) {
204  return;
205  }
206  int physicalValue = palReadPad(getHwPort("read", pin), getHwPin("read", pin));
207  efiPrintf("pin %s value %d", hwPortname(pin), physicalValue);
208 }
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
const char * hwPortname(brain_pin_e brainPin)

Referenced by benchSetPinValue(), and initSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scheduleStopEngine()

void scheduleStopEngine ( )

See 'LimpManager::isEngineStop' for code which actually stops engine

Definition at line 456 of file settings.cpp.

456  {
458 }
void doScheduleStopEngine()

Referenced by executeTSCommand(), initSettings(), and Engine::isInShutdownMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDateTime()

void setDateTime ( const char *const  isoDateTime)

Definition at line 696 of file settings.cpp.

696  {
697 #if EFI_RTC
698  if (strlen(isoDateTime) >= 19 && isoDateTime[10] == 'T') {
699  efidatetime_t dateTime;
700  dateTime.year = atoi(isoDateTime);
701  dateTime.month = atoi(isoDateTime + 5);
702  dateTime.day = atoi(isoDateTime + 8);
703  dateTime.hour = atoi(isoDateTime + 11);
704  dateTime.minute = atoi(isoDateTime + 14);
705  dateTime.second = atoi(isoDateTime + 17);
706  if (dateTime.year != ATOI_ERROR_CODE &&
707  dateTime.month >= 1 && dateTime.month <= 12 &&
708  dateTime.day >= 1 && dateTime.day <= 31 &&
709  dateTime.hour <= 23 &&
710  dateTime.minute <= 59 &&
711  dateTime.second <= 59) {
712  // doesn't concern about leap years or seconds; ChibiOS doesn't support (added) leap seconds anyway
713  setRtcDateTime(&dateTime);
714  return;
715  }
716  }
717  efiPrintf("date_set Date parameter %s is wrong", isoDateTime);
718 #else // EFI_RTC
719  efiPrintf("Cannot set time: RTC not supported");
720 #endif // EFI_RTC
721 }
void setRtcDateTime(efidatetime_t const *const dateTime)
Definition: rtc_helper.cpp:50
uint8_t minute
Definition: rusefi_types.h:54
uint8_t hour
Definition: rusefi_types.h:53
uint8_t second
Definition: rusefi_types.h:55
uint32_t year
Definition: rusefi_types.h:50
uint8_t month
Definition: rusefi_types.h:51

Referenced by setValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEngineType()

void setEngineType ( int  value,
bool  isWriteToFlash = true 
)

Definition at line 729 of file settings.cpp.

729  {
730  {
731 #if EFI_PROD_CODE
732  chibios_rt::CriticalSectionLocker csl;
733 #endif // EFI_PROD_CODE
734 
738 
739 #if EFI_CONFIGURATION_STORAGE
740  if (isWriteToFlash) {
741  writeToFlashNow();
742  }
743 #endif /* EFI_CONFIGURATION_STORAGE */
744  }
746 #if EFI_ENGINE_CONTROL && ! EFI_UNIT_TEST
748 #endif // ! EFI_UNIT_TEST
749 }
void resetEngineSnifferIfInTestMode()
Definition: engine.cpp:56
void incrementGlobalConfigurationVersion(const char *msg)
void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e engineType)
engine_type_e
Definition: engine_types.h:18
void writeToFlashNow()
Definition: flash_main.cpp:162

Referenced by executeTSCommand(), processCanQcBenchTest(), and setEngineTypeAndSave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEngineTypeAndSave()

void setEngineTypeAndSave ( int  value)

Definition at line 725 of file settings.cpp.

725  {
726  setEngineType(value, true);
727 }
void setEngineType(int value, bool isWriteToFlash)
Definition: settings.cpp:729
Here is the call graph for this function:

Go to the source code of this file.