From b6fd6b02f5755c01a2eab5c0cd3b308a80a6e531 Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Wed, 20 Nov 2019 22:23:22 +0100 Subject: [PATCH] Enabled virtual build for KBDFans/KBD4x Signed-off-by: Florian Fleissner --- src/kaleidoscope/device/avr/pins_and_ports.h | 16 ++++++++++++---- src/kaleidoscope/device/kbdfans/KBD4x.cpp | 2 ++ src/kaleidoscope/device/kbdfans/KBD4x.h | 4 ++++ .../driver/bootloader/avr/Caterina.h | 3 ++- src/kaleidoscope/driver/bootloader/avr/FLIP.h | 3 ++- src/kaleidoscope/driver/bootloader/avr/HalfKay.h | 3 ++- src/kaleidoscope/driver/keyscanner/ATmega.h | 15 +++++++++++++++ 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/kaleidoscope/device/avr/pins_and_ports.h b/src/kaleidoscope/device/avr/pins_and_ports.h index ba42f7ba..d2d566cc 100644 --- a/src/kaleidoscope/device/avr/pins_and_ports.h +++ b/src/kaleidoscope/device/avr/pins_and_ports.h @@ -21,7 +21,7 @@ #pragma once -#ifndef __ASSEMBLER__ +#if !defined(__ASSEMBLER__) && !defined(KALEIDOSCOPE_VIRTUAL_BUILD) #include #endif #define PORT_SHIFTER 4 // this may be 4 for all AVR chips @@ -55,13 +55,22 @@ #define PINC_ADDRESS 0x3 #define PINB_ADDRESS 0x6 #define PINA_ADDRESS 0x9 -#else +#elif !defined(KALEIDOSCOPE_VIRTUAL_BUILD) #error "Pins are not defined" #endif /* I/O pins */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin) - +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#define PINDEF(port, pin) 0 +#define PORTA +#define PORTB +#define PORTC +#define PORTD +#define PORTE +#define PORTF +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef PORTA #define PIN_A0 PINDEF(A, 0) @@ -124,7 +133,6 @@ #define PIN_F7 PINDEF(F, 7) #endif - /* converting pins to ports */ enum { PIN_OFFSET, DDR_OFFSET, PORT_OFFSET}; diff --git a/src/kaleidoscope/device/kbdfans/KBD4x.cpp b/src/kaleidoscope/device/kbdfans/KBD4x.cpp index 7657edc5..788100cb 100644 --- a/src/kaleidoscope/device/kbdfans/KBD4x.cpp +++ b/src/kaleidoscope/device/kbdfans/KBD4x.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifdef ARDUINO_AVR_KBD4X #include @@ -32,3 +33,4 @@ ATMEGA_KEYSCANNER_BOILERPLATE kaleidoscope::device::kbdfans::KBD4x &KBD4x = kaleidoscope_internal::device; #endif +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/src/kaleidoscope/device/kbdfans/KBD4x.h b/src/kaleidoscope/device/kbdfans/KBD4x.h index c0a28c68..d5d83d37 100644 --- a/src/kaleidoscope/device/kbdfans/KBD4x.h +++ b/src/kaleidoscope/device/kbdfans/KBD4x.h @@ -42,6 +42,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps { typedef kaleidoscope::driver::bootloader::avr::FLIP Bootloader; }; +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard { public: KBD4x() { @@ -49,6 +50,9 @@ class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard { mcu_.disableClockDivision(); } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +class KBD4x; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define PER_KEY_DATA(dflt, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \ diff --git a/src/kaleidoscope/driver/bootloader/avr/Caterina.h b/src/kaleidoscope/driver/bootloader/avr/Caterina.h index 1d45939c..52447cb5 100644 --- a/src/kaleidoscope/driver/bootloader/avr/Caterina.h +++ b/src/kaleidoscope/driver/bootloader/avr/Caterina.h @@ -20,6 +20,7 @@ #ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -53,7 +54,7 @@ class Caterina : public kaleidoscope::driver::bootloader::Base { } }; #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD -class Caterina; +typedef bootloader::None Caterina; #endif // #ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/bootloader/avr/FLIP.h b/src/kaleidoscope/driver/bootloader/avr/FLIP.h index 29af58c1..c4e993e1 100644 --- a/src/kaleidoscope/driver/bootloader/avr/FLIP.h +++ b/src/kaleidoscope/driver/bootloader/avr/FLIP.h @@ -25,6 +25,7 @@ #endif #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -38,7 +39,7 @@ class FLIP : public kaleidoscope::driver::bootloader::Base { static void rebootBootloader(); }; #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD -class FLIP; +typedef bootloader::None FLIP; #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h index 7386122f..ae8d1268 100644 --- a/src/kaleidoscope/driver/bootloader/avr/HalfKay.h +++ b/src/kaleidoscope/driver/bootloader/avr/HalfKay.h @@ -20,6 +20,7 @@ #ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#include "kaleidoscope/driver/bootloader/None.h" #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { @@ -69,7 +70,7 @@ class HalfKay : public kaleidoscope::driver::bootloader::Base { } }; #else -class HalfKay; +typedef bootloader::None HalfKay; #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } diff --git a/src/kaleidoscope/driver/keyscanner/ATmega.h b/src/kaleidoscope/driver/keyscanner/ATmega.h index bf8e8ba3..8db7eaf8 100644 --- a/src/kaleidoscope/driver/keyscanner/ATmega.h +++ b/src/kaleidoscope/driver/keyscanner/ATmega.h @@ -22,17 +22,26 @@ #include "kaleidoscope/macro_helpers.h" #include "kaleidoscope/driver/keyscanner/Base.h" +#include "kaleidoscope/driver/keyscanner/None.h" + #include "kaleidoscope/device/avr/pins_and_ports.h" +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ROW_PIN_LIST(...) __VA_ARGS__ #define COL_PIN_LIST(...) __VA_ARGS__ +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), NUM_ARGS(COL_PINS_)); \ static constexpr uint8_t matrix_row_pins[matrix_rows] = ROW_PINS_; \ static constexpr uint8_t matrix_col_pins[matrix_columns] = COL_PINS_; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +#define ATMEGA_KEYSCANNER_PROPS(ROW_PINS_, COL_PINS_) \ + KEYSCANNER_PROPS(NUM_ARGS(ROW_PINS_), NUM_ARGS(COL_PINS_)); +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #define ATMEGA_KEYSCANNER_BOILERPLATE \ KEYSCANNER_PROPS_BOILERPLATE(kaleidoscope::Device::KeyScannerProps); \ @@ -66,6 +75,8 @@ struct ATmegaProps: kaleidoscope::driver::keyscanner::BaseProps { static constexpr uint8_t matrix_col_pins[] = {}; }; + +#ifndef KALEIDOSCOPE_VIRTUAL_BUILD template class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> { private: @@ -233,6 +244,10 @@ class ATmega: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> { } } }; +#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD +template +class ATmega : public keyscanner::None {}; +#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD } }