]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Added Comedi userspace example for setting DAC for MF614 card.
authorRostislav Lisovy <lisovy@gmail.com>
Mon, 9 May 2011 21:31:50 +0000 (23:31 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Mon, 9 May 2011 21:31:50 +0000 (23:31 +0200)
src/comedi/mf614_simple_driver/userspace/dac_example/Makefile [new file with mode: 0644]
src/comedi/mf614_simple_driver/userspace/dac_example/main.c [new file with mode: 0644]

diff --git a/src/comedi/mf614_simple_driver/userspace/dac_example/Makefile b/src/comedi/mf614_simple_driver/userspace/dac_example/Makefile
new file mode 100644 (file)
index 0000000..8e4f4ee
--- /dev/null
@@ -0,0 +1,2 @@
+all:
+       gcc main.c -o main -lcomedi -lm
diff --git a/src/comedi/mf614_simple_driver/userspace/dac_example/main.c b/src/comedi/mf614_simple_driver/userspace/dac_example/main.c
new file mode 100644 (file)
index 0000000..4924ac3
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <comedilib.h>
+#define MF614_AO_SUBDEV        3
+
+
+
+int main(int argc, char* argv[])
+{
+       comedi_t* comedi_dev;
+       int status;
+       int channel = 0;
+       int range = 0;
+       int aref = 0;
+
+       comedi_dev = comedi_open("/dev/comedi0");
+       if (comedi_dev == NULL) {
+               comedi_perror("comedi_open");
+               return 1;
+       }
+
+       while(1) {
+               printf("Setting DA0 to 9.9 V \n");
+               status = comedi_data_write(comedi_dev, MF614_AO_SUBDEV, channel, range, aref, 0xFFF); // 9.9 V
+               if (status == -1) {
+                       comedi_perror("comedi_data_write");
+               }
+               sleep(1);
+               
+               printf("Setting DA0 to 0 V\n");
+               status = comedi_data_write(comedi_dev, MF614_AO_SUBDEV, channel, range, aref, 0x800); // 0 V
+               if (status == -1) {
+                       comedi_perror("comedi_data_write");
+               }
+               sleep(1);
+       }
+
+       return 0;
+}