rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
hellen_logic.h File Reference

Functions

void hellenWbo ()
 
void setHellenMegaEnPin (bool enableBoardOnStartUp=true)
 
void setHellenEnPin (Gpio pin, bool enableBoardOnStartUp=true)
 
void setHellen64MegaEnPin ()
 
bool isBoardWithPowerManagement ()
 
bool getHellenBoardEnabled ()
 
void hellenEnableEn (const char *msg="")
 
void hellenDisableEn (const char *msg="")
 
void hellenDisableEnSilently ()
 
void hellenBoardStandBy ()
 
void hellenMegaSdWithAccelerometer ()
 
void hellenMegaModule ()
 
void hellenMegaAccelerometerPreInitCS2Pin ()
 
void configureHellenCanTerminator ()
 
void setHellenCan ()
 
void setHellenCan2 ()
 
void setHellen64Can ()
 
void setHellenAnalogDividers ()
 
void setHellenVbatt ()
 
int detectHellenBoardId ()
 
void detectHellenBoardType ()
 
ObdCode boardGetAnalogDiagnostic ()
 
static void enableHellenSpi1 ()
 
static void setHellenSdCardSpi1Hardware ()
 
static void enableHellenSpi3 ()
 
static void setHellenSdCardSpi3NoCS ()
 
static void setAccelerometerSpi ()
 
static void setHellen64SdCardSpi ()
 
static void enableHellenSpi2 ()
 
void setHellenSdCardSpi2 ()
 
void setHellenSdCardSpi3 ()
 
void setDefaultHellenAtPullUps (float pullup=HELLEN_DEFAULT_AT_PULLUP)
 
void setHellenMMbaro ()
 

Function Documentation

◆ 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 analogGetDiagnostic(), boardGetAnalogInputDiagnostic(), and boardGetAnalogInputDiagnostic().

Here is the call graph for this function:
Here is the caller 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:

◆ detectHellenBoardId()

int detectHellenBoardId ( )

Definition at line 308 of file hellen_board_id.cpp.

308 {
309 int boardId = -1;
310#if defined( HELLEN_BOARD_ID_PIN_1) && !defined(HW_HELLEN_SKIP_BOARD_TYPE)
311 efiPrintf("Starting Hellen Board ID detection...");
312 Timer t;
313 t.reset();
314
315 const int numPins = 2;
316 Gpio rPins[numPins] = { HELLEN_BOARD_ID_PIN_1, HELLEN_BOARD_ID_PIN_2};
317
318 // We start from the estimated capacitance, but the real one can be +-10%
319 float C = HELLEN_BOARD_ID_CAPACITOR;
320
321 // we need to find the resistor values connected to the mcu pins and to the capacitor.
322 float R[numPins] = { 0 };
323 int rIdx[numPins] = { 0 };
324
325 HellenBoardIdFinder<numPins> finder(rPins);
326
327 // init some ChibiOs objects
328 chSemObjectInit(&finder.state.boardId_wake, 0);
329
330 // R1 is the first, R2 is the second
331 for (int i = 0; i < numPins; i++) {
332#ifdef HELLEN_BOARD_ID_DEBUG
333 efiPrintf("*** Resistor R%d...", i + 1);
334#endif /* HELLEN_BOARD_ID_DEBUG */
335
336 float Tc1_us = 0, Tc2_us = 0;
337 // We need several measurements for each resistor to increase the precision.
338 // But if any of the measurements fails, then abort!
339 if (!finder.measureChargingTimesAveraged(i, Tc1_us, Tc2_us))
340 break;
341
342 // Now roughly estimate the resistor value using the approximate threshold voltage.
343 float Rest = finder.calcEstimatedResistance(Tc1_us, C);
344 // check if we are inside the range
345 if (Rest < 300.0f || Rest > 15000.0f) {
346 efiPrintf("* Unrealistic estimated resistor value (%f)! Aborting!", Rest);
347 break;
348 }
349
350 // for the first resistor, we test only "major" values because we don't know the exact capacitance yet
351 bool testOnlyMajorSeries = (i == 0);
352
353 float Rmeasured, newC;
354 // Now calculate the R and C
355 R[i] = finder.calc(Tc1_us, Tc2_us, Rest, C, testOnlyMajorSeries, &Rmeasured, &newC, &rIdx[i]);
356 C = newC;
357
358#ifdef HELLEN_BOARD_ID_DEBUG
359 efiPrintf("* R = %f, Rmeasured = %f, Rest = %f, Creal = %f", R[i], Rmeasured, Rest, C);
360#endif /* HELLEN_BOARD_ID_DEBUG */
361 }
362
363 // in case the process was aborted
364 for (size_t k = 0; k < numPins; k++) {
365 efiExtiDisablePin(rPins[k]);
366 // release the pins
367 palSetPadMode(getBrainPinPort(rPins[k]), getBrainPinIndex(rPins[k]), PAL_MODE_RESET);
368 }
369
370 float elapsed_Ms = t.getElapsedSeconds() * 1000;
371
372 // Check that all resistors were actually detected
373 bool allRValid = true;
374 for (size_t i = 0; i < numPins; i++) {
375 allRValid &= R[i] != 0;
376 }
377
378 // Decode board ID only if all resistors could be decoded, otherwise we return -1
379 if (allRValid) {
380 boardId = HELLEN_GET_BOARD_ID(rIdx[0], rIdx[1]);
381 } else {
382 boardId = -1;
383 }
384
385 efiPrintf("* RESULT: BoardId = %d, R1 = %.0f, R2 = %.0f (Elapsed time: %.1f ms)", boardId, R[0], R[1], elapsed_Ms);
386#endif /* HELLEN_BOARD_ID_PIN_1 */
387 return boardId;
388}
void efiExtiDisablePin(brain_pin_e brainPin)
C
int getBrainPinIndex(Gpio brainPin)
ioportid_t getBrainPinPort(brain_pin_e brainPin)

