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 Oct 4, 2024
1 parent 8e5fd2e commit d837026
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 d837026

Please sign in to comment.