From 7f45f1fc0d5923eb9bb34267b3591553e7922329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 30 Apr 2017 04:27:07 +0200 Subject: [PATCH] Implement TestAction_DisableUsb --- right/src/usb_report_updater.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 32ab7d7..f8f0b0d 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -73,6 +73,17 @@ void processMouseAction(key_action_t action) void processTestAction(key_action_t testAction) { switch (testAction.test.testAction) { + case TestAction_DisableUsb: + if (kStatus_USB_Success != USB_DeviceClassDeinit(CONTROLLER_ID)) { + return; + } + // Make sure we are clocking to the peripheral to ensure there are no bus errors + if (SIM->SCGC4 & SIM_SCGC4_USBOTG_MASK) { + NVIC_DisableIRQ(USB0_IRQn); // Disable the USB interrupt + NVIC_ClearPendingIRQ(USB0_IRQn); // Clear any pending interrupts on USB + SIM->SCGC4 &= ~SIM_SCGC4_USBOTG_MASK; // Turn off clocking to USB + } + break; case TestAction_DisableI2c: TestStates.disableI2c = true; break;