diff options
Diffstat (limited to 'source/dac.cpp')
-rw-r--r-- | source/dac.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/dac.cpp b/source/dac.cpp new file mode 100644 index 0000000..c7c250d --- /dev/null +++ b/source/dac.cpp @@ -0,0 +1,27 @@ +#include "dac.hpp" + +//static const DACConversionGroup dacGroupConfig = { +// .num_channels = 1, +// .end_cb = NULL, +// .error_cb = NULL, +// .trigger = DAC_TRG(0) +//}; + +void DACd::init() +{ + initPins(); + dacStart(m_driver, &m_config); +} + +void DACd::write(unsigned int channel, uint16_t value) +{ + if (channel < 2) + dacPutChannelX(m_driver, channel, value); +} + +void DACd::initPins() +{ + palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG); // DAC out1, out2 + palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG); +} + |