File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
common-hal/microcontroller Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 35
35
#include "shared-bindings/microcontroller/__init__.h"
36
36
#include "shared-bindings/microcontroller/Pin.h"
37
37
#include "shared-bindings/microcontroller/Processor.h"
38
+ #include "supervisor/filesystem.h"
39
+ #include "supervisor/port.h"
38
40
#include "supervisor/shared/safe_mode.h"
39
41
#include "supervisor/shared/translate.h"
40
42
41
43
#include "src/rp2040/hardware_structs/include/hardware/structs/sio.h"
42
44
#include "src/rp2_common/hardware_sync/include/hardware/sync.h"
43
45
46
+ #include "hardware/watchdog.h"
47
+
44
48
void common_hal_mcu_delay_us (uint32_t delay ) {
45
49
mp_hal_delay_us (delay );
46
50
}
@@ -66,8 +70,11 @@ void common_hal_mcu_enable_interrupts(void) {
66
70
asm volatile ("cpsie i" : : : "memory" );
67
71
}
68
72
73
+ static bool next_reset_to_bootloader = false;
74
+
69
75
void common_hal_mcu_on_next_reset (mcu_runmode_t runmode ) {
70
76
if (runmode == RUNMODE_BOOTLOADER ) {
77
+ next_reset_to_bootloader = true;
71
78
} else {
72
79
}
73
80
if (runmode == RUNMODE_SAFE_MODE ) {
@@ -76,6 +83,12 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
76
83
}
77
84
78
85
void common_hal_mcu_reset (void ) {
86
+ filesystem_flush ();
87
+ if (next_reset_to_bootloader ) {
88
+ reset_to_bootloader ();
89
+ } else {
90
+ reset_cpu ();
91
+ }
79
92
}
80
93
81
94
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
Original file line number Diff line number Diff line change 52
52
53
53
#include "tusb.h"
54
54
55
+ #include "pico/bootrom.h"
56
+ #include "hardware/watchdog.h"
55
57
56
58
extern volatile bool mp_msc_enabled ;
57
59
@@ -110,13 +112,17 @@ void reset_port(void) {
110
112
}
111
113
112
114
void reset_to_bootloader (void ) {
113
- // reset( );
115
+ reset_usb_boot ( 0 , 0 );
114
116
while (true) {}
115
117
}
116
118
117
119
void reset_cpu (void ) {
118
- // reset();
119
- while (true) {}
120
+ watchdog_reboot (0 , SRAM_END , 0 );
121
+ watchdog_start_tick (12 );
122
+
123
+ while (true) {
124
+ __wfi ();
125
+ }
120
126
}
121
127
122
128
bool port_has_fixed_stack (void ) {
You can’t perform that action at this time.
0 commit comments