better variable name & docs

This commit is contained in:
rusefi 2020-01-19 00:16:19 -05:00
parent fa5b5b76fb
commit b377e1f2f0
2 changed files with 13 additions and 14 deletions

View File

@ -67,23 +67,24 @@ extern bool hasFirmwareErrorFlag;
* 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 timeUs) {
void setHardwareUsTimer(int32_t deltaTimeUs) {
enginePins.debugSetTimer.setValue(1);
efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started");
setHwTimerCounter++;
/**
* #259 BUG error: not positive timeUs
* #259 BUG error: not positive deltaTimeUs
* Once in a while we night get an interrupt where we do not expect it
*/
if (timeUs <= 0) {
if (deltaTimeUs <= 0) {
timerFreezeCounter++;
warning(CUSTOM_OBD_LOCAL_FREEZE, "local freeze cnt=%d", timerFreezeCounter);
}
if (timeUs < 2)
timeUs = 2; // for some reason '1' does not really work
efiAssertVoid(CUSTOM_ERR_6681, timeUs > 0, "not positive timeUs");
if (timeUs >= 10 * US_PER_SECOND) {
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too long: %d", timeUs);
if (deltaTimeUs < 2)
deltaTimeUs = 2; // for some reason '1' does not really work
efiAssertVoid(CUSTOM_ERR_6681, deltaTimeUs > 0, "not positive deltaTimeUs");
if (deltaTimeUs >= 10 * US_PER_SECOND) {
// 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 long: %d", deltaTimeUs);
// let's make this look special and NOT toggle enginePins.debugSetTimer
return;
}
@ -100,10 +101,10 @@ void setHardwareUsTimer(int32_t timeUs) {
// let's make this look special and NOT toggle enginePins.debugSetTimer
return;
}
gptStartOneShotI(&GPTDEVICE, timeUs);
gptStartOneShotI(&GPTDEVICE, deltaTimeUs);
lastSetTimerTimeNt = getTimeNowNt();
lastSetTimerValue = timeUs;
lastSetTimerValue = deltaTimeUs;
isTimerPending = TRUE;
timerRestartCounter++;
enginePins.debugSetTimer.setValue(0);

View File

@ -5,8 +5,7 @@
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#ifndef SIGNAL_TEMP_H_
#define SIGNAL_TEMP_H_
#pragma once
#ifdef __cplusplus
extern "C"
@ -14,10 +13,9 @@ extern "C"
#endif /* __cplusplus */
void initMicrosecondTimer(void);
void setHardwareUsTimer(int32_t timeUs);
void setHardwareUsTimer(int32_t deltaTimeUs);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SIGNAL_TEMP_H_ */