Skip to content

Commit 8166fce

Browse files
committed
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 <[email protected]>
1 parent 3674743 commit 8166fce

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cores/arduino/Arduino.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ enum digitalPins {
8787
NUM_OF_DIGITAL_PINS
8888
};
8989

90-
const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
91-
DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};
92-
9390
#ifdef CONFIG_ADC
9491

9592
#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),
10198
#endif
10299

103100
#include <variants.h>
101+
#ifdef __cplusplus
104102
#include <zephyrPrint.h>
105103
#include <zephyrSerial.h>
104+
#endif // __cplusplus

cores/arduino/zephyrCommon.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <Arduino.h>
88

9+
static const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
10+
DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};
11+
912
namespace {
1013

1114
/*

0 commit comments

Comments
 (0)