Skip to content
Snippets Groups Projects
Commit b11b8e8b authored by Cristian Maglie's avatar Cristian Maglie Committed by Cristian Maglie
Browse files

Fix on USB-CDC 1200bps-touch reset condition

Some serial libraries opens the serial port BEFORE setting the baudrate.
This patch allows finer control on the reset condition, since it's
checked on open/close (DTR) AND on serial port parameter change.
parent dd50d5c4
No related branches found
No related tags found
No related merge requests found
...@@ -119,21 +119,25 @@ bool WEAK CDC_Setup(Setup& setup) ...@@ -119,21 +119,25 @@ bool WEAK CDC_Setup(Setup& setup)
if (CDC_SET_LINE_CODING == r) if (CDC_SET_LINE_CODING == r)
{ {
USBD_RecvControl((void*)&_usbLineInfo,7); USBD_RecvControl((void*)&_usbLineInfo,7);
return false;
} }
if (CDC_SET_CONTROL_LINE_STATE == r) if (CDC_SET_CONTROL_LINE_STATE == r)
{ {
_usbLineInfo.lineState = setup.wValueL; _usbLineInfo.lineState = setup.wValueL;
}
if (CDC_SET_LINE_CODING == r || CDC_SET_CONTROL_LINE_STATE == r)
{
// auto-reset into the bootloader is triggered when the port, already // auto-reset into the bootloader is triggered when the port, already
// open at 1200 bps, is closed. // open at 1200 bps, is closed. We check DTR state to determine if host
if (1200 == _usbLineInfo.dwDTERate) // port is open (bit 0 of lineState).
if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0)
{
initiateReset(250);
}
else
{ {
// We check DTR state to determine if host port is open (bit 0 of lineState). cancelReset();
if ((_usbLineInfo.lineState & 0x01) == 0)
initiateReset(250);
else
cancelReset();
} }
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment