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

Functions

void portInitMicrosecondTimer ()
 
void portSetHardwareSchedulerTimer (efitick_t nowNt, efitick_t setTimeNt)
 
void portMicrosecondTimerCallback ()
 

Function Documentation

◆ portInitMicrosecondTimer()

void portInitMicrosecondTimer ( )

This file defines the API for the microsecond timer that a port needs to implement

Do not call these functions directly, they should only be called by microsecond_timer.cpp

Definition at line 35 of file microsecond_timer_gpt.cpp.

35 {
36 gptStart(&GPTDEVICE, &gpt5cfg);
37 efiAssertVoid(ObdCode::CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
38}
static constexpr GPTConfig gpt5cfg
@ CUSTOM_ERR_TIMER_STATE

Referenced by initMicrosecondTimer().

Here is the caller graph for this function:

◆ portMicrosecondTimerCallback()

void portMicrosecondTimerCallback ( )

Definition at line 98 of file microsecond_timer.cpp.

98 {
100 isTimerPending = false;
101
102 uint32_t before = getTimeNowLowerNt();
104 uint32_t precisionCallbackDuration = getTimeNowLowerNt() - before;
105 if (precisionCallbackDuration > maxPrecisionCallbackDuration) {
106 maxPrecisionCallbackDuration = precisionCallbackDuration;
107 }
108}
void globalTimerCallback()
static bool isTimerPending
uint32_t maxPrecisionCallbackDuration
static int timerCallbackCounter
uint32_t getTimeNowLowerNt()

Referenced by hwTimerCallback(), and hwTimerCallback().

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

◆ portSetHardwareSchedulerTimer()

void portSetHardwareSchedulerTimer ( efitick_t  nowNt,
efitick_t  setTimeNt 
)

Definition at line 6 of file microsecond_timer_gpt.cpp.

6 {
7 int32_t deltaTimeUs = NT2US((int32_t)setTimeNt - (int32_t)nowNt);
8
9 // If already set, reset the timer
10 if (GPTDEVICE.state == GPT_ONESHOT) {
11 gptStopTimerI(&GPTDEVICE);
12 }
13
14 if (GPTDEVICE.state != GPT_READY) {
15 firmwareError(ObdCode::CUSTOM_HW_TIMER, "HW timer state %d", GPTDEVICE.state);
16 return;
17 }
18
19 // Start the timer
20 gptStartOneShotI(&GPTDEVICE, deltaTimeUs);
21}
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_HW_TIMER

Referenced by setHardwareSchedulerTimer().

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

Go to the source code of this file.