close(fd);
}
-void cpSetPortConf(int fd, int pullups)
+void cpSetPortConf(int fd, int nopullups)
{
int ret;
cp2101_port_config_t config;
/* 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
* 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);
void usage(char* program)
{
- fprintf(stderr, "usage: %s [--pullups] <tty> <mfg> <part#> <sn#>\n",
+ fprintf(stderr, "usage: %s [--nopullups] <tty> <mfg> <part#> <sn#>\n",
program);
}
int main(int argc, char* argv[])
{
int fd;
- int pullups = 0;
+ int nopullups = 0;
if (argc < 2 || argc > 3) {
usage(argv[0]);
}
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");
}
}
-void cpSetPortConf(int fd, int pullups)
+void cpSetPortConf(int fd, int nopullups)
{
int ret;
cp2101_port_config_t config;
/* 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
* 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);
void usage(char* program)
{
- fprintf(stderr, "usage: %s [--pullups] <tty> <mfg> <part#> <sn#>\n",
+ fprintf(stderr, "usage: %s [--nopullups] <tty> <mfg> <part#> <sn#>\n",
program);
}
char newprod[255];
char newsn[255];
int fd;
- int pullups = 0;
+ int nopullups = 0;
if (argc < 5 || argc > 6) {
usage(argv[0]);
}
if (argc == 6) {
- if (strncmp(argv[1], "--p", 3) == 0)
- pullups = 1;
+ if (strncmp(argv[1], "--n", 3) == 0)
+ nopullups = 1;
else {
usage(argv[0]);
exit(1);
}
}
- /* strcpy(newmfg, argv[pullups + 2]);
- * strcpy(newprod, argv[pullups + 3]);
+ /* strcpy(newmfg, argv[nopullups + 2]);
+ * strcpy(newprod, argv[nopullups + 3]);
*/
- snprintf(newprod, sizeof(newprod), "%s %s", argv[pullups + 2],
- argv[pullups + 3]);
- strcpy(newsn, argv[pullups + 4]);
- fd = cpConnect(argv[pullups + 1]);
+ snprintf(newprod, sizeof(newprod), "%s %s", argv[nopullups + 2],
+ argv[nopullups + 3]);
+ strcpy(newsn, argv[nopullups + 4]);
+ fd = cpConnect(argv[nopullups + 1]);
/* SiLabs doesn't allow set of mfg string on cp210x.
* cpSetStr(fd, IOCTL_SETMFG, newmfg, strlen(newmfg));
*/
cpSetStr(fd, IOCTL_SETPRODUCT, newprod, strlen(newprod));
cpSetStr(fd, IOCTL_SETSERIAL, newsn, strlen(newsn));
- cpSetPortConf(fd, pullups);
+ cpSetPortConf(fd, nopullups);
cpReset(fd);
cpDisconnect(fd);
printf("done\n");