rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
hellen_common.cpp File Reference

Functions

void hellenWbo ()
 
void setHellenCan ()
 
void setHellenCan2 ()
 
static void init5vpDiag ()
 
void setHellenAnalogDividers ()
 
void setHellenVbatt ()
 
void setHellen64Can ()
 
PUBLIC_API_WEAK bool isBoardWithPowerManagement ()
 
bool getHellenBoardEnabled ()
 
bool boardEnableSendWidebandInfo ()
 
bool fansDisabledByBoardStatus ()
 
PUBLIC_API_WEAK void onHellenEnChange (int value)
 
PUBLIC_API_WEAK bool onHellenSdChange (int value)
 
static void setHellenEnValue (int value)
 
void hellenEnableEn (const char *msg)
 
void hellenDisableEn (const char *msg)
 
void hellenDisableEnSilently ()
 
void setHellenEnPin (Gpio pin, bool enableBoardOnStartUp)
 
void setHellenMegaEnPin (bool enableBoardOnStartUp)
 
void setHellen64MegaEnPin ()
 
void hellenBoardStandBy ()
 
void hellenMegaSdWithAccelerometer ()
 
void hellenMegaModule ()
 
void hellenMegaAccelerometerPreInitCS2Pin ()
 
void configureHellenCanTerminator ()
 
void detectHellenBoardType ()
 
ObdCode boardGetAnalogDiagnostic ()
 
float getAnalogInputDividerCoefficient (adc_channel_e hwChannel)
 
bool boardSdCardEnable ()
 

Variables

static OutputPin megaEn
 
static bool hellenEnPinInitialized = false
 
Timer hellenEnPinStateChange
 
OutputPin accelerometerChipSelect
 

Function Documentation

◆ boardEnableSendWidebandInfo()

bool boardEnableSendWidebandInfo ( )

Definition at line 66 of file hellen_common.cpp.

66 {
67 // when board is powered down we should be more CANbus silent
68 return getHellenBoardEnabled();
69}
bool getHellenBoardEnabled()

Referenced by CanWrite::PeriodicTask().

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

◆ boardGetAnalogDiagnostic()

ObdCode boardGetAnalogDiagnostic ( )

Definition at line 227 of file hellen_common.cpp.

228{
229#ifdef DIAG_5VP_PIN
230 /* paranoid check */
231 if (!isBrainPinValid(DIAG_5VP_PIN)) {
232 /* Pin is not defined - return success */
233 return ObdCode::None;
234 }
235
237#else
238 return ObdCode::None;
239#endif
240}
bool efiReadPin(brain_pin_e pin)
Definition io_pins.cpp:89
@ OBD_ECM_VSS_OUTPUT_A_MALFUNCTION
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by boardGetAnalogInputDiagnostic().

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

◆ boardSdCardEnable()

bool boardSdCardEnable ( )

Definition at line 266 of file hellen_common.cpp.

266 {
267 // on mega-module we manage SD card power supply
268 if (getHellenBoardEnabled()) {
269 return true;
270 }
271
272 // Board can enable SD card power without enabling WBOs
273 if (onHellenSdChange(1)) {
274 efiPrintf(" *** turning SD power ONLY ***");
275 return true;
276 }
277
278 if (getTimeNowS() > 4 && !isIgnVoltage()) {
279 // looks like vehicle is OFF and we are hooked to USB - turn on peripheral to get Mass Storage Device USB profile
280 efiPrintf(" *** turning board ON to power SD card ***");
282 chThdSleepMilliseconds(200);
283
284 //check state
285 return getHellenBoardEnabled();
286 }
287
288 return false;
289}
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42
void hellenEnableEn(const char *msg)
PUBLIC_API_WEAK bool onHellenSdChange(int value)
bool isIgnVoltage()
Here is the call graph for this function:

◆ configureHellenCanTerminator()

void configureHellenCanTerminator ( )

Definition at line 211 of file hellen_common.cpp.

211 {
212 static bool initialized = false;
213 static OutputPin terminatorControlPin;
214 if (!initialized) {
215 initialized = true;
216 terminatorControlPin.initPin("CAN-term", H_SPI3_CS); // todo: make this pin configurable
218 }
219}
Single output pin reference and state.
Definition efi_output.h:49
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
static constexpr engine_configuration_s * engineConfiguration
static int initialized
Definition histogram.cpp:39

