adjust microsecond_timer api (#1952)

* change timer api

* don't need all that
This commit is contained in:
Matthew Kennedy 2020-11-16 15:50:13 -08:00 committed by GitHub
parent fcc75992f1
commit 6e4517be8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 20 deletions

View File

@ -154,9 +154,7 @@ void SingleTimerExecutor::scheduleTimerCallback() {
efiAssertVoid(CUSTOM_ERR_6625, nextEventTimeNt.Value > nowNt, "setTimer constraint");
int32_t hwAlarmTime = NT2US((int32_t)nextEventTimeNt.Value - (int32_t)nowNt);
setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime);
setHardwareSchedulerTimer(nowNt, nextEventTimeNt.Value);
}
void initSingleTimerExecutorHardware(void) {

View File

@ -15,7 +15,7 @@ HW_LAYER_EMS = $(HW_LAYER_EGT) \
HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_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_icu.cpp \
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_exti.cpp \

View File

@ -7,18 +7,8 @@
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void initMicrosecondTimer(void);
void setHardwareUsTimer(int32_t deltaTimeUs);
void initMicrosecondTimer();
void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt);
#define TOO_FAR_INTO_FUTURE_US (10 * US_PER_SECOND)
#define TOO_FAR_INTO_FUTURE_NT US2NT(TOO_FAR_INTO_FUTURE_US)
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -63,9 +63,11 @@ static volatile bool hwStarted = false;
* sets the alarm to the specified number of microseconds from now.
* 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");
int32_t deltaTimeUs = NT2US((int32_t)setTimeNt - (int32_t)nowNt);
setHwTimerCounter++;
/**
@ -82,10 +84,9 @@ void setHardwareUsTimer(int32_t deltaTimeUs) {
deltaTimeUs = 2;
}
efiAssertVoid(CUSTOM_DELTA_NOT_POSITIVE, deltaTimeUs > 0, "not positive deltaTimeUs");
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
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too far: %d", deltaTimeUs);
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareSchedulerTimer() too far: %d", deltaTimeUs);
return;
}
@ -198,7 +199,7 @@ static void validateHardwareTimer() {
}
}
void initMicrosecondTimer(void) {
void initMicrosecondTimer() {
gptStart(&GPTDEVICE, &gpt5cfg);
efiAssertVoid(CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
hwStarted = true;