From 8166fce82421910d56c4336606aa2c1b0c30a07f Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Thu, 20 Jun 2024 19:24:10 +0530 Subject: [PATCH] Arduino.h: Allow including from other headers - I was facing some problems due to multiple declarations of arduino_pins array. - It is important for Arduino.h to be includable from both C and C++ code since `Common.h` defines some data types like PinStatus and PinMode Signed-off-by: Ayush Singh --- cores/arduino/Arduino.h | 5 ++--- cores/arduino/zephyrCommon.cpp | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index f75c50f6..67226d57 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -87,9 +87,6 @@ enum digitalPins { NUM_OF_DIGITAL_PINS }; -const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP( - DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))}; - #ifdef CONFIG_ADC #define AN_ENUMS(n, p, i) A ## i = DIGITAL_PIN_GPIOS_FIND_PIN( \ @@ -101,5 +98,7 @@ enum analogPins { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), #endif #include +#ifdef __cplusplus #include #include +#endif // __cplusplus diff --git a/cores/arduino/zephyrCommon.cpp b/cores/arduino/zephyrCommon.cpp index c023e7ad..00744040 100644 --- a/cores/arduino/zephyrCommon.cpp +++ b/cores/arduino/zephyrCommon.cpp @@ -6,6 +6,9 @@ #include +static const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP( + DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))}; + namespace { /*