diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-01-13 12:25:58 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-01-13 12:25:58 -0500 |
commit | 078a03dc2107674832a720b2ddb9cb15b78e7b15 (patch) | |
tree | 18c86d4ded6a756f71c9fb2bc76c9147404621a7 | |
parent | 093512b9713999069b53193127ab0086e075a4f7 (diff) | |
download | kutter-078a03dc2107674832a720b2ddb9cb15b78e7b15.tar.gz kutter-078a03dc2107674832a720b2ddb9cb15b78e7b15.tar.xz kutter-078a03dc2107674832a720b2ddb9cb15b78e7b15.zip |
lpc176x: Add mechanism for entering the bootloader from a USB signal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | src/lpc176x/usbserial.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lpc176x/usbserial.c b/src/lpc176x/usbserial.c index 677aa013..d6db8565 100644 --- a/src/lpc176x/usbserial.c +++ b/src/lpc176x/usbserial.c @@ -6,6 +6,8 @@ #include <string.h> // memcpy #include "LPC17xx.h" // LPC_SC +#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER +#include "board/irq.h" // irq_disable #include "byteorder.h" // cpu_to_le32 #include "command.h" // output #include "generic/usb_cdc.h" // usb_notify_ep0 @@ -244,6 +246,13 @@ usb_set_configure(void) void usb_request_bootloader(void) { + if (!CONFIG_SMOOTHIEWARE_BOOTLOADER) + return; + // The "LPC17xx-DFU-Bootloader" will enter the bootloader if the + // watchdog timeout flag is set. + irq_disable(); + LPC_WDT->WDMOD = 0x07; + NVIC_SystemReset(); } void |