From cd41471643c8f3c755e7c435c79b5f1720a1dad6 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 25 Mar 2022 18:57:53 -0700 Subject: [PATCH 1/4] wip model100 reboot --- .../src/kaleidoscope/device/keyboardio/Model100.cpp | 4 ++++ .../src/kaleidoscope/device/keyboardio/Model100.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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..8b13028f 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,10 @@ void Model100::enableHardwareTestMode() { KeyScanner::setKeyscanInterval(2); } +void Model100::rebootBootloader() { + 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..99b08f6a 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 @@ -156,7 +156,7 @@ class Model100 : public kaleidoscope::device::Base { auto serialPort() -> decltype(Serial) & { return Serial; } - + static void rebootBootloader(); static void enableHardwareTestMode(); }; From 4ca969092b623ec17005c82f53a8f6a5d25c330b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 28 Mar 2022 12:18:24 -0700 Subject: [PATCH 2/4] Add an initial stab at a GD32 mcu support driver --- src/kaleidoscope/driver/mcu/GD32.h | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/kaleidoscope/driver/mcu/GD32.h diff --git a/src/kaleidoscope/driver/mcu/GD32.h b/src/kaleidoscope/driver/mcu/GD32.h new file mode 100644 index 00000000..b9adafe6 --- /dev/null +++ b/src/kaleidoscope/driver/mcu/GD32.h @@ -0,0 +1,51 @@ +/* -*- 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 "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 From 50008ddd5a4f64ee85e3a27881294831b41748a0 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 28 Mar 2022 12:36:38 -0700 Subject: [PATCH 3/4] Implement a "reset" method for the Model 100 --- .../src/kaleidoscope/device/keyboardio/Model100.cpp | 1 + .../src/kaleidoscope/device/keyboardio/Model100.h | 5 +++++ src/kaleidoscope/driver/mcu/GD32.h | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) 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 8b13028f..a1353d39 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 @@ -239,6 +239,7 @@ void Model100::enableHardwareTestMode() { } void Model100::rebootBootloader() { + USBCore().disconnect(); NVIC_SystemReset(); } 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 99b08f6a..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 diff --git a/src/kaleidoscope/driver/mcu/GD32.h b/src/kaleidoscope/driver/mcu/GD32.h index b9adafe6..b6ac7b8d 100644 --- a/src/kaleidoscope/driver/mcu/GD32.h +++ b/src/kaleidoscope/driver/mcu/GD32.h @@ -17,6 +17,8 @@ #pragma once +#include // NVIC_Reset +#include // For connect, disconnect, USBCore #include "kaleidoscope/driver/mcu/Base.h" // for Base, BaseProps namespace kaleidoscope { @@ -31,10 +33,10 @@ template class GD32 : public kaleidoscope::driver::mcu::Base<_Props> { public: void detachFromHost() { - USBCore::disconnect(); + USBCore().disconnect(); } void attachToHost() { - USBCore::connect(); + USBCore().connect(); } From faf132839dffb8a2cb990e120c5a2a7dade4b525 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 28 Mar 2022 12:37:11 -0700 Subject: [PATCH 4/4] clang-format --- .../src/kaleidoscope/device/keyboardio/Model100.cpp | 4 ++-- src/kaleidoscope/driver/mcu/GD32.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 a1353d39..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 @@ -239,8 +239,8 @@ void Model100::enableHardwareTestMode() { } void Model100::rebootBootloader() { - USBCore().disconnect(); - NVIC_SystemReset(); + USBCore().disconnect(); + NVIC_SystemReset(); } #endif diff --git a/src/kaleidoscope/driver/mcu/GD32.h b/src/kaleidoscope/driver/mcu/GD32.h index b6ac7b8d..001b2d9c 100644 --- a/src/kaleidoscope/driver/mcu/GD32.h +++ b/src/kaleidoscope/driver/mcu/GD32.h @@ -17,8 +17,8 @@ #pragma once -#include // NVIC_Reset -#include // For connect, disconnect, USBCore +#include // NVIC_Reset +#include // For connect, disconnect, USBCore #include "kaleidoscope/driver/mcu/Base.h" // for Base, BaseProps namespace kaleidoscope {