From a3cecb852cc21f922953c14c81009d57661ccbd8 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 12:33:22 +1100 Subject: [PATCH 1/7] Update make_translation.py --- Translations/make_translation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Translations/make_translation.py b/Translations/make_translation.py index 217f1da2..cdb4bf4b 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -148,6 +148,7 @@ def get_power_source_list() -> List[str]: "DC", "QC", "PD", + "PD No VBus", ] From 3c83b59b53bf783a626c4185f61ea6f70706e330 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 13:14:53 +1100 Subject: [PATCH 2/7] Expose Vbus --- source/Core/Drivers/USBPD.cpp | 11 +++++++++++ source/Core/Drivers/USBPD.h | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/Core/Drivers/USBPD.cpp b/source/Core/Drivers/USBPD.cpp index c2d7abef..d992763b 100644 --- a/source/Core/Drivers/USBPD.cpp +++ b/source/Core/Drivers/USBPD.cpp @@ -67,6 +67,17 @@ bool USBPowerDelivery::fusbPresent() { return detectionState == 1; } +bool USBPowerDelivery::isVBUSConnected() { + // Check the status reg + + FUSB302::fusb_status status; + if (fusb.fusb_get_status(&status)) { + return status.status0 & 0x80; + } + // As we are using this to detect the mod fail safe + return true; +} + bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) { /* Get the number of PDOs */ diff --git a/source/Core/Drivers/USBPD.h b/source/Core/Drivers/USBPD.h index bd41297b..7e27dbea 100644 --- a/source/Core/Drivers/USBPD.h +++ b/source/Core/Drivers/USBPD.h @@ -16,9 +16,9 @@ public: static void PPSTimerCallback(); // PPS Timer static void IRQOccured(); // Thread callback that an irq occured static void step(); // Iterate the step machine - static bool negotiationHasWorked(); // - static uint8_t getStateNumber(); // - + static bool negotiationHasWorked(); // Has PD negotiation worked (are we in a PD contract) + static uint8_t getStateNumber(); // Debugging - Get the internal state number + static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302 private: // static int detectionState; From 265e152c182b0eb90213f8fa5dee56b54d35df36 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 13:15:01 +1100 Subject: [PATCH 3/7] Add to debug menu --- source/Core/Threads/GUIThread.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 940cde55..60570b7b 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -731,18 +731,23 @@ void showDebugMenu(void) { sourceNumber = 0; } else { // We are not powered via DC, so want to display the appropriate state for PD or QC - bool poweredbyPD = false; + bool poweredbyPD = false; + bool pdHasVBUSConnected = false; #if POW_PD if (USBPowerDelivery::fusbPresent()) { // We are PD capable if (USBPowerDelivery::negotiationComplete()) { // We are powered via PD - poweredbyPD = true; + poweredbyPD = true; + pdHasVBUSConnected = USBPowerDelivery::isVBUSConnected(); } } #endif if (poweredbyPD) { sourceNumber = 2; + if (!pdHasVBUSConnected) { + sourceNumber = 3; + } } else { sourceNumber = 1; } From a2918ae8a4736779c2ee988dd8cb166513b9c557 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 14:41:49 +1100 Subject: [PATCH 4/7] Update usb-pd --- source/Core/Drivers/usb-pd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Drivers/usb-pd b/source/Core/Drivers/usb-pd index 4c5a5625..b3859826 160000 --- a/source/Core/Drivers/usb-pd +++ b/source/Core/Drivers/usb-pd @@ -1 +1 @@ -Subproject commit 4c5a5625bab7191b77147e1ef1bd6e2705f9e640 +Subproject commit b38598261df4f705bcbd37cdd5dcccfaa5ab7b4a From 1969d860c7b72a7e35195c2866840a46722af94b Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 14:41:52 +1100 Subject: [PATCH 5/7] Update USBPD.cpp --- source/Core/Drivers/USBPD.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/source/Core/Drivers/USBPD.cpp b/source/Core/Drivers/USBPD.cpp index d992763b..d1093dde 100644 --- a/source/Core/Drivers/USBPD.cpp +++ b/source/Core/Drivers/USBPD.cpp @@ -67,16 +67,7 @@ bool USBPowerDelivery::fusbPresent() { return detectionState == 1; } -bool USBPowerDelivery::isVBUSConnected() { - // Check the status reg - - FUSB302::fusb_status status; - if (fusb.fusb_get_status(&status)) { - return status.status0 & 0x80; - } - // As we are using this to detect the mod fail safe - return true; -} +bool USBPowerDelivery::isVBUSConnected() { return fusb.isVBUSConnected(); } bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) { From 0735d4f7042b639df8459860084bee56a4272936 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 14:42:01 +1100 Subject: [PATCH 6/7] Update GUIThread.cpp --- source/Core/Threads/GUIThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index 60570b7b..2e8c7803 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -732,7 +732,7 @@ void showDebugMenu(void) { } else { // We are not powered via DC, so want to display the appropriate state for PD or QC bool poweredbyPD = false; - bool pdHasVBUSConnected = false; + bool pdHasVBUSConnected = true; #if POW_PD if (USBPowerDelivery::fusbPresent()) { // We are PD capable From fb297704b34123e3fcf9ca8953f87a98ad7f4f10 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sun, 6 Feb 2022 14:45:40 +1100 Subject: [PATCH 7/7] Update make_translation.py --- Translations/make_translation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Translations/make_translation.py b/Translations/make_translation.py index cdb4bf4b..e6be313a 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -147,7 +147,7 @@ def get_power_source_list() -> List[str]: return [ "DC", "QC", - "PD", + "PD W. VBus", "PD No VBus", ]