This commit is contained in:
rusefi 2020-04-25 12:08:16 -04:00
commit aee48c9953
8 changed files with 17 additions and 44 deletions

View File

@ -571,8 +571,6 @@ static void initStatusLeds(void) {
enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin); enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin);
enginePins.debugTriggerSync.initPin("debug: sync", CONFIG(debugTriggerSync)); enginePins.debugTriggerSync.initPin("debug: sync", CONFIG(debugTriggerSync));
enginePins.debugTimerCallback.initPin("debug: timer callback", CONFIG(debugTimerCallback));
enginePins.debugSetTimer.initPin("debug: set timer", CONFIG(debugSetTimer));
} }
#define BLINKING_PERIOD_MS 33 #define BLINKING_PERIOD_MS 33

View File

@ -1872,7 +1872,7 @@ typedef enum {
CUSTOM_ERR_UNEXPECTED_SPI = 6524, CUSTOM_ERR_UNEXPECTED_SPI = 6524,
CUSTOM_ERR_EXT_MODE = 6525, CUSTOM_ERR_EXT_MODE = 6525,
CUSTOM_ERR_TIMER_OVERFLOW = 6526, CUSTOM_ERR_TIMER_OVERFLOW = 6526,
CUSTOM_ERR_NULL_TIMER_CALLBACK = 6527, CUSTOM_ERR_6527 = 6527,
CUSTOM_ERR_SCHEDULING_ERROR = 6528, CUSTOM_ERR_SCHEDULING_ERROR = 6528,
CUSTOM_ERR_LOGGING_NOT_READY = 6529, CUSTOM_ERR_LOGGING_NOT_READY = 6529,
ERROR_NAN_FIND_INDEX = 6530, ERROR_NAN_FIND_INDEX = 6530,

View File

@ -145,8 +145,6 @@ public:
OutputPin runningLedPin; // green LED on brain board by default OutputPin runningLedPin; // green LED on brain board by default
OutputPin debugTriggerSync; OutputPin debugTriggerSync;
OutputPin debugTimerCallback;
OutputPin debugSetTimer;
OutputPin boostPin; OutputPin boostPin;
OutputPin idleSolenoidPin; OutputPin idleSolenoidPin;
OutputPin secondIdleSolenoidPin; OutputPin secondIdleSolenoidPin;

View File

@ -35,8 +35,6 @@
#include "engine.h" #include "engine.h"
EXTERN_ENGINE; EXTERN_ENGINE;
extern schfunc_t globalTimerCallback;
/** /**
* these fields are global in order to facilitate debugging * these fields are global in order to facilitate debugging
*/ */
@ -45,15 +43,9 @@ static efitime_t nextEventTimeNt = 0;
uint32_t hwSetTimerDuration; uint32_t hwSetTimerDuration;
uint32_t lastExecutionCount; uint32_t lastExecutionCount;
static void executorCallback(void *arg) { void globalTimerCallback() {
(void)arg;
efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y"); efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
// callbackTime = getTimeNowNt();
// if ((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) {
// timerIsLate++;
// }
___engine.executor.onTimerCallback(); ___engine.executor.onTimerCallback();
} }
@ -180,7 +172,6 @@ void SingleTimerExecutor::scheduleTimerCallback() {
} }
void initSingleTimerExecutorHardware(void) { void initSingleTimerExecutorHardware(void) {
globalTimerCallback = executorCallback;
initMicrosecondTimer(); initMicrosecondTimer();
} }

View File

