This commit is contained in:
parent
4c22537ec1
commit
58cc02228f
|
@ -696,6 +696,10 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf(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)) {
|
||||
float mapValue = getMap();
|
||||
tsOutputChannels->veValue = veMap.getValue(rpm, mapValue);
|
||||
|
|
|
@ -279,10 +279,6 @@ static void periodicSlowCallback(Engine *engine) {
|
|||
|
||||
cylinderCleanupControl(engine);
|
||||
|
||||
#if EFI_MEMS || defined(__DOXYGEN__)
|
||||
accelerometerPeriodicCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
#endif /* EFI_MEMS */
|
||||
|
||||
scheduleNextSlowInvocation();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,21 @@ void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
#if EFI_MEMS || defined(__DOXYGEN__)
|
||||
|
||||
void accelerometerPeriodicCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
int8_t x = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTX);
|
||||
int8_t y = (int8_t)lis302dlReadRegister(driver, LIS302DL_OUTY);
|
||||
static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||
|
||||
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) {
|
||||
|
@ -65,6 +77,8 @@ void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
if (engineConfiguration->LIS302DLCsPin == GPIO_UNASSIGNED)
|
||||
return; // not used
|
||||
|
||||
if (!boardConfiguration->is_enabled_spi_1)
|
||||
return; // temporary
|
||||
// todo: driver = getSpiDevice(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_REG3, 0x00);
|
||||
|
||||
|
||||
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
|
||||
}
|
||||
|
||||
#endif /* EFI_MEMS */
|
||||
|
||||
|
||||
|
||||
float getLongitudinalAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
return 0;
|
||||
return engine->sensors.accelerometer.x;
|
||||
}
|
||||
|
||||
float getTransverseAcceleration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
return 0;
|
||||
return engine->sensors.accelerometer.y;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
void configureAccelerometerPins(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
void initAccelerometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void accelerometerPeriodicCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
/**
|
||||
* Acceleration/braking
|
||||
*/
|
||||
|
|
|
@ -405,11 +405,11 @@ void initHardware(Logging *l) {
|
|||
initSpiModules(boardConfiguration);
|
||||
#endif
|
||||
|
||||
#if EFI_HIP_9011
|
||||
#if EFI_HIP_9011 || defined(__DOXYGEN__)
|
||||
initHip9011(sharedLogger);
|
||||
#endif /* EFI_HIP_9011 */
|
||||
|
||||
#if EFI_FILE_LOGGING
|
||||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||
initMmcCard();
|
||||
#endif /* EFI_FILE_LOGGING */
|
||||
|
||||
|
@ -419,11 +419,11 @@ void initHardware(Logging *l) {
|
|||
|
||||
// initBooleanInputs();
|
||||
|
||||
#if EFI_UART_GPS
|
||||
#if EFI_UART_GPS || defined(__DOXYGEN__)
|
||||
initGps();
|
||||
#endif
|
||||
|
||||
#if ADC_SNIFFER
|
||||
#if ADC_SNIFFER || defined(__DOXYGEN__)
|
||||
initAdcDriver();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue