From 4cc7fa5c4c5c397611b80896b265ec8187a7aa73 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 21 Oct 2019 01:27:33 +0200 Subject: [PATCH] sys/arduino: Wire requires periph_i2c module --- sys/Makefile.dep | 4 ++++ sys/arduino/include/Wire.h | 4 ++++ sys/arduino/wireport.cpp | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 10a9375146f4e..4b40c3a632da1 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -1,3 +1,7 @@ +ifneq (,$(filter arduino,$(USEMODULE))) + FEATURES_OPTIONAL += periph_i2c +endif + ifneq (,$(filter eepreg,$(USEMODULE))) FEATURES_REQUIRED += periph_eeprom endif diff --git a/sys/arduino/include/Wire.h b/sys/arduino/include/Wire.h index 9d9f91113ba0a..0f546e86613d3 100644 --- a/sys/arduino/include/Wire.h +++ b/sys/arduino/include/Wire.h @@ -17,6 +17,10 @@ #ifndef WIRE_H #define WIRE_H +#ifndef MODULE_PERIPH_I2C +#error "No I2C support on your board" +#endif + #ifdef __cplusplus #include "wireport.hpp" #endif diff --git a/sys/arduino/wireport.cpp b/sys/arduino/wireport.cpp index 296d19a4c8c72..85fa75fc86258 100644 --- a/sys/arduino/wireport.cpp +++ b/sys/arduino/wireport.cpp @@ -52,6 +52,8 @@ * (https://creativecommons.org/licenses/by-sa/3.0/). */ +#if MODULE_PERIPH_I2C + extern "C" { #include #include @@ -269,3 +271,9 @@ void TwoWire::flush(void) /* single instance */ TwoWire Wire; + +#else /* MODULE_PERIPH_I2C */ + +typedef int dont_be_pedantic; + +#endif /* MODULE_PERIPH_I2C */