1-
21#include " SerialUSB.h"
32#include " tusb.h"
3+ #include " boot.h"
44
55#ifndef DISABLE_USB_SERIAL
66// Ensure we are installed in the USB chain
@@ -133,17 +133,7 @@ _SerialUSB::operator bool() {
133133 return rv;
134134}
135135
136- /* Key code for writing PRCR register. */
137- #define BSP_PRV_PRCR_KEY (0xA500U )
138- #define BSP_PRV_PRCR_PRC1_UNLOCK ((BSP_PRV_PRCR_KEY) | 0x2U )
139- #define BSP_PRV_PRCR_LOCK ((BSP_PRV_PRCR_KEY) | 0x0U )
140136
141- #ifdef NO_BACKUP_REGISTERS
142- #define BOOT_DOUBLE_TAP_DATA (*((volatile uint32_t *)0x20007FF0 ))
143- #else
144- #define BOOT_DOUBLE_TAP_DATA (*((volatile uint32_t *) &R_SYSTEM->VBTBKR[0 ]))
145- #endif
146- #define DOUBLE_TAP_MAGIC 0x07738135
147137
148138int _SerialUSB::_bps, _SerialUSB::_bits, _SerialUSB::_parity, _SerialUSB::_stop;
149139bool _SerialUSB::_dtr, _SerialUSB::_rts;
@@ -154,12 +144,7 @@ static void CheckSerialReset() {
154144 #endif
155145
156146 if ((_SerialUSB::_bps == 1200 ) && (! _SerialUSB::_dtr)) {
157- R_SYSTEM->PRCR = (uint16_t ) BSP_PRV_PRCR_PRC1_UNLOCK;
158- BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
159- R_SYSTEM->PRCR = (uint16_t ) BSP_PRV_PRCR_LOCK;
160- ((R_USB_FS0_Type*)R_USB_FS0_BASE)->SYSCFG_b .DPRPU = 0 ;
161- NVIC_SystemReset ();
162- while (1 ); // WDT will fire here
147+ goBootloader ();
163148 }
164149}
165150
@@ -223,4 +208,4 @@ void arduino::serialEventRun(void) {
223208 if (serialEvent && SerialUSB.available ()) {
224209 serialEvent ();
225210 }
226- }
211+ }
0 commit comments