Referenced by hellen112_17_boardConfigOverrides(), and hellen_honda_k_boardConfigOverrides().

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

◆ detectHellenBoardType()

void detectHellenBoardType ( )

Definition at line 221 of file hellen_common.cpp.

221 {
222#ifndef EFI_BOOTLOADER
224#endif /* EFI_BOOTLOADER */
225}
EngineState engineState
Definition engine.h:344
static EngineAccessor engine
Definition engine.h:413
int hackHellenBoardId(int detectedId)
int detectHellenBoardId()

Referenced by detectBoardType().

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

◆ fansDisabledByBoardStatus()

bool fansDisabledByBoardStatus ( )

Definition at line 73 of file hellen_common.cpp.

73 {
74 return !getHellenBoardEnabled();
75}

Referenced by FanController::getState().

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

◆ getAnalogInputDividerCoefficient()

float getAnalogInputDividerCoefficient ( adc_channel_e  hwChannel)

Definition at line 242 of file hellen_common.cpp.

242 {
243#if (HELLEN_BOARD_MM64 == TRUE)
244 (void)hwChannel;
245 if (0)
246#endif
247#if (HELLEN_BOARD_MM100 == TRUE)
248 if (hwChannel == MM100_IN_CRANK_ANALOG) [[unlikely]]
249#endif
250#if (HELLEN_BOARD_MM144 == TRUE)
251 if (hwChannel == H144_IN_CRANK_ANALOG) [[unlikely]]
252#endif
253#if (HELLEN_BOARD_MM176 == TRUE)
254 if (hwChannel == MM176_IN_CRANK_ANALOG) [[unlikely]]
255#endif
256 {
257 // (4.7K || 5.1K) + 4.7K divider
258 // 4.7K || 5.1K == 2.445K
259 return (4.7f + 2.445f) / 4.7f;
260 }
261
263}

◆ getHellenBoardEnabled()

bool getHellenBoardEnabled ( )

Definition at line 62 of file hellen_common.cpp.

62 {
64}
bool getLogicValue() const
Definition efi_gpio.cpp:667
PUBLIC_API_WEAK bool isBoardWithPowerManagement()
static OutputPin megaEn

Referenced by boardEnableSendWidebandInfo(), boardSdCardEnable(), fansDisabledByBoardStatus(), sendCanVerbose(), and setHwQcMode().

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

◆ hellenBoardStandBy()

void hellenBoardStandBy ( )

Definition at line 171 of file hellen_common.cpp.

171 {
172 // we need to turn 'megaEn' and pause for a bit to make sure that WBO is off and does not wake main firmware right away
174 // todo: 200ms is totally random what's the science for this sleep duration?
175 chThdSleepMilliseconds(200);
176}
void hellenDisableEn(const char *msg)

Referenced by onBoardStandBy().

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

◆ hellenDisableEn()

void hellenDisableEn ( const char msg)

Definition at line 117 of file hellen_common.cpp.

117 {
118#if (EFI_FILE_LOGGING || EFI_CONFIGURATION_STORAGE) && EFI_PROD_CODE
119 // un-mount before turning power off SD card
120 // wait up to 1 second for SD card to become unmounted
121 efiPrintf("Long poll for SD card unmount");
122 int timeout = 1000;
124#if EFI_CONFIGURATION_STORAGE
125 // safe to call, even board does not have EXT FLASH
127#endif // EFI_CONFIGURATION_STORAGE
128 do {
129 chThdSleepMilliseconds(10);
131 break;
132 }
133 timeout -= 10;
134 } while (timeout > 0);
135#if EFI_CONFIGURATION_STORAGE
136 while (storageIsStorageRegistered(STORAGE_MFS_EXT_FLASH) && timeout > 0) {
137 chThdSleepMilliseconds(10);
138 timeout -= 10;
139 }
140#endif // EFI_CONFIGURATION_STORAGE
141#endif
142 efiPrintf("Turning board off [%s]", msg);
144}
void hellenDisableEnSilently()
void sdCardRequestMode(SD_MODE mode)
SD_MODE sdCardGetCurrentMode(void)
@ SD_MODE_UNMOUNT
Definition mmc_card.h:20
@ SD_MODE_IDLE
Definition mmc_card.h:17
bool storageIsStorageRegistered(StorageType type)
Definition storage.cpp:230
bool storagRequestUnregisterStorage(StorageType id)
Definition storage.cpp:243
@ STORAGE_MFS_EXT_FLASH
Definition storage.h:40

