aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpencer Oliver <spen@spen-soft.co.uk>2012-04-19 15:45:06 +0100
committerSpencer Oliver <spen@spen-soft.co.uk>2012-04-30 13:04:38 +0000
commit5d1cabb1422f9b76afb665aecc2f0116174de1b0 (patch)
tree5f94ec00a9c3c54e96813f83e1f32be2176062fe /src
parent9cc733ae312dd79471f4cc5116f675116d5176b3 (diff)
stlink: add hardware srst functions to stlink/v2
Change-Id: Ib82b6a1116b9f396f1933cc5526733334254fd62 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/579 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com> Reviewed-by: Mathias Küster <kesmtp@freenet.de>
Diffstat (limited to 'src')
-rw-r--r--src/jtag/drivers/stlink_usb.c30
-rw-r--r--src/jtag/stlink/stlink_layout.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 6fe958e8..d40436a0 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -719,6 +719,8 @@ static enum target_state stlink_usb_v2_get_status(void *handle)
if (status & S_HALT)
return TARGET_HALTED;
+ else if (status & S_RESET_ST)
+ return TARGET_RESET;
return TARGET_RUNNING;
}
@@ -783,6 +785,32 @@ static int stlink_usb_reset(void *handle)
return h->databuf[0] == STLINK_DEBUG_ERR_OK ? ERROR_OK : ERROR_FAIL;
}
+static int stlink_usb_assert_srst(void *handle, int srst)
+{
+ int res;
+ struct stlink_usb_handle_s *h;
+
+ assert(handle != NULL);
+
+ h = (struct stlink_usb_handle_s *)handle;
+
+ if (h->jtag_api == STLINK_JTAG_API_V1)
+ return ERROR_COMMAND_NOTFOUND;
+
+ stlink_usb_init_buffer(handle, STLINK_RX_EP, 2);
+
+ h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
+ h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_APIV2_DRIVE_NRST;
+ h->cmdbuf[h->cmdidx++] = srst;
+
+ res = stlink_usb_xfer(handle, h->databuf, 2);
+
+ if (res != ERROR_OK)
+ return res;
+
+ return h->databuf[0] == STLINK_DEBUG_ERR_OK ? ERROR_OK : ERROR_FAIL;
+}
+
/** */
static int stlink_usb_run(void *handle)
{
@@ -1223,6 +1251,8 @@ struct stlink_layout_api_s stlink_usb_layout_api = {
/** */
.reset = stlink_usb_reset,
/** */
+ .assert_srst = stlink_usb_assert_srst,
+ /** */
.run = stlink_usb_run,
/** */
.halt = stlink_usb_halt,
diff --git a/src/jtag/stlink/stlink_layout.h b/src/jtag/stlink/stlink_layout.h
index 59e6174c..e0da75c7 100644
--- a/src/jtag/stlink/stlink_layout.h
+++ b/src/jtag/stlink/stlink_layout.h
@@ -37,6 +37,8 @@ struct stlink_layout_api_s {
/** */
int (*reset) (void *fd);
/** */
+ int (*assert_srst) (void *fd, int srst);
+ /** */
int (*run) (void *fd);
/** */
int (*halt) (void *fd);