Skip to content

Commit e69c61e

Browse files
Ayush1325DhruvaG2000
authored andcommitted
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 73ba170 commit e69c61e

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
@@ -7,6 +7,9 @@
77
#include <Arduino.h>
88
#include "zephyrInternal.h"
99

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

1215
/*

0 commit comments

Comments
 (0)