diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp index 34a33b14..c32bf3ba 100644 --- a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp +++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp @@ -238,6 +238,11 @@ void Model100::enableHardwareTestMode() { KeyScanner::setKeyscanInterval(2); } +void Model100::rebootBootloader() { + USBCore().disconnect(); + NVIC_SystemReset(); +} + #endif } // namespace keyboardio diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.h b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.h index bd6ebd08..5e666c45 100644 --- a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.h +++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.h @@ -43,6 +43,8 @@ struct cRGB { #include "kaleidoscope/driver/keyscanner/Base.h" #include "kaleidoscope/driver/led/Base.h" #include "kaleidoscope/driver/storage/GD32Flash.h" +#include "kaleidoscope/driver/mcu/GD32.h" + namespace kaleidoscope { namespace device { @@ -145,6 +147,9 @@ struct Model100Props : public kaleidoscope::device::BaseProps { typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader; static constexpr const char *short_name = "kbio100"; + + typedef kaleidoscope::driver::mcu::GD32Props MCUProps; + typedef kaleidoscope::driver::mcu::GD32 MCU; }; #ifndef KALEIDOSCOPE_VIRTUAL_BUILD @@ -156,7 +161,7 @@ class Model100 : public kaleidoscope::device::Base { auto serialPort() -> decltype(Serial) & { return Serial; } - + static void rebootBootloader(); static void enableHardwareTestMode(); }; diff --git a/src/kaleidoscope/driver/mcu/GD32.h b/src/kaleidoscope/driver/mcu/GD32.h new file mode 100644 index 00000000..001b2d9c --- /dev/null +++ b/src/kaleidoscope/driver/mcu/GD32.h @@ -0,0 +1,53 @@ +/* -*- mode: c++ -*- + * driver::MCU::GD32 -- GD32 MCU driver for Kaleidoscope, initially targeting the GD32F303 series + * Copyright (C) 2019, 2020 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +#include // NVIC_Reset +#include // For connect, disconnect, USBCore +#include "kaleidoscope/driver/mcu/Base.h" // for Base, BaseProps + +namespace kaleidoscope { +namespace driver { +namespace mcu { + +struct GD32Props : public kaleidoscope::driver::mcu::BaseProps { +}; + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD +template +class GD32 : public kaleidoscope::driver::mcu::Base<_Props> { + public: + void detachFromHost() { + USBCore().disconnect(); + } + void attachToHost() { + USBCore().connect(); + } + + + void setup() { + } +}; +#else +template +class GD32 : public kaleidoscope::driver::mcu::Base<_Props> {}; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD + +} // namespace mcu +} // namespace driver +} // namespace kaleidoscope