auto-sync
This commit is contained in:
parent
a46e46474e
commit
7dc8a7c312
|
@ -32,6 +32,8 @@ static void commonMiataNa(engine_configuration_s *engineConfiguration, board_con
|
|||
|
||||
engineConfiguration->ignitionMode = IM_WASTED_SPARK;
|
||||
|
||||
engineConfiguration->globalTriggerAngleOffset = 114;
|
||||
|
||||
// Frankenstein: high side #1 is PE8
|
||||
// Frankenstein: high side #2 is PE10
|
||||
// Frankenstein: high side #3 is PE12
|
||||
|
|
|
@ -185,8 +185,7 @@ void printConfiguration(engine_configuration_s *engineConfiguration, engine_conf
|
|||
}
|
||||
|
||||
scheduleMsg(&logger, "ignitionPins: mode %s", pinModeToString(boardConfiguration->ignitionPinMode));
|
||||
// todo: calculate coils count based on ignition mode
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
brain_pin_e brainPin = boardConfiguration->ignitionPins[i];
|
||||
scheduleMsg(&logger, "ignition %d @ %s", i, hwPortname(brainPin));
|
||||
}
|
||||
|
|
|
@ -131,9 +131,9 @@ static void initWave(const char *name, int index) {
|
|||
|
||||
reader->name = name;
|
||||
|
||||
registerCallback(&hw->widthListeners, (IntListener) waAnaWidthCallback, (void*)reader);
|
||||
registerCallback(&hw->widthListeners, (IntListener) waAnaWidthCallback, (void*) reader);
|
||||
|
||||
registerCallback(&hw->periodListeners, (IntListener) waIcuPeriodCallback, (void*)reader);
|
||||
registerCallback(&hw->periodListeners, (IntListener) waIcuPeriodCallback, (void*) reader);
|
||||
|
||||
initWaveAnalyzerDriver(hw, driver, port, pin);
|
||||
|
||||
|
@ -151,9 +151,9 @@ static void initWave(const char *name, int index) {
|
|||
//}
|
||||
|
||||
static void onWaveShaftSignal(trigger_event_e ckpSignalType, int index, void *arg) {
|
||||
if (index != 0) {
|
||||
if (index != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
uint64_t nowUs = getTimeNowUs();
|
||||
ckpPeriodUs = nowUs - previousCrankSignalStart;
|
||||
previousCrankSignalStart = nowUs;
|
||||
|
@ -183,12 +183,12 @@ uint32_t getWaveLowWidth(int index) {
|
|||
return reader->last_wave_low_widthUs;
|
||||
}
|
||||
|
||||
float getWaveHighWidthMs(int index) {
|
||||
static float getWaveHighWidthMs(int index) {
|
||||
WaveReader *reader = &readers[index];
|
||||
ensureInitialized(reader);
|
||||
if (getTimeNowUs() - reader->lastActivityTimeUs > 4 * US_PER_SECOND) {
|
||||
return 0.0f; // dwell time has expired
|
||||
}
|
||||
}
|
||||
return reader->last_wave_high_widthUs / 1000.0f;
|
||||
}
|
||||
|
||||
|
@ -210,14 +210,6 @@ uint64_t getWidthEventTime(int index) {
|
|||
return reader->widthEventTimeUs;
|
||||
}
|
||||
|
||||
uint64_t getPeriodEventTime(int index) {
|
||||
WaveReader *reader = &readers[index];
|
||||
ensureInitialized(reader);
|
||||
return reader->periodEventTimeUs;
|
||||
}
|
||||
|
||||
int waveBufferReported = 0;
|
||||
|
||||
static void reportWave(Logging *logging, int index) {
|
||||
// int counter = getEventCounter(index);
|
||||
// debugInt2(logging, "ev", index, counter);
|
||||
|
@ -257,11 +249,11 @@ void initWaveAnalyzer(void) {
|
|||
initWave(WA_CHANNEL_1, 0);
|
||||
initWave(WA_CHANNEL_2, 1);
|
||||
|
||||
addTriggerEventListener(&onWaveShaftSignal, "wave analyzer", (void*)NULL);
|
||||
addTriggerEventListener(&onWaveShaftSignal, "wave analyzer", (void*) NULL);
|
||||
|
||||
addConsoleActionII("set_logic_input_mode", setWaveModeSilent);
|
||||
|
||||
chThdCreateStatic(waThreadStack, sizeof(waThreadStack), NORMALPRIO, waThread, (void*)NULL);
|
||||
chThdCreateStatic(waThreadStack, sizeof(waThreadStack), NORMALPRIO, waThread, (void*) NULL);
|
||||
|
||||
#else
|
||||
print("wave disabled\r\n");
|
||||
|
|
|
@ -26,7 +26,10 @@ typedef struct {
|
|||
volatile int eventCounter;
|
||||
|
||||
volatile uint64_t lastActivityTimeUs; // timestamp in microseconds ticks
|
||||
volatile uint64_t periodEventTimeUs; // time of signal fall in microseconds
|
||||
/**
|
||||
* time of signal fall event, in microseconds
|
||||
*/
|
||||
volatile uint64_t periodEventTimeUs;
|
||||
volatile uint64_t widthEventTimeUs; // time of signal rise in microseconds
|
||||
|
||||
volatile uint32_t signalPeriodUs; // period between two signal rises in microseconds
|
||||
|
@ -45,7 +48,6 @@ void initWaveAnalyzer(void);
|
|||
void pokeWaveInfo(void);
|
||||
void reportWaveInfo(void);
|
||||
uint32_t getWaveLowWidth(int index);
|
||||
float getWaveHighWidthMs(int index);
|
||||
uint64_t getWaveOffset(int index);
|
||||
|
||||
int getWaveMode(int index);
|
||||
|
|
Loading…
Reference in New Issue