aboutsummaryrefslogtreecommitdiffstats
path: root/source/dac.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-06-11 10:15:31 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-06-11 10:15:31 -0400
commit7f0a54a8ee175106254982dc12c184d7c25849b4 (patch)
tree4415a7f58bdb2d17266c9bfa267f5f903e5177a6 /source/dac.cpp
parent14eb7970debdafdd7e8486eced64d4b718a821a7 (diff)
made classes for drivers
Diffstat (limited to 'source/dac.cpp')
-rw-r--r--source/dac.cpp27
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);
+}
+