summaryrefslogtreecommitdiffstats
path: root/kernel/code/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/code/gpio.c')
-rw-r--r--kernel/code/gpio.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/kernel/code/gpio.c b/kernel/code/gpio.c
new file mode 100644
index 0000000..549eb81
--- /dev/null
+++ b/kernel/code/gpio.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+#include <string.h>
+
+#include <sys/ioctl.h>
+#include <linux/cp210x.h>
+
+
+#define log_ioctl(fd,op,arg) do_ioctl(fd,#op,op,arg)
+
+int
+do_ioctl (int fd, char *sop, int op, void *arg)
+{
+ int ret;
+
+ errno = 0;
+
+ ret = ioctl (fd, op, arg);
+
+ printf ("ioctl(%d,%s(0x%x),%p)=%d (errno=%d(%s))\n", fd, sop, op, arg, ret,
+ errno, strerror (errno));
+
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ struct cp210x_port_config config;
+
+ int fd = open (argv[1], O_RDWR);
+
+ memset (&config, 0, sizeof (config));
+
+ log_ioctl (fd, CPIOC_PORTCONFGET, &config);
+
+ printf ("reset=(%x,%x,%x), suspend=(%x,%x,%x), enhanced_fxn=%x\n",
+ config.reset.mode,
+ config.reset.low_power,
+ config.reset.latch,
+ config.suspend.mode,
+ config.suspend.low_power,
+ config.suspend.latch, config.enhanced_fxn);
+
+
+}