From faba5dfdf2f9d87283c8543721dbbe4a6c105155 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 12 Nov 2019 02:00:15 +0100 Subject: [PATCH] Guard a couple of AVR-specific places with an ifdef We have a few AVR-specific things which do not have a guard yet, and cause issues on other architectures. This adds those missing guards to the following places: - The `kaleidoscope::Hardware` base class, which is deprecated, but still exists. As such, it needs to be restricted to AVR devices only (since that's all it supported, non-AVR devices should use the new APIs). - `device/keyboardio/twi` are only used by the Imago at the moment, and is AVR-specific, so guard that too. - Removed an unneeded include from `driver::bootloader::None`, because it doesn't need ``. - `plugin::FirmwareDump` is now restricted to AVR, because that's the only architecture we support dumping the firmware on. Signed-off-by: Gergely Nagy --- src/kaleidoscope/Hardware.h | 4 ++++ src/kaleidoscope/device/keyboardio/twi.c | 4 ++++ src/kaleidoscope/device/keyboardio/twi.h | 3 +++ src/kaleidoscope/driver/bootloader/None.h | 1 - src/kaleidoscope/driver/storage/AVREEPROM.h | 2 +- src/kaleidoscope/plugin/FirmwareDump.cpp | 2 ++ src/kaleidoscope/plugin/FirmwareDump.h | 3 +++ 7 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/kaleidoscope/Hardware.h b/src/kaleidoscope/Hardware.h index 7d846954..8f231c47 100644 --- a/src/kaleidoscope/Hardware.h +++ b/src/kaleidoscope/Hardware.h @@ -21,6 +21,8 @@ #pragma once +#ifdef __AVR__ + #include "kaleidoscope/MatrixAddr.h" #include "kaleidoscope_internal/deprecations.h" @@ -402,3 +404,5 @@ class Hardware { /** @} */ }; } + +#endif diff --git a/src/kaleidoscope/device/keyboardio/twi.c b/src/kaleidoscope/device/keyboardio/twi.c index f1c8eb65..38fe7e59 100644 --- a/src/kaleidoscope/device/keyboardio/twi.c +++ b/src/kaleidoscope/device/keyboardio/twi.c @@ -18,6 +18,8 @@ Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts */ +#ifdef __AVR__ + #define ENABLE_TWI_SLAVE_MODE 0 #include @@ -559,3 +561,5 @@ ISR(TWI_vect) { break; } } + +#endif diff --git a/src/kaleidoscope/device/keyboardio/twi.h b/src/kaleidoscope/device/keyboardio/twi.h index 29cdf16b..e3753519 100644 --- a/src/kaleidoscope/device/keyboardio/twi.h +++ b/src/kaleidoscope/device/keyboardio/twi.h @@ -16,6 +16,8 @@ with this program. If not, see . */ +#ifdef __AVR__ + #ifndef twi_h #define twi_h @@ -51,3 +53,4 @@ void twi_stop(void); void twi_releaseBus(void); #endif +#endif diff --git a/src/kaleidoscope/driver/bootloader/None.h b/src/kaleidoscope/driver/bootloader/None.h index d91fe105..a240ae0a 100644 --- a/src/kaleidoscope/driver/bootloader/None.h +++ b/src/kaleidoscope/driver/bootloader/None.h @@ -17,7 +17,6 @@ #pragma once -#include #include "kaleidoscope/driver/bootloader/Base.h" namespace kaleidoscope { diff --git a/src/kaleidoscope/driver/storage/AVREEPROM.h b/src/kaleidoscope/driver/storage/AVREEPROM.h index 01e0b80b..9871a084 100644 --- a/src/kaleidoscope/driver/storage/AVREEPROM.h +++ b/src/kaleidoscope/driver/storage/AVREEPROM.h @@ -17,7 +17,7 @@ #pragma once -#ifdef ARDUINO_ARCH_AVR +#ifdef __AVR__ #include "kaleidoscope/driver/storage/Base.h" #include diff --git a/src/kaleidoscope/plugin/FirmwareDump.cpp b/src/kaleidoscope/plugin/FirmwareDump.cpp index fc2450a0..04a40f7f 100644 --- a/src/kaleidoscope/plugin/FirmwareDump.cpp +++ b/src/kaleidoscope/plugin/FirmwareDump.cpp @@ -15,6 +15,7 @@ * this program. If not, see . */ +#ifdef __AVR__ #ifndef KALEIDOSCOPE_VIRTUAL_BUILD #include @@ -72,3 +73,4 @@ EventHandlerResult FirmwareDump::onFocusEvent(const char *command) { kaleidoscope::plugin::FirmwareDump FirmwareDump; #endif +#endif diff --git a/src/kaleidoscope/plugin/FirmwareDump.h b/src/kaleidoscope/plugin/FirmwareDump.h index 2f841174..aa3a41a4 100644 --- a/src/kaleidoscope/plugin/FirmwareDump.h +++ b/src/kaleidoscope/plugin/FirmwareDump.h @@ -21,6 +21,8 @@ #error "Firmware Dump is not available for virtual builds" #else +#ifdef __AVR__ + #include namespace kaleidoscope { @@ -42,3 +44,4 @@ class FirmwareDump : public kaleidoscope::Plugin { extern kaleidoscope::plugin::FirmwareDump FirmwareDump; #endif +#endif