summaryrefslogtreecommitdiffstats
path: root/kernel/code/gpio.c
blob: 549eb819005fdb1552ddffbcf3965f7f01af9ef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);


}