summaryrefslogtreecommitdiff
path: root/usb/device/dfu/dfu_runtime.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-01-08 17:42:58 +0100
committerHarald Welte <laforge@gnumonks.org>2012-01-08 17:44:16 +0100
commit1b1befdeb5c24e5434952718cdd1b78cb6556fe5 (patch)
tree4c6c793a08fed3926b09ce776d2a1344c51892d2 /usb/device/dfu/dfu_runtime.c
parent5729b6faa31ad687facd4101e9a82b5daca65249 (diff)
DFU: add dfu_runtime.c for runtime-to-dfu switching
Diffstat (limited to 'usb/device/dfu/dfu_runtime.c')
-rw-r--r--usb/device/dfu/dfu_runtime.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/usb/device/dfu/dfu_runtime.c b/usb/device/dfu/dfu_runtime.c
new file mode 100644
index 0000000..5ad1038
--- /dev/null
+++ b/usb/device/dfu/dfu_runtime.c
@@ -0,0 +1,20 @@
+
+#include <board.h>
+#include <core_cm3.h>
+
+#include <usb/device/core/USBD.h>
+#include <usb/device/dfu/dfu.h>
+
+
+void DFURT_SwitchToDFU(void)
+{
+ unsigned int *dfu_except_tbl = (unsigned int *)AT91C_IFLASH0;
+ void (*toDFU)(void) = (void *)dfu_except_tbl[1];
+
+ *(unsigned int *)USB_DFU_MAGIC_ADDR = USB_DFU_MAGIC;
+
+ USBD_Disconnect();
+ __disable_irq();
+
+ toDFU();
+}
personal git repositories of Harald Welte. Your mileage may vary