From c96ef841396acdf5318af8c5e05c19d9fb94f90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 21 Mar 2018 17:15:16 +0100 Subject: [PATCH] [usb] Leave DFU mode on Back key press. Change-Id: Icd031097f678a19729f12453db18cac2e08c6f05 --- ion/src/device/usb/Makefile | 2 ++ ion/src/device/usb/calculator.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ion/src/device/usb/Makefile b/ion/src/device/usb/Makefile index fafc1a44a..361ffadc1 100644 --- a/ion/src/device/usb/Makefile +++ b/ion/src/device/usb/Makefile @@ -33,6 +33,8 @@ usb_objs += liba/src/memset.o usb_objs += liba/src/memcpy.o usb_objs += libaxx/src/cxxabi/pure_virtual.o usb_objs += ion/src/device/usb/boot.o +usb_objs += ion/src/device/keyboard.o +usb_objs += ion/src/device/device.o ion/src/device/usb/dfu.elf: LDFLAGS = --gc-sections -T ion/src/device/boot/dfu.ld ion/src/device/usb/dfu.elf: $(usb_objs) diff --git a/ion/src/device/usb/calculator.cpp b/ion/src/device/usb/calculator.cpp index a5449ac0f..c63262d0a 100644 --- a/ion/src/device/usb/calculator.cpp +++ b/ion/src/device/usb/calculator.cpp @@ -1,5 +1,6 @@ #include "calculator.h" #include "../regs/regs.h" +#include namespace Ion { namespace USB { @@ -11,7 +12,9 @@ void Calculator::Poll() { } Calculator c; - while (true) { + // Leave DFU mode when pressing the Back key. + // TODO also leave on detach or when unplugging + while (!Ion::Keyboard::scan().keyDown(Ion::Keyboard::Key::A6)) { c.poll(); } }