summaryrefslogtreecommitdiff
path: root/quellcode/versuch1/cpx.h
diff options
context:
space:
mode:
Diffstat (limited to 'quellcode/versuch1/cpx.h')
-rwxr-xr-xquellcode/versuch1/cpx.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/quellcode/versuch1/cpx.h b/quellcode/versuch1/cpx.h
new file mode 100755
index 0000000..bcdbe17
--- /dev/null
+++ b/quellcode/versuch1/cpx.h
@@ -0,0 +1,67 @@
+/**
+ *
+ * \file cpx.h
+ * \brief read and write DIO
+ *
+ * \author Manuel Traut
+ * \version 2006-10-06
+ *
+ */
+
+#ifndef CPX_H
+#define CPX_H
+
+#include <iostream>
+
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+// Device Nodes
+#define CPX_Input "/dev/iio2"
+#define CPX_Input_1 "/dev/iio2_in"
+#define CPX_Output_1 "/dev/iio2_out"
+
+// Memory Addresses
+#define PORT1_OUT 0x2c00
+#define PORT2_OUT 0x3c00
+#define PORT3_OUT 0x4c00
+
+#define PORT1_IN 0x5c00
+#define PORT2_IN 0x6c00
+#define PORT3_IN 0x7c00
+
+#define PROT_READ 0x01
+#define PROT_WRITE 0x02
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+
+// ioctl (file descriptor, CPX_DIO_IOCTL_SET_SIGNAL, irq_send_signal_param*)
+// enable sending signal on interrupt
+// cpx_dio_set_signal_param.signal = signal to be sent to process
+#define CPX_DIO_IOCTL_BASE 0xCD
+
+typedef struct{
+ int signal; // signal to be sent
+ int pid; // process id, signal should be sent to
+}cpx_dio_set_signal_param;
+
+#define CPX_DIO_IOCTL_ADD_SIG _IOW(CPX_DIO_IOCTL_BASE, 3, cpx_dio_set_signal_param)
+#define CPX_DIO_IOCTL_DEL_SIG _IOW(CPX_DIO_IOCTL_BASE, 4, cpx_dio_set_signal_param)
+
+class CPX{
+ public:
+ CPX();
+ void set(short port, short value);
+ short get(short port);
+ private:
+ int init();
+ unsigned char *mapped_in;
+ unsigned char *mapped_out;
+ volatile u_char *DOUT;
+ volatile u_char *DIN;
+ cpx_dio_set_signal_param param;
+};
+
+#endif