DAC with Lua #5601

This commit is contained in:
rusefillc 2023-10-12 10:33:56 -04:00
parent c872239f51
commit 9a6406bd81
1 changed files with 7 additions and 2 deletions

View File

@ -40,15 +40,20 @@ static Dac dacs[] {
};
void initDac() {
dacs[0].Start(dacConfig);
dacs[1].Start(dacConfig);
bool dacIsUsed = false;
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);
dacIsUsed = true;
}
}
if (dacIsUsed) {
// DAC peripheral changes associated pin behaviour regardless of actual pin mode
dacs[0].Start(dacConfig);
dacs[1].Start(dacConfig);
}
}
void setDacVoltage(int channel, float voltage) {