Referenced by configureRusefiLuaHooks(), and hellenBoardStandBy().

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

◆ hellenDisableEnSilently()

void hellenDisableEnSilently ( )

Definition at line 146 of file hellen_common.cpp.

146 {
147 // this function is called from criticalShutdown() that may be called from hardFault handler
148 // please no call to OS functions!
150}
static void setHellenEnValue(int value)

Referenced by hellenDisableEn(), and turnAllPinsOff().

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

◆ hellenEnableEn()

void hellenEnableEn ( const char msg)

Definition at line 108 of file hellen_common.cpp.

108 {
109 efiPrintf("Turning board ON [%s]", msg);
111#if EFI_STORAGE_MFS
112 chThdSleepMilliseconds(1);
114#endif
115}
bool storagRequestRegisterStorage(StorageType id)
Definition storage.cpp:238

Referenced by boardSdCardEnable(), configureRusefiLuaHooks(), setHellenEnPin(), and setHwQcMode().

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

◆ hellenMegaAccelerometerPreInitCS2Pin()

void hellenMegaAccelerometerPreInitCS2Pin ( )

Definition at line 200 of file hellen_common.cpp.

200 {
201#if EFI_ONBOARD_MEMS
203 accelerometerChipSelect.initPin("mm-CS2", Gpio::H_SPI1_CS2);
205 }
206#else
207 criticalError("probably broken MEMS configuration?");
208#endif // EFI_ONBOARD_MEMS
209}
bool isInitialized() const
Definition efi_gpio.cpp:559
OutputPin accelerometerChipSelect

Referenced by hellenMegaSdWithAccelerometer(), and setMegaUaefiBoardConfigOverrides().

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

◆ hellenMegaModule()

void hellenMegaModule ( )

Definition at line 194 of file hellen_common.cpp.

194 {
198}
void hellenMegaSdWithAccelerometer()
void setHellenVbatt()
void setDefaultHellenAtPullUps(float pullup=HELLEN_DEFAULT_AT_PULLUP)

Referenced by alphax_8chan_boardConfigOverrides(), alphax_silver_boardConfigOverrides(), alphax_silver_revA_boardConfigOverrides(), hellen154hyundai_f7_boardConfigOverrides(), and hellen_honda_k_boardConfigOverrides().

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

◆ hellenMegaSdWithAccelerometer()

void hellenMegaSdWithAccelerometer ( )

Definition at line 188 of file hellen_common.cpp.

188 {
190 // weird order of operations? i guess it does not really matter
192}
void hellenMegaAccelerometerPreInitCS2Pin()
static void setHellenSdCardSpi1Hardware()

Referenced by alphax_2chan_ConfigOverrides(), alphax_4chan_ConfigOverrides(), alphax_4kgdi_boardConfigOverrides(), alphax_gold_boardConfigOverrides(), hellen112_17_boardConfigOverrides(), hellenMegaModule(), super_uaefi_boardConfigOverrides(), and uaefi_boardConfigOverrides().

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

◆ hellenWbo()

void hellenWbo ( )

◆ init5vpDiag()

static void init5vpDiag ( )
static

Definition at line 22 of file hellen_common.cpp.

22 {
23#ifdef DIAG_5VP_PIN
24static bool is5vpInit = false;
25 if (!is5vpInit) {
26 efiSetPadMode("5VP_STATE", DIAG_5VP_PIN, PAL_MODE_INPUT);
27 is5vpInit = true;
28 }
29#endif // DIAG_5VP_PIN
30}
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)

Referenced by setHellenVbatt().

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

◆ isBoardWithPowerManagement()

PUBLIC_API_WEAK bool isBoardWithPowerManagement ( )

Definition at line 58 of file hellen_common.cpp.

58 {
59 return false;
60}

Referenced by FuelLevelFunc::convert(), and getHellenBoardEnabled().

Here is the caller graph for this function:

◆ onHellenEnChange()

PUBLIC_API_WEAK void onHellenEnChange ( int  value)

Definition at line 77 of file hellen_common.cpp.

