Merge pull request #1148 from keyboardio/model100-reboot

Implement "reboot" for the Model 100
pull/1149/head
Gergely Nagy 3 years ago committed by GitHub
commit dc51a0cd61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -238,6 +238,11 @@ void Model100::enableHardwareTestMode() {
KeyScanner::setKeyscanInterval(2);
}
void Model100::rebootBootloader() {
USBCore().disconnect();
NVIC_SystemReset();
}
#endif
} // namespace keyboardio

@ -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<MCUProps> MCU;
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
@ -156,7 +161,7 @@ class Model100 : public kaleidoscope::device::Base<Model100Props> {
auto serialPort() -> decltype(Serial) & {
return Serial;
}
static void rebootBootloader();
static void enableHardwareTestMode();
};

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Arduino.h> // NVIC_Reset
#include <USBCore.h> // 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<typename _Props>
class GD32 : public kaleidoscope::driver::mcu::Base<_Props> {
public:
void detachFromHost() {
USBCore().disconnect();
}
void attachToHost() {
USBCore().connect();
}
void setup() {
}
};
#else
template<typename _Props>
class GD32 : public kaleidoscope::driver::mcu::Base<_Props> {};
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
} // namespace mcu
} // namespace driver
} // namespace kaleidoscope
Loading…
Cancel
Save