rusEFI
The most advanced open source ECU
Functions | Variables
microsecond_timer_gpt.cpp File Reference

Functions

void portSetHardwareSchedulerTimer (efitick_t nowNt, efitick_t setTimeNt)
 
static void hwTimerCallback (GPTDriver *)
 
void portInitMicrosecondTimer ()
 
uint32_t getTimeNowLowerNt ()
 

Variables

static constexpr GPTConfig gpt5cfg
 

Function Documentation

◆ getTimeNowLowerNt()

uint32_t getTimeNowLowerNt ( )

Get a monotonically increasing (but wrapping) 32-bit timer value Implemented at port level, based on timer or CPU tick counter Main source of EFI clock, SW-extended to 64bits

2147483648 / ~168MHz = ~12 seconds to overflow

Definition at line 43 of file microsecond_timer_gpt.cpp.

43  {
44  return port_rt_get_counter_value();
45 }

Referenced by getTimeNowNt(), handleShaftSignal(), onLockHook(), onUnlockHook(), portMicrosecondTimerCallback(), and testBinary().

Here is the caller graph for this function:

◆ hwTimerCallback()

static void hwTimerCallback ( GPTDriver )
static

Definition at line 23 of file microsecond_timer_gpt.cpp.

23  {
25 }
void portMicrosecondTimerCallback()
Here is the call graph for this function:

◆ 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:

◆ 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:

Variable Documentation

◆ gpt5cfg

constexpr GPTConfig gpt5cfg
staticconstexpr
Initial value:
= { 1000000,
0, 0 }
static void hwTimerCallback(GPTDriver *)

Definition at line 31 of file microsecond_timer_gpt.cpp.

Referenced by portInitMicrosecondTimer().

Go to the source code of this file.