mirror of https://github.com/rusefi/rusefi-1.git
This commit is contained in:
parent
2e013e761c
commit
5ce4fe3157
|
@ -696,6 +696,10 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
||||||
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
|
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
|
||||||
tsOutputChannels->massAirFlow = hasMafSensor() ? getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
|
tsOutputChannels->massAirFlow = hasMafSensor() ? getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
|
||||||
|
|
||||||
|
|
||||||
|
tsOutputChannels->accelerationX = engine->sensors.accelerometer.x;
|
||||||
|
tsOutputChannels->accelerationY = engine->sensors.accelerometer.y;
|
||||||
|
|
||||||
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
float mapValue = getMap();
|
float mapValue = getMap();
|
||||||
tsOutputChannels->veValue = veMap.getValue(rpm, mapValue);
|
tsOutputChannels->veValue = veMap.getValue(rpm, mapValue);
|
||||||
|
|
|
@ -279,10 +279,6 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
|
|
||||||
cylinderCleanupControl(engine);
|
cylinderCleanupControl(engine);
|
||||||
|
|
||||||
#if EFI_MEMS || defined(__DOXYGEN__)
|
|
||||||
accelerometerPeriodicCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
||||||
#endif /* EFI_MEMS */
|
|
||||||
|
|
||||||
scheduleNextSlowInvocation();
|
scheduleNextSlowInvocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,21 @@ void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
#if EFI_MEMS || defined(__DOXYGEN__)
|
#if EFI_MEMS || defined(__DOXYGEN__)
|
||||||
|
|
||||||
void accelerometerPeriodicCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
int8_t x = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTX);
|
|
||||||
int8_t y = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTY);
|
static msg_t ivThread(int param) {
|
||||||
|
(void) param;
|
||||||
|
chRegSetThreadName("Acc SPI");
|
||||||
|
while (true) {
|
||||||
|
// has to be a thread since we want to use blocking method - blocking method only available in threads, not in interrupt handler
|
||||||
|
// todo: migrate to async SPI API?
|
||||||
|
engine->sensors.accelerometer.x = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTX);
|
||||||
|
engine->sensors.accelerometer.y = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
@ -65,6 +77,8 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (engineConfiguration->LIS302DLCsPin == GPIO_UNASSIGNED)
|
if (engineConfiguration->LIS302DLCsPin == GPIO_UNASSIGNED)
|
||||||
return; // not used
|
return; // not used
|
||||||
|
|
||||||
|
if (!boardConfiguration->is_enabled_spi_1)
|
||||||
|
return; // temporary
|
||||||
// todo: driver = getSpiDevice(device);
|
// todo: driver = getSpiDevice(device);
|
||||||
|
|
||||||
turnOnSpi(device);
|
turnOnSpi(device);
|
||||||
|
@ -81,17 +95,16 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
lis302dlWriteRegister(driver, LIS302DL_CTRL_REG2, 0x00); // 4 wire mode
|
lis302dlWriteRegister(driver, LIS302DL_CTRL_REG2, 0x00); // 4 wire mode
|
||||||
lis302dlWriteRegister(driver, LIS302DL_CTRL_REG3, 0x00);
|
lis302dlWriteRegister(driver, LIS302DL_CTRL_REG3, 0x00);
|
||||||
|
|
||||||
|
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* EFI_MEMS */
|
#endif /* EFI_MEMS */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float getLongitudinalAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
float getLongitudinalAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
return 0;
|
return engine->sensors.accelerometer.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getTransverseAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
float getTransverseAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
return 0;
|
return engine->sensors.accelerometer.y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void accelerometerPeriodicCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
|
||||||
/**
|
/**
|
||||||
* Acceleration/braking
|
* Acceleration/braking
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -405,11 +405,11 @@ void initHardware(Logging *l) {
|
||||||
initSpiModules(boardConfiguration);
|
initSpiModules(boardConfiguration);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EFI_HIP_9011
|
#if EFI_HIP_9011 || defined(__DOXYGEN__)
|
||||||
initHip9011(sharedLogger);
|
initHip9011(sharedLogger);
|
||||||
#endif /* EFI_HIP_9011 */
|
#endif /* EFI_HIP_9011 */
|
||||||
|
|
||||||
#if EFI_FILE_LOGGING
|
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||||
initMmcCard();
|
initMmcCard();
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
|
|
||||||
|
@ -419,11 +419,11 @@ void initHardware(Logging *l) {
|
||||||
|
|
||||||
// initBooleanInputs();
|
// initBooleanInputs();
|
||||||
|
|
||||||
#if EFI_UART_GPS
|
#if EFI_UART_GPS || defined(__DOXYGEN__)
|
||||||
initGps();
|
initGps();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ADC_SNIFFER
|
#if ADC_SNIFFER || defined(__DOXYGEN__)
|
||||||
initAdcDriver();
|
initAdcDriver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue