From ff82ca26f2cf6e1f5a29965a38f0f440d1bf57f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 30 Mar 2018 15:56:06 +0200 Subject: [PATCH] [usb] Enable the USB core on calculator plugged. Change-Id: I5b8ab068936524e775bb77a4569a2601e5a9844a --- apps/usb_timer.cpp | 3 +++ ion/include/ion/usb.h | 1 + ion/src/device/usb.cpp | 4 ++++ ion/src/shared/dummy/usb.cpp | 3 +++ 4 files changed, 11 insertions(+) diff --git a/apps/usb_timer.cpp b/apps/usb_timer.cpp index d14fa8965..d38599db2 100644 --- a/apps/usb_timer.cpp +++ b/apps/usb_timer.cpp @@ -12,6 +12,9 @@ USBTimer::USBTimer(AppsContainer * container) : bool USBTimer::fire() { bool needRedrawing = false; if (Ion::USB::isPlugged()) { + if (!m_previousPluggedState) { + Ion::USB::removeSoftDisconnect(); + } if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) { m_container->displayExamModePopUp(false); needRedrawing = true; diff --git a/ion/include/ion/usb.h b/ion/include/ion/usb.h index f30aacbaa..db478b4cc 100644 --- a/ion/include/ion/usb.h +++ b/ion/include/ion/usb.h @@ -5,6 +5,7 @@ namespace Ion { namespace USB { bool isPlugged(); +void removeSoftDisconnect(); void DFU(); } diff --git a/ion/src/device/usb.cpp b/ion/src/device/usb.cpp index 84ee6838c..f33fa1b66 100644 --- a/ion/src/device/usb.cpp +++ b/ion/src/device/usb.cpp @@ -13,6 +13,10 @@ bool isPlugged() { return Device::VbusPin.group().IDR()->get(Device::VbusPin.pin()); } +void removeSoftDisconnect() { + OTG.DCTL()->setSDIS(false); +} + } } diff --git a/ion/src/shared/dummy/usb.cpp b/ion/src/shared/dummy/usb.cpp index bc077012e..aad90aed5 100644 --- a/ion/src/shared/dummy/usb.cpp +++ b/ion/src/shared/dummy/usb.cpp @@ -4,5 +4,8 @@ bool Ion::USB::isPlugged() { return false; } +void Ion::USB::removeSoftDisconnect() { +} + void Ion::USB::DFU() { }