From 2ef8f7574b41a5463ddac1ec70360f8452e8fb80 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Thu, 2 Sep 2010 11:55:12 +1200 Subject: [PATCH] fet: by default, reset chip on startup. --- fet.c | 7 +++++++ fet.h | 1 + main.c | 11 ++++++++++- mspdebug.man | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/fet.c b/fet.c index b48ba1a..48f8295 100644 --- a/fet.c +++ b/fet.c @@ -888,6 +888,13 @@ device_t fet_open(transport_t transport, int proto_flags, int vcc_mv, if (do_configure(dev) < 0) goto fail; + /* Reset first, if requested */ + if (!(proto_flags & FET_PROTO_NORESET)) { + printc_dbg("Sending initial reset...\n"); + if (xfer(dev, C_RESET, NULL, 0, 3, FET_RESET_ALL, 0, 0) < 0) + printc_err("warning: fet: initial reset failed\n"); + } + /* set VCC */ if (xfer(dev, C_VCC, NULL, 0, 1, vcc_mv) < 0) printc_err("warning: fet: set VCC failed\n"); diff --git a/fet.h b/fet.h index 0a2baaf..775fd8e 100644 --- a/fet.h +++ b/fet.h @@ -26,6 +26,7 @@ #define FET_PROTO_SPYBIWIRE 0x01 #define FET_PROTO_RF2500 0x02 #define FET_PROTO_OLIMEX 0x04 +#define FET_PROTO_NORESET 0x08 device_t fet_open(transport_t transport, int proto_flags, int vcc_mv, const char *force_id); diff --git a/main.c b/main.c index ba9ba4f..e6143e4 100644 --- a/main.c +++ b/main.c @@ -124,6 +124,7 @@ struct cmdline_args { const char *usb_device; const char *fet_force_id; int want_jtag; + int no_reset; int no_rc; int vcc_mv; }; @@ -141,6 +142,8 @@ static device_t driver_open_fet(const struct cmdline_args *args, if (!args->want_jtag) flags |= FET_PROTO_SPYBIWIRE; + if (args->no_reset) + flags |= FET_PROTO_NORESET; dev = fet_open(trans, flags, args->vcc_mv, args->fet_force_id); if (!dev) { @@ -271,6 +274,8 @@ static void usage(const char *progname) " Set the supply voltage, in millivolts.\n" " -n\n" " Do not read ~/.mspdebug on startup.\n" +" -r\n" +" Do not reset the device on startup.\n" " --help\n" " Show this help text.\n" " --fet-list\n" @@ -357,7 +362,7 @@ static int parse_cmdline_args(int argc, char **argv, {NULL, 0, 0, 0} }; - while ((opt = getopt_long(argc, argv, "d:jv:nU:q", + while ((opt = getopt_long(argc, argv, "d:jv:nU:qr", longopts, NULL)) >= 0) switch (opt) { case 'q': @@ -412,6 +417,10 @@ static int parse_cmdline_args(int argc, char **argv, args->no_rc = 1; break; + case 'r': + args->no_reset = 1; + break; + case '?': printc_err("Try --help for usage information.\n"); return -1; diff --git a/mspdebug.man b/mspdebug.man index bfa9077..66a80dd 100644 --- a/mspdebug.man +++ b/mspdebug.man @@ -47,6 +47,8 @@ Specify a particular USB device to connect to. Without this option, the first device of the appropriate type is opened. .IP "\-n" Do not process the startup file (~/.mspdebug). +.IP "\-r" +Do not reset the device on startup. .IP "\-\-help" Display a brief help message and exit. .IP "\-\-fet\-list"