@@ -80,35 +80,39 @@ bool WEAK CDC_Setup(Setup& setup)
80
80
if (CDC_SET_LINE_CODING == r)
81
81
{
82
82
USB_RecvControl ((void *)&_usbLineInfo,7 );
83
- return true ;
84
83
}
85
84
86
85
if (CDC_SET_CONTROL_LINE_STATE == r)
87
86
{
88
87
_usbLineInfo.lineState = setup.wValueL ;
88
+ }
89
89
90
+ if (CDC_SET_LINE_CODING == r || CDC_SET_CONTROL_LINE_STATE == r)
91
+ {
90
92
// auto-reset into the bootloader is triggered when the port, already
91
93
// open at 1200 bps, is closed. this is the signal to start the watchdog
92
94
// with a relatively long period so it can finish housekeeping tasks
93
95
// like servicing endpoints before the sketch ends
94
- if (1200 == _usbLineInfo.dwDTERate ) {
95
- // We check DTR state to determine if host port is open (bit 0 of lineState).
96
- if ((_usbLineInfo.lineState & 0x01 ) == 0 ) {
97
- *(uint16_t *)0x0800 = 0x7777 ;
98
- wdt_enable (WDTO_120MS);
99
- } else {
100
- // Most OSs do some intermediate steps when configuring ports and DTR can
101
- // twiggle more than once before stabilizing.
102
- // To avoid spurious resets we set the watchdog to 250ms and eventually
103
- // cancel if DTR goes back high.
104
-
105
- wdt_disable ();
106
- wdt_reset ();
107
- *(uint16_t *)0x0800 = 0x0 ;
108
- }
96
+
97
+ // We check DTR state to determine if host port is open (bit 0 of lineState).
98
+ if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01 ) == 0 )
99
+ {
100
+ *(uint16_t *)0x0800 = 0x7777 ;
101
+ wdt_enable (WDTO_120MS);
102
+ }
103
+ else
104
+ {
105
+ // Most OSs do some intermediate steps when configuring ports and DTR can
106
+ // twiggle more than once before stabilizing.
107
+ // To avoid spurious resets we set the watchdog to 250ms and eventually
108
+ // cancel if DTR goes back high.
109
+
110
+ wdt_disable ();
111
+ wdt_reset ();
112
+ *(uint16_t *)0x0800 = 0x0 ;
109
113
}
110
- return true ;
111
114
}
115
+ return true ;
112
116
}
113
117
return false ;
114
118
}
0 commit comments