summaryrefslogtreecommitdiff
path: root/usb/device/dfu
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-08 18:24:32 +0100
committerHarald Welte <laforge@gnumonks.org>2012-01-08 18:24:32 +0100
commit61739ec34d060a208db9506d5a8d94ad7059c7c5 (patch)
tree32ecf2bb3e10a10bcd9bb9af2fd70ac37ac42f6e /usb/device/dfu
parent1b1befdeb5c24e5434952718cdd1b78cb6556fe5 (diff)
DFU: include code to switch from DFU to RUNTUIME after bus reset / mannifest
Diffstat (limited to 'usb/device/dfu')
-rw-r--r--usb/device/dfu/dfu.h3
-rw-r--r--usb/device/dfu/dfu_driver.c19
2 files changed, 22 insertions, 0 deletions
diff --git a/usb/device/dfu/dfu.h b/usb/device/dfu/dfu.h
index eec956b..52b4ea5 100644
--- a/usb/device/dfu/dfu.h
+++ b/usb/device/dfu/dfu.h
@@ -139,6 +139,9 @@ void USBDFU_DFU_RequestHandler(const USBGenericRequest *request);
void USBDFU_Initialize(const USBDDriverDescriptors *pDescriptors);
+/* USBD tells us to switch from DFU mode to application mode */
+void USBDFU_SwitchToApp(void);
+
#define DFU_RET_NOTHING 0
#define DFU_RET_ZLP 1
#define DFU_RET_STALL 2
diff --git a/usb/device/dfu/dfu_driver.c b/usb/device/dfu/dfu_driver.c
index 832ccbb..c9a9f03 100644
--- a/usb/device/dfu/dfu_driver.c
+++ b/usb/device/dfu/dfu_driver.c
@@ -22,6 +22,9 @@
#include <unistd.h>
+#include <board.h>
+#include <core_cm3.h>
+
#include <utility/trace.h>
#include <usb/common/core/USBInterfaceDescriptor.h>
@@ -462,3 +465,19 @@ void USBDFU_Initialize(const USBDDriverDescriptors *pDescriptors)
USBD_Init();
}
+
+void USBDFU_SwitchToApp(void)
+{
+ /* make sure the MAGIC is not set to enter DFU again */
+ *(unsigned int *)USB_DFU_MAGIC_ADDR = 0;
+
+ /* disconnect from USB to ensure re-enumeration */
+ USBD_Disconnect();
+
+ /* disable any interrupts during transition */
+ __disable_irq();
+
+ /* Tell the hybrid to execute FTL JUMP! */
+ //BootIntoApp();
+ RSTC_ProcessorReset();
+}
personal git repositories of Harald Welte. Your mileage may vary