aboutsummaryrefslogtreecommitdiff
path: root/src/lpc43xx.c
diff options
context:
space:
mode:
authorAllen Ibara2014-01-10 10:54:56 -0800
committerAllen Ibara2014-01-10 13:24:25 -0800
commit911af3b8363247d132abb9a11559104b0402ae56 (patch)
treeac2bccd4a6bdf1a42b1c219dfbc181eeeaffb36c /src/lpc43xx.c
parent813622b1b6146371a3a9ff50bc62727ecd1f6b26 (diff)
LPC43XX: Add reset command to do a system reset (but not the debug).
Diffstat (limited to 'src/lpc43xx.c')
-rw-r--r--src/lpc43xx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lpc43xx.c b/src/lpc43xx.c
index 49f8068..a578e67 100644
--- a/src/lpc43xx.c
+++ b/src/lpc43xx.c
@@ -114,6 +114,7 @@ struct flash_program {
};
static bool lpc43xx_cmd_erase(target *t);
+static bool lpc43xx_cmd_reset(target *target, int argc, const char *argv[]);
static bool lpc43xx_cmd_mkboot(target *target, int argc, const char *argv[]);
static int lpc43xx_flash_init(struct target_s *target);
static void lpc43xx_iap_call(struct target_s *target, struct flash_param *param, unsigned param_len);
@@ -123,6 +124,7 @@ static int lpc43xx_flash_write(struct target_s *target, uint32_t dest, const uin
const struct command_s lpc43xx_cmd_list[] = {
{"erase_mass", (cmd_handler)lpc43xx_cmd_erase, "Erase entire flash memory"},
+ {"reset", lpc43xx_cmd_reset, "Reset target"},
{"mkboot", lpc43xx_cmd_mkboot, "Make flash bank bootable"},
{NULL, NULL, NULL}
};
@@ -198,6 +200,20 @@ bool lpc43xx_probe(struct target_s *target)
return false;
}
+/* Reset all major systems _except_ debug */
+static bool lpc43xx_cmd_reset(target *target, int __attribute__((unused)) argc, const char __attribute__((unused)) *argv[])
+{
+ /* Cortex-M4 Application Interrupt and Reset Control Register */
+ static const uint32_t AIRCR = 0xE000ED0C;
+ /* Magic value key */
+ static const uint32_t reset_val = 0x05FA0004;
+
+ /* System reset on target */
+ target_mem_write_words(target, AIRCR, &reset_val, sizeof(reset_val));
+
+ return true;
+}
+
static bool lpc43xx_cmd_erase(target *target)
{
uint32_t bank = 0;