add SW reset (#107)

This commit is contained in:
tomaszduda23
2022-09-12 11:53:52 +02:00
committed by GitHub
parent ce43938d28
commit 615863a848
7 changed files with 106 additions and 3 deletions

View File

@@ -73,4 +73,11 @@ namespace DRIVERS {
}
}
Board* Factory::makeBoard(type _type) {
switch (_type) {
default:
return new Board(DRIVERS::DUMMY);
}
}
}

View File

@@ -0,0 +1,38 @@
/*****************************************************************************
# #
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2022 Maxim Devaev <mdevaev@gmail.com> #
# #
# 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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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 <https://www.gnu.org/licenses/>. #
# #
*****************************************************************************/
#pragma once
#include "board.h"
namespace DRIVERS {
class BoardStm32 : public Board {
public:
BoardStm32() : Board(BOARD){
}
void reset() override {
nvic_sys_reset();
}
};
}

View File

@@ -26,6 +26,7 @@
#include "usb/mouse-absolute-stm32.h"
#include "usb/mouse-relative-stm32.h"
#include "backup-register.h"
#include "board-stm32.h"
#ifndef __STM32F1__
# error "Only STM32F1 is supported"
@@ -72,4 +73,14 @@ namespace DRIVERS {
return new Storage(DRIVERS::DUMMY);
}
}
Board* Factory::makeBoard(type _type) {
switch (_type) {
case BOARD:
return new BoardStm32();
default:
return new Board(DRIVERS::DUMMY);
}
}
}

32
hid/lib/drivers/board.h Normal file
View File

@@ -0,0 +1,32 @@
/*****************************************************************************
# #
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2022 Maxim Devaev <mdevaev@gmail.com> #
# #
# 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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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 <https://www.gnu.org/licenses/>. #
# #
*****************************************************************************/
#pragma once
#include "driver.h"
namespace DRIVERS {
struct Board : public Driver {
using Driver::Driver;
virtual void reset() {}
};
}

View File

@@ -34,6 +34,7 @@ namespace DRIVERS {
USB_KEYBOARD,
PS2_KEYBOARD,
NON_VOLATILE_STORAGE,
BOARD,
};
class Driver {

View File

@@ -24,6 +24,7 @@
#include "keyboard.h"
#include "mouse.h"
#include "storage.h"
#include "board.h"
namespace DRIVERS {
@@ -31,5 +32,6 @@ namespace DRIVERS {
static Keyboard *makeKeyboard(type _type);
static Mouse *makeMouse(type _type);
static Storage* makeStorage(type _type);
static Board* makeBoard(type _type);
};
}