diff options
Diffstat (limited to 'kernel/code/set.c')
-rw-r--r-- | kernel/code/set.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/kernel/code/set.c b/kernel/code/set.c new file mode 100644 index 0000000..4c8de0e --- /dev/null +++ b/kernel/code/set.c @@ -0,0 +1,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); + +} |