#include #include #include #include #include #include #include #include #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); }