aboutsummaryrefslogtreecommitdiff
path: root/dac.c
diff options
context:
space:
mode:
authorCamil Staps2017-01-31 23:15:28 +0100
committerCamil Staps2017-01-31 23:15:28 +0100
commit631204a1feffa8cf3795060370b14dfb9f53f533 (patch)
tree001d32e0157127607f7c088881f098c2eca841a1 /dac.c
Diffstat (limited to 'dac.c')
-rw-r--r--dac.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/dac.c b/dac.c
new file mode 100644
index 0000000..12fb41c
--- /dev/null
+++ b/dac.c
@@ -0,0 +1,13 @@
+#include <xc.h>
+#include "dac.h"
+
+void dac_init(void) {
+ DAC1REFH = 0x00;
+ DAC1REFL = 0x00;
+ DAC1CON0 = 0xa0; /* enable, output on RA2, VDD - VSS */
+}
+
+inline void dac_set(uint8_t value) {
+ DAC1REFL = value;
+ DACLDbits.DAC1LD = 1;
+}