Referenced by detectHellenBoardType().

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:

◆ enableHellenSpi1()

static void enableHellenSpi1 ( )
static

◆ enableHellenSpi2()

static void enableHellenSpi2 ( )
static

◆ enableHellenSpi3()

static void enableHellenSpi3 ( )
static

◆ 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 ( )

◆ isBoardWithPowerManagement()

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:

◆ setAccelerometerSpi()

static void setAccelerometerSpi ( )
static

Definition at line 64 of file hellen_logic.h.

64 {
65 /* accelerometer SPI is shared with SD card SPI on mm144 */
67 engineConfiguration->accelerometerCsPin = Gpio::H_SPI1_CS2;
68}

Referenced by alphax_4chan_defaultConfiguration(), and hellen_honda_k_boardDefaultConfiguration().

Here is the caller graph for this function:

◆ setDefaultHellenAtPullUps()

void setDefaultHellenAtPullUps ( float  pullup = HELLEN_DEFAULT_AT_PULLUP)
inline

Definition at line 101 of file hellen_logic.h.

Referenced by alphax_2chan_ConfigOverrides(), alphax_4chan_ConfigOverrides(), alphax_4kgdi_boardConfigOverrides(), alphax_8chan_reva_boardConfigOverrides(), alphax_gold_boardConfigOverrides(), hellen112_17_boardConfigOverrides(), hellen121_nissan_boardConfigOverrides(), hellen121_vag_boardConfigOverrides(), hellen154_hyundai_boardConfigOverrides(), hellen81_boardConfigOverrides(), hellen_gm_e67_boardConfigOverrides(), hellen_MiataNA6_boardConfigOverrides(), hellen_MiataNA96_boardConfigOverrides(), hellen_MiataNB1_boardConfigOverrides(), hellen_MiataNB2_boardConfigOverrides(), hellenMegaModule(), setMegaUaefiBoardConfigOverrides(), super_uaefi_boardConfigOverrides(), and uaefi_boardConfigOverrides().

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:

◆ setHellen64SdCardSpi()

static void setHellen64SdCardSpi ( )
static

◆ 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 = true 
)

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}
void hellenEnableEn(const char *msg)
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:

◆ setHellenMegaEnPin()

void setHellenMegaEnPin ( bool  enableBoardOnStartUp = true)

◆ setHellenMMbaro()

void setHellenMMbaro ( )
inline

◆ setHellenSdCardSpi1Hardware()

static void setHellenSdCardSpi1Hardware ( )
static

Definition at line 45 of file hellen_logic.h.

45 {
46 engineConfiguration->sdCardCsPin = Gpio::H_SPI1_CS1;
49}
static void enableHellenSpi1()

Referenced by hellenMegaSdWithAccelerometer().

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

◆ setHellenSdCardSpi2()

void setHellenSdCardSpi2 ( )
inline

◆ setHellenSdCardSpi3()

void setHellenSdCardSpi3 ( )
inline

Definition at line 93 of file hellen_logic.h.

93 {
96}
static void setHellenSdCardSpi3NoCS()

Referenced by hellen121_nissan_boardConfigOverrides(), hellen121_vag_boardConfigOverrides(), hellen81_boardConfigOverrides(), hellen88_boardConfigOverrides(), and hellen_MiataNB2_boardConfigOverrides().

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

◆ setHellenSdCardSpi3NoCS()

static void setHellenSdCardSpi3NoCS ( )
static

Definition at line 58 of file hellen_logic.h.

58 {
62}
static void enableHellenSpi3()

Referenced by setHellenSdCardSpi3().

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

◆ setHellenVbatt()

void setHellenVbatt ( )

Go to the source code of this file.