From 1b1befdeb5c24e5434952718cdd1b78cb6556fe5 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Jan 2012 17:42:58 +0100 Subject: DFU: add dfu_runtime.c for runtime-to-dfu switching --- usb/device/dfu/dfu_runtime.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 usb/device/dfu/dfu_runtime.c (limited to 'usb/device/dfu/dfu_runtime.c') 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 +#include + +#include +#include + + +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(); +} -- cgit v1.2.3