From e706ffaa8979c923e9bc2a68c93028fe387d02c6 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 8 Jun 2018 09:13:47 +0200 Subject: [PATCH] Implement detachFromHost() and attachToHost() Signed-off-by: Gergely Nagy --- src/kaleidoscope/hardware/ErgoDox.cpp | 8 ++++++++ src/kaleidoscope/hardware/ErgoDox.h | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/kaleidoscope/hardware/ErgoDox.cpp b/src/kaleidoscope/hardware/ErgoDox.cpp index 43965cde..7fc5728e 100644 --- a/src/kaleidoscope/hardware/ErgoDox.cpp +++ b/src/kaleidoscope/hardware/ErgoDox.cpp @@ -217,6 +217,14 @@ void ErgoDox::debounceRow(uint8_t change, uint8_t row) { } } +void ErgoDox::detachFromHost() { + UDCON |= (1 << DETACH); +} + +void ErgoDox::attachToHost() { + UDCON &= ~(1 << DETACH); +} + } } diff --git a/src/kaleidoscope/hardware/ErgoDox.h b/src/kaleidoscope/hardware/ErgoDox.h index f9d7ae7c..9a11e0cd 100644 --- a/src/kaleidoscope/hardware/ErgoDox.h +++ b/src/kaleidoscope/hardware/ErgoDox.h @@ -63,6 +63,17 @@ class ErgoDox { void actOnMatrixScan(void); void setup(); + /** Detaching from / attaching to the host. + * + * These two functions should detach the device from (or attach it to) the + * host, preferably without rebooting the device. Their purpose is to allow + * one to do some configuration inbetween, so the re-attach happens with + * different properties. The device remains powered between these operations, + * only the connection to the host gets severed. + */ + void detachFromHost(); + void attachToHost(); + /* Key masking * ----------- *