summaryrefslogtreecommitdiffstats
path: root/kernel/code/set.c
blob: 4c8de0e15b024aae2a2d4217f8766409af3cce5e (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#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));

// config.reset.mode=0xf05f;
  config.reset.mode = ~CP_INPUT_PINS;
  config.reset.low_power = 0;
  config.reset.latch = CP_INPUT_PINS | CP_PIN_GPIO_1 | CP_PIN_GPIO_2;
// config.suspend.mode=0xf05f;
  config.suspend.mode = ~CP_INPUT_PINS;
  config.suspend.low_power = 0;
  config.suspend.latch = CP_INPUT_PINS | CP_PIN_GPIO_1 | CP_PIN_GPIO_2;
// config.enhanced_fxn=0x30;
  config.enhanced_fxn = CP_EFXN_ENABLE_WPU;


  log_ioctl (fd, CPIOC_PORTCONFSET, &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);

  log_ioctl (fd, CPIOC_DEVICERESET, 0);

}