77{ UNUSED(value); }
UNUSED(samplingTimeSeconds)

Referenced by setHellenEnValue().

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

◆ onHellenSdChange()

PUBLIC_API_WEAK bool onHellenSdChange ( int  value)

Definition at line 80 of file hellen_common.cpp.

80 {
81 UNUSED(value);
82
83 // most Hellen board have no separate SD card power control
84 // return false and let MegaEn to be enabled
85 return false;
86}

Referenced by boardSdCardEnable().

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

◆ setHellen64Can()

void setHellen64Can ( )

◆ setHellen64MegaEnPin()

void setHellen64MegaEnPin ( )

Definition at line 167 of file hellen_common.cpp.

167 {
168 setHellenEnPin(Gpio::MM64_GP1); // OUT_PWR_EN
169}
void setHellenEnPin(Gpio pin, bool enableBoardOnStartUp)

Referenced by small_can_board_boardConfigOverrides().

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

◆ setHellenAnalogDividers()

void setHellenAnalogDividers ( )

Definition at line 32 of file hellen_common.cpp.

32 {
33 // 4.7k high side/4.7k low side = 2.0 ratio divider
35
36 // set vbatt_divider 5.835
37 // 33k / 6.8k
38 engineConfiguration->vbattDividerCoeff = (33 + 6.8) / 6.8; // 5.835
40}

Referenced by setHellenVbatt(), and small_can_board_boardConfigOverrides().

Here is the caller graph for this function:

◆ setHellenCan()

void setHellenCan ( )

◆ setHellenCan2()

void setHellenCan2 ( )

◆ setHellenEnPin()

void setHellenEnPin ( Gpio  pin,
bool  enableBoardOnStartUp 
)

Definition at line 152 of file hellen_common.cpp.

152 {
155 megaEn.initPin("EN", pin);
156 if (enableBoardOnStartUp) {
157 hellenEnableEn("start-up");
158 }
159 }
160}
static bool hellenEnPinInitialized
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by alphax_2chan_ConfigOverrides(), alphax_4chan_ConfigOverrides(), alphax_8chan_boardInitHardware(), alphax_8chan_reva_boardInitHardware(), setHellen64MegaEnPin(), and setHellenMegaEnPin().

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

◆ setHellenEnValue()

static void setHellenEnValue ( int  value)
static

Definition at line 92 of file hellen_common.cpp.

92 {
93 // todo: can we use 'megaEn.getLogicValue()' instead?
94 static int currentHellenEnValue = -1;
95
96 megaEn.setValue(value, /*isForce*/ true);
97 if (currentHellenEnValue != value) {
98 currentHellenEnValue = value;
99#ifndef EFI_BOOTLOADER
101#endif
102 }
103 // todo: shall we move below callbacks into 'only-if-changed' conditional block?
104 onHellenEnChange(value);
106}
static void ResetFilters()
Timer hellenEnPinStateChange
PUBLIC_API_WEAK void onHellenEnChange(int value)

Referenced by hellenDisableEnSilently(), and hellenEnableEn().

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

◆ setHellenMegaEnPin()

void setHellenMegaEnPin ( bool  enableBoardOnStartUp)

◆ setHellenVbatt()

void setHellenVbatt ( )

Variable Documentation

◆ accelerometerChipSelect

OutputPin accelerometerChipSelect
extern

We need to make sure that accelerometer device which physically exists does not conflict with SD card in case of shared SPI. We reply on specific order of execution here: 1) accelerometer pre-initialization into safe CS pin state 2) SD card initialization 3) accelerometer main initialization if accelerometer feature is desired

Definition at line 65 of file accelerometer.cpp.

Referenced by hellenMegaAccelerometerPreInitCS2Pin(), and initAccelerometer().

◆ hellenEnPinInitialized

bool hellenEnPinInitialized = false
static

Definition at line 71 of file hellen_common.cpp.

Referenced by setHellenEnPin().

◆ hellenEnPinStateChange

Timer hellenEnPinStateChange

Definition at line 89 of file hellen_common.cpp.

Referenced by FuelLevelFunc::convert(), and setHellenEnValue().

◆ megaEn

OutputPin megaEn
static

Definition at line 55 of file hellen_common.cpp.

Referenced by getHellenBoardEnabled(), setHellenEnPin(), and setHellenEnValue().

Go to the source code of this file.