adjust microsecond_timer api (#1952)
* change timer api * don't need all that
This commit is contained in:
parent
fcc75992f1
commit
6e4517be8c
|
@ -154,9 +154,7 @@ void SingleTimerExecutor::scheduleTimerCallback() {
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_ERR_6625, nextEventTimeNt.Value > nowNt, "setTimer constraint");
|
efiAssertVoid(CUSTOM_ERR_6625, nextEventTimeNt.Value > nowNt, "setTimer constraint");
|
||||||
|
|
||||||
int32_t hwAlarmTime = NT2US((int32_t)nextEventTimeNt.Value - (int32_t)nowNt);
|
setHardwareSchedulerTimer(nowNt, nextEventTimeNt.Value);
|
||||||
|
|
||||||
setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSingleTimerExecutorHardware(void) {
|
void initSingleTimerExecutorHardware(void) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ HW_LAYER_EMS = $(HW_LAYER_EGT) \
|
||||||
|
|
||||||
HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_CPP) \
|
HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_CPP) \
|
||||||
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
|
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/microsecond_timer.cpp \
|
$(PROJECT_DIR)/hw_layer/microsecond_timer_gpt.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/digital_input/digital_input.cpp \
|
$(PROJECT_DIR)/hw_layer/digital_input/digital_input.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_icu.cpp \
|
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_icu.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_exti.cpp \
|
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_exti.cpp \
|
||||||
|
|
|
@ -7,18 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
void initMicrosecondTimer();
|
||||||
extern "C"
|
void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt);
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
void initMicrosecondTimer(void);
|
|
||||||
void setHardwareUsTimer(int32_t deltaTimeUs);
|
|
||||||
|
|
||||||
#define TOO_FAR_INTO_FUTURE_US (10 * US_PER_SECOND)
|
#define TOO_FAR_INTO_FUTURE_US (10 * US_PER_SECOND)
|
||||||
#define TOO_FAR_INTO_FUTURE_NT US2NT(TOO_FAR_INTO_FUTURE_US)
|
#define TOO_FAR_INTO_FUTURE_NT US2NT(TOO_FAR_INTO_FUTURE_US)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,11 @@ static volatile bool hwStarted = false;
|
||||||
* sets the alarm to the specified number of microseconds from now.
|
* sets the alarm to the specified number of microseconds from now.
|
||||||
* This function should be invoked under kernel lock which would disable interrupts.
|
* This function should be invoked under kernel lock which would disable interrupts.
|
||||||
*/
|
*/
|
||||||
void setHardwareUsTimer(int32_t deltaTimeUs) {
|
void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started");
|
efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started");
|
||||||
|
|
||||||
|
int32_t deltaTimeUs = NT2US((int32_t)setTimeNt - (int32_t)nowNt);
|
||||||
|
|
||||||
setHwTimerCounter++;
|
setHwTimerCounter++;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,10 +84,9 @@ void setHardwareUsTimer(int32_t deltaTimeUs) {
|
||||||
deltaTimeUs = 2;
|
deltaTimeUs = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_DELTA_NOT_POSITIVE, deltaTimeUs > 0, "not positive deltaTimeUs");
|
|
||||||
if (deltaTimeUs >= TOO_FAR_INTO_FUTURE_US) {
|
if (deltaTimeUs >= TOO_FAR_INTO_FUTURE_US) {
|
||||||
// we are trying to set callback for too far into the future. This does not look right at all
|
// we are trying to set callback for too far into the future. This does not look right at all
|
||||||
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too far: %d", deltaTimeUs);
|
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareSchedulerTimer() too far: %d", deltaTimeUs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ static void validateHardwareTimer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMicrosecondTimer(void) {
|
void initMicrosecondTimer() {
|
||||||
gptStart(&GPTDEVICE, &gpt5cfg);
|
gptStart(&GPTDEVICE, &gpt5cfg);
|
||||||
efiAssertVoid(CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
|
efiAssertVoid(CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
|
||||||
hwStarted = true;
|
hwStarted = true;
|
Loading…
Reference in New Issue