]> git.earman.xyz Git - sensor-watch.git/commitdiff
add watch_reset_to_bootloader function (resolves #81)
authorJoey Castillo <joeycastillo@utexas.edu>
Sun, 14 Aug 2022 20:23:19 +0000 (15:23 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Sun, 14 Aug 2022 20:23:32 +0000 (15:23 -0500)
watch-library/hardware/watch/watch.c
watch-library/shared/watch/watch.h
watch-library/simulator/watch/watch.c

index b3dc4e8d168578518c87a5d107e0d20352c06265..7bda9257d596accf99d0d6d6c4124f1eb32cbab6 100644 (file)
@@ -45,3 +45,9 @@ bool watch_is_buzzer_or_led_enabled(void){
 bool watch_is_usb_enabled(void) {
     return USB->DEVICE.CTRLA.bit.ENABLE;
 }
+
+void watch_reset_to_bootloader(void) {
+    volatile uint32_t *dbl_tap_ptr = ((volatile uint32_t *)(HSRAM_ADDR + HSRAM_SIZE - 4));
+    *dbl_tap_ptr = 0xf01669ef; // from the UF2 bootloaer: uf2.h line 255
+    NVIC_SystemReset();
+}
index b94d36fb8499b0e26da33a9abae9e6ca8331bbf5..7526d03a1fc98b1720bb41ea1c4b27a15dbc54dd 100644 (file)
@@ -80,6 +80,10 @@ bool watch_is_buzzer_or_led_enabled(void);
   */
 bool watch_is_usb_enabled(void);
 
+/** @brief Resets in the UF2 bootloader mode
+  */
+void watch_reset_to_bootloader(void);
+
 /** @brief Reads up to len bytes from the USB serial.
   * @param file ignored, you can pass in 0
   * @param ptr pointer to a buffer of at least len bytes
index 749651af23bfe9913fe1a8af0c3ea8dec473568c..4e89f3d335d2d9ed1c5e30105a7ba0092dfcab06 100644 (file)
@@ -7,3 +7,7 @@ bool watch_is_buzzer_or_led_enabled(void) {
 bool watch_is_usb_enabled(void) {
     return true;
 }
+
+void watch_reset_to_bootloader(void) {
+    // No bootloader in the simulator; nothing to do here
+}