From 17ba4fb8e8d54b8af7b406c193a9cd1db146739d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 28 Aug 2021 12:52:07 +0200 Subject: [PATCH] gd32: Add a GD32Flash storage driver Signed-off-by: Gergely Nagy --- .../src/kaleidoscope/device/gd32/Eval.h | 7 ++- src/kaleidoscope/driver/storage/GD32Flash.h | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/kaleidoscope/driver/storage/GD32Flash.h diff --git a/plugins/Kaleidoscope-Hardware-GD32-Eval/src/kaleidoscope/device/gd32/Eval.h b/plugins/Kaleidoscope-Hardware-GD32-Eval/src/kaleidoscope/device/gd32/Eval.h index eaa1bff2..81ccc265 100644 --- a/plugins/Kaleidoscope-Hardware-GD32-Eval/src/kaleidoscope/device/gd32/Eval.h +++ b/plugins/Kaleidoscope-Hardware-GD32-Eval/src/kaleidoscope/device/gd32/Eval.h @@ -22,12 +22,17 @@ #include #include "kaleidoscope/device/Base.h" +#include "kaleidoscope/driver/storage/GD32Flash.h" namespace kaleidoscope { namespace device { namespace gd32 { -struct EvalProps : kaleidoscope::device::BaseProps { +struct EvalStorageProps: kaleidoscope::driver::storage::GD32FlashProps {}; + +struct EvalProps: kaleidoscope::device::BaseProps { + typedef EvalStorageProps StorageProps; + typedef kaleidoscope::driver::storage::GD32Flash Storage; static constexpr const char *short_name = "GD32Eval"; }; diff --git a/src/kaleidoscope/driver/storage/GD32Flash.h b/src/kaleidoscope/driver/storage/GD32Flash.h new file mode 100644 index 00000000..1a0ae69e --- /dev/null +++ b/src/kaleidoscope/driver/storage/GD32Flash.h @@ -0,0 +1,47 @@ +/* -*- mode: c++ -*- + * kaleidoscope::driver::storage::GD32Flash -- Storage driver with GD32 flash backend + * Copyright (C) 2021 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 + +#if defined(ARDUINO_ARCH_GD32) || defined(KALEIDOSCOPE_VIRTUAL_BUILD) + +#include "kaleidoscope/driver/storage/Base.h" +#include "FlashStorage.h" +#include "FlashAsEEPROM.h" + +namespace kaleidoscope { +namespace driver { +namespace storage { + +struct GD32FlashProps : kaleidoscope::driver::storage::BaseProps { + static constexpr uint16_t length = 10240; +}; + +template +class GD32Flash: public EEPROMClass<_StorageProps::length> { + public: + void setup() { + EEPROMClass<_StorageProps::length>::begin(); + } + void commit() {} +}; + +} // namespace storage +} // namespace driver +} // namespace kaleidoscope + +#endif