DAC with Lua #5601
This commit is contained in:
parent
0353500421
commit
1f0e55e98a
|
@ -25,7 +25,9 @@ DDEFS += -DEFI_KLINE=TRUE
|
|||
DDEFS += -DKLINE_SERIAL_DEVICE_RX=Gpio::C11 -DKLINE_SERIAL_DEVICE_TX=Gpio::C10
|
||||
DDEFS += -DKLINE_SERIAL_DEVICE=SD3
|
||||
|
||||
DDEFS += -DEFI_DAC=TRUE -DHAL_USE_DAC=TRUE -DSTM32_DAC_USE_DAC1_CH1=TRUE
|
||||
# DAC channel1 PA4
|
||||
# DAC channel2 PA5
|
||||
DDEFS += -DEFI_DAC=TRUE -DHAL_USE_DAC=TRUE -DSTM32_DAC_USE_DAC1_CH1=TRUE -DSTM32_DAC_USE_DAC1_CH2=TRUE
|
||||
|
||||
DDEFS += -DBOARD_TLE9104_COUNT=2
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
#include "value_lookup.h"
|
||||
#include "can_filter.h"
|
||||
#include "tunerstudio.h"
|
||||
|
||||
#if EFI_DAC
|
||||
#include "dac.h"
|
||||
#endif // EFI_DAC
|
||||
|
||||
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
|
||||
#include "can_msg_tx.h"
|
||||
#endif // EFI_CAN_SUPPORT
|
||||
|
@ -959,4 +964,14 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
return 0;
|
||||
});
|
||||
#endif // EFI_VEHICLE_SPEED
|
||||
|
||||
#if EFI_DAC
|
||||
lua_register(l, "setDacVoltage", [](lua_State* l) {
|
||||
auto channel = luaL_checkinteger(l, 1);
|
||||
auto voltage = luaL_checknumber(l, 2);
|
||||
setDacVoltage(channel, voltage);
|
||||
return 0;
|
||||
});
|
||||
#endif // EFI_DAC
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,17 @@ static Dac dac(DACD1);
|
|||
|
||||
void initDac() {
|
||||
dac.Start(dacConfig);
|
||||
for (size_t i = 0;i<DAC_OUTPUT_COUNT;i++) {
|
||||
Gpio pin = engineConfiguration->dacOutputPins[i];
|
||||
if (isBrainPinValid(pin)) {
|
||||
// setting up the output pin as analog as suggested by the Reference Manual.
|
||||
efiSetPadMode("dac", pin, PAL_MODE_INPUT_ANALOG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setDacVoltage(int channel, float voltage) {
|
||||
dac.SetVoltage(channel, voltage);
|
||||
}
|
||||
|
||||
#endif // EFI_DAC
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// dac.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -21,5 +23,6 @@ private:
|
|||
};
|
||||
|
||||
void initDac();
|
||||
void setDacVoltage(int channel, float voltage);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1135,7 +1135,8 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\
|
|||
uint8_t autoscale noFuelTrimAfterDfcoTime;Pause closed loop fueling after deceleration fuel cut occurs. Set this to a little longer than however long is required for normal fueling behavior to resume after fuel cut.;"sec", 0.1, 0, 0, 10, 1
|
||||
float tpsAccelEnrichmentThreshold;Maximum change delta of TPS percentage over the 'length'. Actual TPS change has to be above this value in order for TPS/TPS acceleration to kick in.;"roc", 1, 0, 0, 200, 1
|
||||
|
||||
brain_input_pin_e[2 iterate] auxSpeedSensorInputPin;
|
||||
#define AUX_SPEED_SENSOR_COUNT 2
|
||||
brain_input_pin_e[AUX_SPEED_SENSOR_COUNT iterate] auxSpeedSensorInputPin;
|
||||
uint8_t totalGearsCount;;"", 1, 0, 1, @@GEARS_COUNT@@, 0
|
||||
|
||||
custom InjectionTimingMode 1 bits, U08, @OFFSET@, [0:1], "End of injection", "Start of injection", "Center of injection"
|
||||
|
@ -1558,7 +1559,8 @@ pin_input_mode_e[LUA_DIGITAL_INPUT_COUNT iterate] luaDigitalInputPinModes;
|
|||
adc_channel_e throttleInletPressureChannel;Place the sensor before the throttle, but after any turbocharger/supercharger and intercoolers if fitted. Uses the same calibration as the MAP sensor.
|
||||
adc_channel_e compressorDischargePressureChannel;Place the sensor after the turbocharger/supercharger, but before any intercoolers if fitted. Uses the same calibration as the MAP sensor.
|
||||
|
||||
Gpio[2 iterate] dacOutputPins;
|
||||
#define DAC_OUTPUT_COUNT 2
|
||||
Gpio[DAC_OUTPUT_COUNT iterate] dacOutputPins;
|
||||
|
||||
uint8_t[250] mainUnusedEnd;;"units", 1, 0, 0, 1, 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue