File tree 1 file changed +20
-3
lines changed
hardware/arduino/avr/cores/arduino
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)
92
92
// with a relatively long period so it can finish housekeeping tasks
93
93
// like servicing endpoints before the sketch ends
94
94
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
+
95
102
// We check DTR state to determine if host port is open (bit 0 of lineState).
96
103
if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01 ) == 0 )
97
104
{
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
100
113
wdt_enable (WDTO_120MS);
101
114
}
102
115
else
@@ -108,7 +121,11 @@ bool CDC_Setup(USBSetup& setup)
108
121
109
122
wdt_disable ();
110
123
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
112
129
}
113
130
}
114
131
return true ;
You can’t perform that action at this time.
0 commit comments