auto-sync

This commit is contained in:
rusEfi 2014-09-12 22:04:25 -05:00
parent 7e4b4c6633
commit 8fb73ff94a
10 changed files with 40 additions and 10 deletions

View File

@ -29,6 +29,8 @@ void setFrankenso_01_LCD(board_configuration_s *boardConfiguration) {
static void setHondaAccordConfigurationCommon(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) {
engineConfiguration->map.sensor.sensorType = MT_DENSO183;
boardConfiguration->isFastAdcEnabled = true;
engineConfiguration->ignitionMode = IM_ONE_COIL;
engineConfiguration->injectionMode = IM_BATCH;

View File

@ -156,11 +156,11 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
// set_cranking_fuel_max 6 40
engineConfiguration->crankingSettings.coolantTempMaxC = 40; // 6ms at 40C
engineConfiguration->crankingSettings.fuelAtMaxTempMs = 6;
engineConfiguration->crankingSettings.fuelAtMaxTempMs = 24;
// set_cranking_fuel_min 6 -40
engineConfiguration->crankingSettings.coolantTempMinC = -40; // 6ms at -40C
engineConfiguration->crankingSettings.fuelAtMinTempMs = 6;
engineConfiguration->crankingSettings.fuelAtMinTempMs = 24;
engineConfiguration->analogInputDividerCoefficient = 2;
@ -229,6 +229,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
engineConfiguration->globalFuelCorrection = 1;
boardConfiguration->isFastAdcEnabled = false;
engineConfiguration->map.sensor.sensorType = MT_MPX4250;
engineConfiguration->baroSensor.sensorType = MT_CUSTOM;

View File

@ -142,7 +142,11 @@ static void fanRelayControl(void) {
Overflow64Counter halTime;
uint64_t getTimeNowUs(void) {
return halTime.get(hal_lld_get_counter_value(), false) / (CORE_CLOCK / 1000000);
return getTimeNowNt() / (CORE_CLOCK / 1000000);
}
uint64_t getTimeNowNt(void) {
return halTime.get(hal_lld_get_counter_value(), false);
}
//uint64_t getHalTimer(void) {

View File

@ -37,11 +37,16 @@ extern "C"
/**
* 64-bit counter of microseconds (1/1 000 000 of a second) since MCU reset
*
* By using 64 bit, we can achive a very precise timestamp which does not overflow.
* By using 64 bit, we can achieve a very precise timestamp which does not overflow.
* The primary implementation counts the number of CPU cycles from MCU reset.
*/
uint64_t getTimeNowUs(void);
/**
* 64-bit counter CPU cycles since MCU reset
*/
uint64_t getTimeNowNt(void);
uint64_t getHalTimer(void);
/**

View File

@ -61,7 +61,7 @@ static uint64_t getNextSwitchTimeUs(PwmConfig *state) {
#if DEBUG_PWM
scheduleMsg(&logger, "start=%d timeToSwitch=%d", state->safe.start, timeToSwitch);
#endif
return state->safe.startUs + timeToSwitchUs;
return NT2US(state->safe.startNt) + timeToSwitchUs;
}
void PwmConfig::handleCycleStart() {
@ -74,7 +74,7 @@ void PwmConfig::handleCycleStart() {
/**
* period length has changed - we need to reset internal state
*/
safe.startUs = getTimeNowUs();
safe.startNt = getTimeNowNt();
safe.iteration = 0;
safe.periodUs = periodUs;
#if DEBUG_PWM

View File

@ -26,7 +26,7 @@ typedef struct {
/**
* Start time of current iteration
*/
uint64_t startUs;
uint64_t startNt;
int phaseIndex;
} pwm_config_safe_state_s;

View File

@ -45,7 +45,7 @@
</option>
<option>
<name>MemFile</name>
<state></state>
<state>$TOOLKIT_DIR$\CONFIG\debugger\ST\STM32F407VG.ddf</state>
</option>
<option>
<name>RunToEnable</name>
@ -117,7 +117,7 @@
</option>
<option>
<name>FlashLoadersV3</name>
<state>$TOOLKIT_DIR$\config\flashloader\</state>
<state>$TOOLKIT_DIR$\config\flashloader\ST\FlashSTM32F4xxx.board</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
@ -1145,7 +1145,7 @@
</option>
<option>
<name>CCCpuClockEdit</name>
<state>72.0</state>
<state>168</state>
</option>
<option>
<name>CCSwoClockAuto</name>

View File

@ -40,6 +40,14 @@ extern "C"
// todo: access some existing configuration field
#define CORE_CLOCK 168000000
// 168 ticks in microsecond
#define US_TO_NT_MULTIPLIER 168
#define US2NT(x) ((x)*US_TO_NT_MULTIPLIER)
#define NT2US(x) ((x) / US_TO_NT_MULTIPLIER)
/**
* number of SysClock ticks in one ms
*/

View File

@ -15,6 +15,12 @@
#include "datalogging.h"
#include "efitime.h"
#define US_TO_NT_MULTIPLIER 100
#define US2NT(x) (US_TO_NT_MULTIPLIER * (x))
#define NT2US(x) ((x) / US_TO_NT_MULTIPLIER)
#ifndef GLOBAL_FT_H_
#define GLOBAL_FT_H_

View File

@ -197,6 +197,10 @@ void chDbgPanic3(const char *msg, const char * file, int line) {
onFatalError(msg, file, line);
}
uint64_t getTimeNowNt(void) {
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
}
uint64_t getTimeNowUs(void) {
return chTimeNow() * (1000000 / CH_FREQUENCY);
}