Skip to content

Commit

Permalink
Reset through AIRCR (#540) (#712)
Browse files Browse the repository at this point in the history
In addition to asserting the NRST line, also request system reset through the
Application Interrupt and Reset Control Register (AIRCR).
  • Loading branch information
timothytylee authored and xor-gate committed May 31, 2018
1 parent 6f74f4a commit 6db0fc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions include/stlink/reg.h
Expand Up @@ -12,4 +12,9 @@
#define STLINK_REG_DCRSR 0xe000edf4
#define STLINK_REG_DCRDR 0xe000edf8

/* Application Interrupt and Reset Control Register */
#define STLINK_REG_AIRCR 0xe000ed0c
#define STLINK_REG_AIRCR_VECTKEY 0x05fa0000
#define STLINK_REG_AIRCR_SYSRESETREQ 0x00000004

#endif /* STLINK_REG_H_ */
5 changes: 5 additions & 0 deletions src/sg.c
Expand Up @@ -535,6 +535,11 @@ int _stlink_sg_reset(stlink_t *sl) {
if (stlink_q(sl))
return -1;

// Reset through AIRCR so NRST does not need to be connected
if (stlink_write_debug32(sl, STLINK_REG_AIRCR,
STLINK_REG_AIRCR_VECTKEY | STLINK_REG_AIRCR_SYSRESETREQ))
return -1;

stlink_stat(sl, "core reset");
return 0;
}
Expand Down
9 changes: 4 additions & 5 deletions src/usb.c
Expand Up @@ -368,10 +368,7 @@ int _stlink_usb_exit_dfu_mode(stlink_t* sl) {
return 0;
}

/**
* TODO - not convinced this does anything...
* @param sl
*/

int _stlink_usb_reset(stlink_t * sl) {
struct stlink_libusb * const slu = sl->backend_data;
unsigned char* const data = sl->q_buf;
Expand All @@ -389,7 +386,9 @@ int _stlink_usb_reset(stlink_t * sl) {
return (int) size;
}

return 0;
// Reset through AIRCR so NRST does not need to be connected
return stlink_write_debug32(sl, STLINK_REG_AIRCR,
STLINK_REG_AIRCR_VECTKEY | STLINK_REG_AIRCR_SYSRESETREQ);
}


Expand Down

0 comments on commit 6db0fc2

Please sign in to comment.