X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=src%2Fexamples%2Fcpio.c;h=8fec895da3ffd73d13ab49d106df41e185f229cc;hb=9a6ce48371002e94e2adfef323fbf6c1f6d069c4;hp=b08ee23f7b4b27f16d231cb4cc7aeaa02b21f892;hpb=31344b807962b968af815c4708f0edadfc657d54;p=cp210x.git diff --git a/src/examples/cpio.c b/src/examples/cpio.c index b08ee23..8fec895 100644 --- a/src/examples/cpio.c +++ b/src/examples/cpio.c @@ -48,7 +48,7 @@ void cpDisconnect(int fd) close(fd); } -void cpSetPortConf(int fd, int pullups) +void cpSetPortConf(int fd, int nopullups) { int ret; cp2101_port_config_t config; @@ -61,8 +61,8 @@ void cpSetPortConf(int fd, int pullups) /* This section assumes the device is currently at factory defaults. If * not, first run 'cpfactory'. The only delta from factory defaults is to - * activate the activity pin functions for GPIOs 0 and 1. Some boards may - * require weak pull-ups, but not TMI's RWS. + * activate the activity pin functions for GPIOs 0 and 1. Most boards + * require the use of weak pull-ups, including TMI's RWS. * * GPIO mapping: * GPIO_0 -> TX activity, active low @@ -71,8 +71,9 @@ void cpSetPortConf(int fd, int pullups) * GPIO_3 -> MSP430 UC_RST * */ - config.reset.mode |= 0x0800; /* GPIO_3 gets push-pull driver */ - config.enhancedFxn |= (pullups) ? 0x13 : 0x03; + config.enhancedFxn |= 0x13; + if (nopullups) + config.enhancedFxn &= ~0x10; if ((ret = ioctl(fd, IOCTL_PORTCONFSET, &config))) { fprintf(stderr, "portconfset ioctl failed %d\n", ret); @@ -93,14 +94,14 @@ void cpReset(int fd) void usage(char* program) { - fprintf(stderr, "usage: %s [--pullups] \n", + fprintf(stderr, "usage: %s [--nopullups] \n", program); } int main(int argc, char* argv[]) { int fd; - int pullups = 0; + int nopullups = 0; if (argc < 2 || argc > 3) { usage(argv[0]); @@ -108,16 +109,16 @@ int main(int argc, char* argv[]) } if (argc == 3) { - if (strncmp(argv[1], "--p", 3) == 0) - pullups = 1; + if (strncmp(argv[1], "--n", 3) == 0) + nopullups = 1; else { usage(argv[0]); exit(1); } } - fd = cpConnect(argv[pullups + 1]); - cpSetPortConf(fd, pullups); + fd = cpConnect(argv[nopullups + 1]); + cpSetPortConf(fd, nopullups); cpReset(fd); cpDisconnect(fd); printf("done\n");