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

Detailed Description

Date
Apr 14, 2014
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file microsecond_timer.h.

Functions

void initMicrosecondTimer ()
 
void setHardwareSchedulerTimer (efitick_t nowNt, efitick_t setTimeNt)
 

Function Documentation

◆ initMicrosecondTimer()

void initMicrosecondTimer ( )

Definition at line 172 of file microsecond_timer.cpp.

172 {
174
175 hwStarted = true;
176
178
180
182#if EFI_EMULATE_POSITION_SENSORS
184#endif /* EFI_EMULATE_POSITION_SENSORS */
185}
efitick_t getTimeNowNt()
Definition efitime.cpp:19
static bool hwStarted
static void watchDogBuddyCallback()
static MicrosecondTimerWatchdogController watchdogControllerInstance
static void validateHardwareTimer()
static efitick_t lastSetTimerTimeNt
void portInitMicrosecondTimer()

Referenced by initSingleTimerExecutorHardware().

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

◆ setHardwareSchedulerTimer()

void setHardwareSchedulerTimer ( efitick_t  nowNt,
efitick_t  setTimeNt 
)

sets the alarm to the specified number of microseconds from now. This function should be invoked under kernel lock which would disable interrupts.

#259 BUG error: not positive deltaTimeNt Once in a while we night get an interrupt where we do not expect it

Definition at line 50 of file microsecond_timer.cpp.

50 {
51 criticalAssertVoid(hwStarted, "HW.started");
52
54
55 // How many ticks in the future is this event?
56 const auto timeDeltaNt = setTimeNt - nowNt;
57
58 /**
59 * #259 BUG error: not positive deltaTimeNt
60 * Once in a while we night get an interrupt where we do not expect it
61 */
62 if (timeDeltaNt <= 0) {
65 }
66
67 // We need the timer to fire after we return - too close to now may actually schedule in the past
68 if (timeDeltaNt < US2NT(2)) {
69 setTimeNt = nowNt + US2NT(2);
70 } else if (timeDeltaNt >= TOO_FAR_INTO_FUTURE_NT) {
71 uint32_t delta32;
72 if (timeDeltaNt > UINT32_MAX) {
73 delta32 = UINT32_MAX;
74 } else {
75 delta32 = timeDeltaNt;
76 }
77
78 // we are trying to set callback for too far into the future. This does not look right at all
79 firmwareError(ObdCode::CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareSchedulerTimer() too far: %lu", delta32);
80 return;
81 }
82
83 // Skip scheduling if there's a firmware error active
84 if (hasFirmwareError()) {
85 return;
86 }
87
88 // Do the actual hardware-specific timer set operation
89 portSetHardwareSchedulerTimer(nowNt, setTimeNt);
90
92 isTimerPending = true;
94}
bool warning(ObdCode code, const char *fmt,...)
void firmwareError(ObdCode code, const char *fmt,...)
static bool isTimerPending
static int timerFreezeCounter
static int timerRestartCounter
static int setHwTimerCounter
void portSetHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt)
@ CUSTOM_ERR_TIMER_OVERFLOW
@ CUSTOM_OBD_LOCAL_FREEZE

Referenced by SingleTimerExecutor::scheduleTimerCallback().

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

Go to the source code of this file.