Implement a way to detach from / attach to the host

These functions can be used to detach from the host, then re-attach, possibly
with different properties, without having to reboot the device.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 7 years ago
parent f56de510ae
commit fe9c6f8d92

@ -251,4 +251,12 @@ void Model01::setKeyscanInterval(uint8_t interval) {
rightHand.setKeyscanInterval(interval); rightHand.setKeyscanInterval(interval);
} }
void Model01::detachFromHost() {
UDCON |= (1 << DETACH);
}
void Model01::attachToHost() {
UDCON &= ~(1 << DETACH);
}
HARDWARE_IMPLEMENTATION KeyboardHardware; HARDWARE_IMPLEMENTATION KeyboardHardware;

@ -29,6 +29,17 @@ class Model01 {
void rebootBootloader(); void rebootBootloader();
/** 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();
/* These public functions are things supported by the Model 01, but /* These public functions are things supported by the Model 01, but
* aren't necessarily part of the Kaleidoscope API * aren't necessarily part of the Kaleidoscope API
*/ */

Loading…
Cancel
Save