Skip to content

Commit

Permalink
Fix issue with checking if already in host mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rechrtb committed Sep 9, 2024
1 parent d97643e commit d248022
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/TinyUsbInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,13 @@ bool CoreUsbSetHostMode(bool hostMode, const StringRef& reply)
return false;
}

if (hostMode && digitalRead(UsbVbusDetect))
if (!CoreUsbIsHostMode() && hostMode && digitalRead(UsbVbusDetect))
{
reply.printf("Unable to change to host mode, board plugged in to computer\n");
return false;
}

if (hostMode == CoreUsbIsHostMode())
{
reply.printf("Already in %s mode\n", hostMode ? "host" : "device");
}
else
if (hostMode != CoreUsbIsHostMode())
{
CoreUsbStop();
changingMode = true;
Expand Down

0 comments on commit d248022

Please sign in to comment.