Added voltage control command-line switch.

This commit is contained in:
Daniel Beer 2010-01-06 21:08:01 +13:00
parent ce308c5823
commit 187bcb283c
2 changed files with 17 additions and 9 deletions

12
fet.c
View File

@ -860,12 +860,6 @@ const struct device *fet_open(const struct fet_transport *tr,
printf("Configured for %s\n",
(proto_flags & FET_PROTO_SPYBIWIRE) ? "Spy-Bi-Wire" : "JTAG");
/* Identify the chip */
if (do_identify() < 0) {
fprintf(stderr, "fet: identify failed\n");
return NULL;
}
/* set VCC */
if (xfer(C_VCC, NULL, 0, 2, vcc_mv, 0) < 0) {
fprintf(stderr, "fet: set VCC failed\n");
@ -874,6 +868,12 @@ const struct device *fet_open(const struct fet_transport *tr,
printf("Set Vcc: %d mV\n", vcc_mv);
/* Identify the chip */
if (do_identify() < 0) {
fprintf(stderr, "fet: identify failed\n");
return NULL;
}
/* I don't know what this is, but it appears to halt the MSP. Without
* it, memory reads return garbage. This is RF2500-specific.
*/

14
main.c
View File

@ -648,12 +648,15 @@ static void reader_loop(void)
static void usage(const char *progname)
{
fprintf(stderr, "Usage: %s [-u device] [-j] [command ...]\n"
fprintf(stderr,
"Usage: %s [-u device] [-j] [-v voltage] [command ...]\n"
"\n"
" -u device\n"
" Open the given tty device (MSP430 UIF compatible devices).\n"
" -j\n"
" Use JTAG, rather than spy-bi-wire (UIF devices only).\n"
" -v voltage\n"
" Set the supply voltage, in millivolts.\n"
"\n"
"By default, the first RF2500 device on the USB bus is opened.\n"
"\n"
@ -669,6 +672,7 @@ int main(int argc, char **argv)
int opt;
int flags = 0;
int want_jtag = 0;
int vcc_mv = 3000;
puts(
"MSPDebug version 0.3 - debugging tool for the eZ430\n"
@ -676,12 +680,16 @@ int main(int argc, char **argv)
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
while ((opt = getopt(argc, argv, "u:j")) >= 0)
while ((opt = getopt(argc, argv, "u:jv:")) >= 0)
switch (opt) {
case 'u':
uif_device = optarg;
break;
case 'v':
vcc_mv = atoi(optarg);
break;
case 'j':
want_jtag = 1;
break;
@ -704,7 +712,7 @@ int main(int argc, char **argv)
/* Then initialize the device */
if (!want_jtag)
flags |= FET_PROTO_SPYBIWIRE;
msp430_dev = fet_open(trans, flags, 3000);
msp430_dev = fet_open(trans, flags, vcc_mv);
if (!msp430_dev)
return -1;