File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
hardware/arduino/avr/cores/arduino Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -92,11 +92,24 @@ bool CDC_Setup(USBSetup& setup)
9292 // with a relatively long period so it can finish housekeeping tasks
9393 // like servicing endpoints before the sketch ends
9494
95+ #ifndef MAGIC_KEY
96+ #define MAGIC_KEY 0x7777
97+ #endif
98+ #ifndef MAGIC_KEY_POS
99+ #define MAGIC_KEY_POS 0x0800
100+ #endif
101+
95102 // We check DTR state to determine if host port is open (bit 0 of lineState).
96103 if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01 ) == 0 )
97104 {
98- *(uint16_t *)(RAMEND-1 ) = *(uint16_t *)0x0800 ;
99- *(uint16_t *)0x0800 = 0x7777 ;
105+ #if MAGIC_KEY_POS != (RAMEND-1)
106+ *(uint16_t *)(RAMEND-1 ) = *(uint16_t *)MAGIC_KEY_POS;
107+ *(uint16_t *)MAGIC_KEY_POS = MAGIC_KEY;
108+ #else
109+ // for future boards save the key in the inproblematic RAMEND
110+ // which is reserved for the main() return value (which will never return)
111+ *(uint16_t *)MAGIC_KEY_POS = MAGIC_KEY;
112+ #endif
100113 wdt_enable (WDTO_120MS);
101114 }
102115 else
@@ -108,7 +121,11 @@ bool CDC_Setup(USBSetup& setup)
108121
109122 wdt_disable ();
110123 wdt_reset ();
111- *(uint16_t *)0x0800 = *(uint16_t *)(RAMEND-1 );
124+ #if MAGIC_KEY_POS != (RAMEND-1)
125+ *(uint16_t *)MAGIC_KEY_POS = *(uint16_t *)(RAMEND-1 );
126+ #else
127+ *(uint16_t *)MAGIC_KEY_POS = 0x0000 ;
128+ #endif
112129 }
113130 }
114131 return true ;
You can’t perform that action at this time.
0 commit comments