STM32F103 WEB USB DFU 固件
Dependencies: mbed mbed-STM32F103C8T6 USBDevice_STM32F103
Revision 0:5fac9aab2679, committed 2021-05-31
- Comitter:
- qitas
- Date:
- Mon May 31 10:53:57 2021 +0800
- Commit message:
- INIT
Changed in this revision
diff -r 000000000000 -r 5fac9aab2679 USBDevice_STM32F103.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice_STM32F103.lib Mon May 31 10:53:57 2021 +0800 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/devanlai/code/USBDevice_STM32F103/#e410de636542
diff -r 000000000000 -r 5fac9aab2679 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 31 10:53:57 2021 +0800 @@ -0,0 +1,56 @@ +#include "stm32f103c8t6.h" +#include "mbed.h" +#include "WebUSBDFU.h" + +DigitalOut myled(LED1); + +bool detached = false; +void onDetachRequested() { + detached = true; +} + +void resetIntoBootloader() { + // Turn on write access to the backup registers + __PWR_CLK_ENABLE(); + HAL_PWR_EnableBkUpAccess(); + + // Write the magic value to force the bootloader to run + BKP->DR2 = 0x544F; + BKP->DR1 = 0x4F42; + + HAL_PWR_DisableBkUpAccess(); + + // Reset and let the bootloader run + NVIC_SystemReset(); +} + +int main() +{ + confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) + + /* Note: 1209:0001 is a test VID/PID pair - it should be changed before using in + * a real application */ + WebUSBDFU usbDFU(0x1209, 0x0001, 0x0001, false); + usbDFU.attach(onDetachRequested); + + while(1) { + // Check the DFU status + if (!usbDFU.configured()) { + usbDFU.connect(false); + } + if (detached) { + for (int i=0; i < 3; i++) { + myled = 1; + wait_ms(100); + myled = 0; + wait_ms(100); + } + resetIntoBootloader(); + } + + // Do normal stuff + myled = !myled; + wait_ms(500); + } +} +
diff -r 000000000000 -r 5fac9aab2679 mbed-STM32F103C8T6.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-STM32F103C8T6.lib Mon May 31 10:53:57 2021 +0800 @@ -0,0 +1,1 @@ +http://mbed.org/users/hudakz/code/mbed-STM32F103C8T6/#09d8c2eacb4d
diff -r 000000000000 -r 5fac9aab2679 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 31 10:53:57 2021 +0800 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b0220dba8be7 \ No newline at end of file