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 67 of file hellen_common.cpp.

67 {
68 // when board is powered down we should be more CANbus silent
69 return getHellenBoardEnabled();
70}
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 228 of file hellen_common.cpp.

229{
230#ifdef DIAG_5VP_PIN
231 /* paranoid check */
232 if (!isBrainPinValid(DIAG_5VP_PIN)) {
233 /* Pin is not defined - return success */
234 return ObdCode::None;
235 }
236
238#else
239 return ObdCode::None;
240#endif
241}
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 267 of file hellen_common.cpp.

267 {
268 // on mega-module we manage SD card power supply
269 if (getHellenBoardEnabled()) {
270 return true;
271 }
272
273 // Board can enable SD card power without enabling WBOs
274 if (onHellenSdChange(1)) {
275 efiPrintf(" *** turning SD power ONLY ***");
276 return true;
277 }
278
279 if (getTimeNowS() > 4 && !isIgnVoltage()) {
280 // looks like vehicle is OFF and we are hooked to USB - turn on peripheral to get Mass Storage Device USB profile
281 efiPrintf(" *** turning board ON to power SD card ***");
283 chThdSleepMilliseconds(200);
284
285 //check state
286 return getHellenBoardEnabled();
287 }
288
289 return false;
290}
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 212 of file hellen_common.cpp.

212 {
213 static bool initialized = false;
214 static OutputPin terminatorControlPin;
215 if (!initialized) {
216 initialized = true;
217 terminatorControlPin.initPin("CAN-term", H_SPI3_CS); // todo: make this pin configurable
218 terminatorControlPin.setValue(engineConfiguration->boardUseCanTerminator);
219 }
220}
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 222 of file hellen_common.cpp.

222 {
223#ifndef EFI_BOOTLOADER
225#endif /* EFI_BOOTLOADER */
226}
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 74 of file hellen_common.cpp.

74 {
75 return !getHellenBoardEnabled();
76}

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 243 of file hellen_common.cpp.

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

◆ getHellenBoardEnabled()

bool getHellenBoardEnabled ( )

Definition at line 63 of file hellen_common.cpp.

63 {
65}
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 172 of file hellen_common.cpp.

172 {
173 // 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
175 // todo: 200ms is totally random what's the science for this sleep duration?
176 chThdSleepMilliseconds(200);
177}
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 118 of file hellen_common.cpp.

118 {
119#if (EFI_FILE_LOGGING || EFI_CONFIGURATION_STORAGE) && EFI_PROD_CODE
120 // un-mount before turning power off SD card
121 // wait up to 1 second for SD card to become unmounted
122 efiPrintf("Long poll for SD card unmount");
123 int timeout = 1000;
125#if EFI_CONFIGURATION_STORAGE
126 // safe to call, even board does not have EXT FLASH
128#endif // EFI_CONFIGURATION_STORAGE
129 do {
130 chThdSleepMilliseconds(10);
132 break;
133 }
134 timeout -= 10;
135 } while (timeout > 0);
136#if EFI_CONFIGURATION_STORAGE
137 while (storageIsStorageRegistered(STORAGE_MFS_EXT_FLASH) && timeout > 0) {
138 chThdSleepMilliseconds(10);
139 timeout -= 10;
140 }
141#endif // EFI_CONFIGURATION_STORAGE
142#endif
143 efiPrintf("Turning board off [%s]", msg);
145}
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 147 of file hellen_common.cpp.

147 {
148 // this function is called from criticalShutdown() that may be called from hardFault handler
149 // please no call to OS functions!
151}
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 109 of file hellen_common.cpp.

109 {
110 efiPrintf("Turning board ON [%s]", msg);
112#if EFI_STORAGE_MFS
113 chThdSleepMilliseconds(1);
115#endif
116}
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 201 of file hellen_common.cpp.

201 {
202#if EFI_ONBOARD_MEMS
204 accelerometerChipSelect.initPin("mm-CS2", Gpio::H_SPI1_CS2);
206 }
207#else
208 criticalError("probably broken MEMS configuration?");
209#endif // EFI_ONBOARD_MEMS
210}
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 195 of file hellen_common.cpp.

