From d248022f0884a95ffeb6f1e1c6108b292777fd75 Mon Sep 17 00:00:00 2001 From: rechrtb Date: Thu, 18 Jul 2024 00:07:30 +0900 Subject: [PATCH] Fix issue with checking if already in host mode --- src/TinyUsbInterface.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/TinyUsbInterface.cpp b/src/TinyUsbInterface.cpp index 761551b9..1df7f6dd 100644 --- a/src/TinyUsbInterface.cpp +++ b/src/TinyUsbInterface.cpp @@ -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;