Files
wideband/firmware/dac.cpp
Matthew Kennedy ca50ee30f0 format IO
2026-04-10 13:35:51 -07:00

34 lines
545 B
C++

#include "dac.h"
/* for VCC_VOLTS */
#include "wideband_config.h"
#include <rusefi/math.h>
#if HAL_USE_DAC
Dac::Dac(DACDriver& driver)
: m_driver(&driver)
{
}
void Dac::Start(DACConfig& config)
{
dacStart(m_driver, &config);
}
void Dac::SetVoltage(int channel, float voltage)
{
voltage = clampF(0, voltage, VCC_VOLTS);
m_voltageFloat[channel] = voltage;
dacPutChannelX(m_driver, channel, voltage / VCC_VOLTS * ((1 << 12) - 1));
}
float Dac::GetLastVoltage(int channel)
{
return m_voltageFloat[channel];
}
#endif