195 {
199}
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 189 of file hellen_common.cpp.

189 {
191 // weird order of operations? i guess it does not really matter
193}
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 23 of file hellen_common.cpp.

23 {
24#ifdef DIAG_5VP_PIN
25static bool is5vpInit = false;
26 if (!is5vpInit) {
27 efiSetPadMode("5VP_STATE", DIAG_5VP_PIN, PAL_MODE_INPUT);
28 is5vpInit = true;
29 }
30#endif // DIAG_5VP_PIN
31}
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 59 of file hellen_common.cpp.

59 {
60 return false;
61}

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 78 of file hellen_common.cpp.

78{ 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 81 of file hellen_common.cpp.

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

Referenced by boardSdCardEnable().

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

◆ setHellen64Can()

void setHellen64Can ( )

Definition at line 51 of file hellen_common.cpp.

51 {
52 engineConfiguration->canTxPin = Gpio::B9;
53 engineConfiguration->canRxPin = Gpio::B8;
54}

Referenced by small_can_board_boardConfigOverrides().

Here is the caller graph for this function:

◆ setHellen64MegaEnPin()

void setHellen64MegaEnPin ( )

Definition at line 168 of file hellen_common.cpp.

168 {
169 setHellenEnPin(Gpio::MM64_GP1); // OUT_PWR_EN
170}
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 33 of file hellen_common.cpp.

33 {
34 // 4.7k high side/4.7k low side = 2.0 ratio divider
35 engineConfiguration->analogInputDividerCoefficient = 2.0f;
36
37 // set vbatt_divider 5.835
38 // 33k / 6.8k
39 engineConfiguration->vbattDividerCoeff = (33 + 6.8) / 6.8; // 5.835
40 engineConfiguration->adcVcc = 3.3f;
41}

Referenced by setHellenVbatt(), and small_can_board_boardConfigOverrides().

Here is the caller graph for this function:

◆ setHellenCan()

void setHellenCan ( )

◆ setHellenCan2()

void setHellenCan2 ( )

Definition at line 18 of file hellen_common.cpp.

18 {
19 engineConfiguration->can2RxPin = Gpio::B12;
20 engineConfiguration->can2TxPin = Gpio::B13;
21}

Referenced by alphax_8chan_boardConfigOverrides(), alphax_8chan_reva_boardConfigOverrides(), uaefi_boardDefaultConfiguration(), and validateBoardConfig().

Here is the caller graph for this function:

◆ setHellenEnPin()

void setHellenEnPin ( Gpio  pin,
bool  enableBoardOnStartUp 
)

Definition at line 153 of file hellen_common.cpp.

153 {
156 megaEn.initPin("EN", pin);
157 if (enableBoardOnStartUp) {
158 hellenEnableEn("start-up");
159 }
160 }
161}
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 93 of file hellen_common.cpp.

93 {
94 // todo: can we use 'megaEn.getLogicValue()' instead?
95 static int currentHellenEnValue = -1;
96
97 megaEn.setValue(value, /*isForce*/ true);
98 if (currentHellenEnValue != value) {
99 currentHellenEnValue = value;
100#ifndef EFI_BOOTLOADER
102#endif
103 }
104 // todo: shall we move below callbacks into 'only-if-changed' conditional block?
105 onHellenEnChange(value);
107}
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 70 of file accelerometer.cpp.

Referenced by hellenMegaAccelerometerPreInitCS2Pin(), and initAccelerometer().

◆ hellenEnPinInitialized

bool hellenEnPinInitialized = false
static

Definition at line 72 of file hellen_common.cpp.

Referenced by setHellenEnPin().

◆ hellenEnPinStateChange

Timer hellenEnPinStateChange

Definition at line 90 of file hellen_common.cpp.

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

◆ megaEn

OutputPin megaEn
static

Definition at line 56 of file hellen_common.cpp.

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

Go to the source code of this file.