@ -46,13 +46,11 @@ uint32_t maxPrecisionCallbackDuration = 0;
static volatile efitick_t lastSetTimerTimeNt; static volatile efitick_t lastSetTimerTimeNt;
static int lastSetTimerValue; static int lastSetTimerValue;
static volatile bool isTimerPending = FALSE; static volatile bool isTimerPending = false;
static volatile int timerCallbackCounter = 0; static volatile int timerCallbackCounter = 0;
static volatile int timerRestartCounter = 0; static volatile int timerRestartCounter = 0;
schfunc_t globalTimerCallback;
static const char * msg; static const char * msg;
static char buff[32]; static char buff[32];
@ -66,7 +64,6 @@ static volatile bool hwStarted = false;
* 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 setHardwareUsTimer(int32_t deltaTimeUs) {
enginePins.debugSetTimer.setValue(1);
efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started"); efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started");
setHwTimerCounter++; setHwTimerCounter++;
/** /**
@ -83,7 +80,6 @@ void setHardwareUsTimer(int32_t 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, "setHardwareUsTimer() too far: %d", deltaTimeUs);
// let's make this look special and NOT toggle enginePins.debugSetTimer
return; return;
} }
@ -92,39 +88,32 @@ void setHardwareUsTimer(int32_t deltaTimeUs) {
} }
if (GPTDEVICE.state != GPT_READY) { if (GPTDEVICE.state != GPT_READY) {
firmwareError(CUSTOM_HW_TIMER, "HW timer state %d/%d", GPTDEVICE.state, setHwTimerCounter); firmwareError(CUSTOM_HW_TIMER, "HW timer state %d/%d", GPTDEVICE.state, setHwTimerCounter);
// let's make this look special and NOT toggle enginePins.debugSetTimer
return; return;
} }
if (hasFirmwareError()) { if (hasFirmwareError()) {
// let's make this look special and NOT toggle enginePins.debugSetTimer
return; return;
} }
gptStartOneShotI(&GPTDEVICE, deltaTimeUs); gptStartOneShotI(&GPTDEVICE, deltaTimeUs);
lastSetTimerTimeNt = getTimeNowNt(); lastSetTimerTimeNt = getTimeNowNt();
lastSetTimerValue = deltaTimeUs; lastSetTimerValue = deltaTimeUs;
isTimerPending = TRUE; isTimerPending = true;
timerRestartCounter++; timerRestartCounter++;
enginePins.debugSetTimer.setValue(0);
} }
void globalTimerCallback();
static void hwTimerCallback(GPTDriver *gptp) { static void hwTimerCallback(GPTDriver *gptp) {
(void)gptp; (void)gptp;
enginePins.debugTimerCallback.setValue(1);
timerCallbackCounter++; timerCallbackCounter++;
if (globalTimerCallback == NULL) {
firmwareError(CUSTOM_ERR_NULL_TIMER_CALLBACK, "NULL globalTimerCallback");
return;
}
isTimerPending = false; isTimerPending = false;
uint32_t before = getTimeNowLowerNt(); uint32_t before = getTimeNowLowerNt();
globalTimerCallback(NULL); globalTimerCallback();
uint32_t precisionCallbackDuration = getTimeNowLowerNt() - before; uint32_t precisionCallbackDuration = getTimeNowLowerNt() - before;
if (precisionCallbackDuration > maxPrecisionCallbackDuration) { if (precisionCallbackDuration > maxPrecisionCallbackDuration) {
maxPrecisionCallbackDuration = precisionCallbackDuration; maxPrecisionCallbackDuration = precisionCallbackDuration;
} }
enginePins.debugTimerCallback.setValue(0);
} }
class MicrosecondTimerWatchdogController : public PeriodicTimerController { class MicrosecondTimerWatchdogController : public PeriodicTimerController {
@ -203,7 +192,6 @@ static void validateHardwareTimer() {
} }
void initMicrosecondTimer(void) { void initMicrosecondTimer(void) {
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;

View File

@ -643,7 +643,7 @@ custom adc_channel_mode_e 4 bits, U32, @OFFSET@, [0:7], "Off", "Slow", "Fas
brain_pin_e canRxPin;set_can_rx_pin X brain_pin_e canRxPin;set_can_rx_pin X
pin_input_mode_e throttlePedalUpPinMode; pin_input_mode_e throttlePedalUpPinMode;
brain_pin_e debugTimerCallback uint8_t unused711;
int idleThreadPeriodMs; int idleThreadPeriodMs;
int consoleLoopPeriodMs; int consoleLoopPeriodMs;
@ -717,7 +717,7 @@ pin_output_mode_e hip9011IntHoldPinMode;
custom uart_device_e 1 bits,U32, @OFFSET@, [0:7], "Off", "UART1", "UART2", "UART3" custom uart_device_e 1 bits,U32, @OFFSET@, [0:7], "Off", "UART1", "UART2", "UART3"
int16_t sdCardPeriodMs;+SD card logging period, in milliseconds;"ms", 1, 0, 0, 30000, 0 int16_t sdCardPeriodMs;+SD card logging period, in milliseconds;"ms", 1, 0, 0, 30000, 0
brain_pin_e debugSetTimer uint8_t unused806
brain_pin_e debugMapAveraging; brain_pin_e debugMapAveraging;
output_pin_e starterRelayDisablePin; output_pin_e starterRelayDisablePin;
pin_output_mode_e starterRelayDisableMode;On some vehicles we can disable starter once engine is already running pin_output_mode_e starterRelayDisableMode;On some vehicles we can disable starter once engine is already running

View File

@ -1918,8 +1918,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "LCD D6 pin", HD44780_db6 field = "LCD D6 pin", HD44780_db6
field = "LCD D7 pin", HD44780_db7 field = "LCD D7 pin", HD44780_db7
field = "Debug Trigger Sync", debugTriggerSync field = "Debug Trigger Sync", debugTriggerSync
field = "Debug Timer Callback", debugTimerCallback
field = "Debug Set Timer", debugSetTimer
field = "Aux Fast Analog", auxFastSensor1_adcChannel field = "Aux Fast Analog", auxFastSensor1_adcChannel
dialog = allPins1_3 dialog = allPins1_3

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated; package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Thu Apr 23 23:48:34 EDT 2020 // this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Fri Apr 24 23:22:49 EDT 2020
// by class com.rusefi.output.FileJavaFieldsConsumer // by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*; import com.rusefi.config.*;
@ -336,9 +336,6 @@ public class Fields {
public static final int debugMapAveraging_offset = 807; public static final int debugMapAveraging_offset = 807;
public static final int debugMapAveraging_offset_hex = 327; public static final int debugMapAveraging_offset_hex = 327;
public static final int debugMode_offset = 2092; public static final int debugMode_offset = 2092;
public static final int debugSetTimer_offset = 806;
public static final int debugSetTimer_offset_hex = 326;
public static final int debugTimerCallback_offset = 711;
public static final int debugTriggerSync_offset = 676; public static final int debugTriggerSync_offset = 676;
public static final int DIGIPOT_COUNT = 4; public static final int DIGIPOT_COUNT = 4;
public static final int digitalPotentiometerChipSelect1_offset = 668; public static final int digitalPotentiometerChipSelect1_offset = 668;
@ -1440,7 +1437,10 @@ public class Fields {
public static final int unused1059_offset = 3964; public static final int unused1059_offset = 3964;
public static final int unused2432_offset = 2432; public static final int unused2432_offset = 2432;
public static final int unused2432_offset_hex = 980; public static final int unused2432_offset_hex = 980;
public static final int unused711_offset = 711;
public static final int unused76b0_offset = 76; public static final int unused76b0_offset = 76;
public static final int unused806_offset = 806;
public static final int unused806_offset_hex = 326;
public static final int unused_1484_bit_24_offset = 1476; public static final int unused_1484_bit_24_offset = 1476;
public static final int unused_1484_bit_25_offset = 1476; public static final int unused_1484_bit_25_offset = 1476;
public static final int unused_1484_bit_26_offset = 1476; public static final int unused_1484_bit_26_offset = 1476;
@ -1811,7 +1811,7 @@ public class Fields {
public static final Field CANTXPIN = Field.create("CANTXPIN", 708, FieldType.INT8, brain_pin_e); public static final Field CANTXPIN = Field.create("CANTXPIN", 708, FieldType.INT8, brain_pin_e);
public static final Field CANRXPIN = Field.create("CANRXPIN", 709, FieldType.INT8, brain_pin_e); public static final Field CANRXPIN = Field.create("CANRXPIN", 709, FieldType.INT8, brain_pin_e);
public static final Field THROTTLEPEDALUPPINMODE = Field.create("THROTTLEPEDALUPPINMODE", 710, FieldType.INT8); public static final Field THROTTLEPEDALUPPINMODE = Field.create("THROTTLEPEDALUPPINMODE", 710, FieldType.INT8);
public static final Field DEBUGTIMERCALLBACK = Field.create("DEBUGTIMERCALLBACK", 711, FieldType.INT8, brain_pin_e); public static final Field UNUSED711 = Field.create("UNUSED711", 711, FieldType.INT8);
public static final Field IDLETHREADPERIODMS = Field.create("IDLETHREADPERIODMS", 712, FieldType.INT); public static final Field IDLETHREADPERIODMS = Field.create("IDLETHREADPERIODMS", 712, FieldType.INT);
public static final Field CONSOLELOOPPERIODMS = Field.create("CONSOLELOOPPERIODMS", 716, FieldType.INT); public static final Field CONSOLELOOPPERIODMS = Field.create("CONSOLELOOPPERIODMS", 716, FieldType.INT);
public static final Field LCDTHREADPERIODMS = Field.create("LCDTHREADPERIODMS", 720, FieldType.INT); public static final Field LCDTHREADPERIODMS = Field.create("LCDTHREADPERIODMS", 720, FieldType.INT);
@ -1909,7 +1909,7 @@ public class Fields {
public static final Field MAX31855_CS7 = Field.create("MAX31855_CS7", 802, FieldType.INT8, brain_pin_e); public static final Field MAX31855_CS7 = Field.create("MAX31855_CS7", 802, FieldType.INT8, brain_pin_e);
public static final Field MAX31855_CS8 = Field.create("MAX31855_CS8", 803, FieldType.INT8, brain_pin_e); public static final Field MAX31855_CS8 = Field.create("MAX31855_CS8", 803, FieldType.INT8, brain_pin_e);
public static final Field SDCARDPERIODMS = Field.create("SDCARDPERIODMS", 804, FieldType.INT16); public static final Field SDCARDPERIODMS = Field.create("SDCARDPERIODMS", 804, FieldType.INT16);
public static final Field DEBUGSETTIMER = Field.create("DEBUGSETTIMER", 806, FieldType.INT8, brain_pin_e); public static final Field UNUSED806 = Field.create("UNUSED806", 806, FieldType.INT8);
public static final Field DEBUGMAPAVERAGING = Field.create("DEBUGMAPAVERAGING", 807, FieldType.INT8, brain_pin_e); public static final Field DEBUGMAPAVERAGING = Field.create("DEBUGMAPAVERAGING", 807, FieldType.INT8, brain_pin_e);
public static final Field STARTERRELAYDISABLEPIN = Field.create("STARTERRELAYDISABLEPIN", 808, FieldType.INT8, output_pin_e); public static final Field STARTERRELAYDISABLEPIN = Field.create("STARTERRELAYDISABLEPIN", 808, FieldType.INT8, output_pin_e);
public static final Field STARTERRELAYDISABLEMODE = Field.create("STARTERRELAYDISABLEMODE", 809, FieldType.INT8, pin_output_mode_e); public static final Field STARTERRELAYDISABLEMODE = Field.create("STARTERRELAYDISABLEMODE", 809, FieldType.INT8, pin_output_mode_e);
@ -2739,7 +2739,7 @@ public class Fields {
CANTXPIN, CANTXPIN,
CANRXPIN, CANRXPIN,
THROTTLEPEDALUPPINMODE, THROTTLEPEDALUPPINMODE,
DEBUGTIMERCALLBACK, UNUSED711,
IDLETHREADPERIODMS, IDLETHREADPERIODMS,
CONSOLELOOPPERIODMS, CONSOLELOOPPERIODMS,
LCDTHREADPERIODMS, LCDTHREADPERIODMS,
@ -2837,7 +2837,7 @@ public class Fields {
MAX31855_CS7, MAX31855_CS7,
MAX31855_CS8, MAX31855_CS8,
SDCARDPERIODMS, SDCARDPERIODMS,
DEBUGSETTIMER, UNUSED806,
DEBUGMAPAVERAGING, DEBUGMAPAVERAGING,
STARTERRELAYDISABLEPIN, STARTERRELAYDISABLEPIN,
STARTERRELAYDISABLEMODE, STARTERRELAYDISABLEMODE,