Skip to content

Commit d44df5f

Browse files
committed
x
1 parent 44b217b commit d44df5f

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

cores/arduino/Arduino.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
#define ZARD_CONNECTOR boosterpack_header
2828
#endif
2929

30+
#if DT_NODE_EXISTS(DT_NODELABEL(arduino_adc))
31+
#define ZARD_ADC_CONNECTOR arduino_adc
32+
#endif
33+
34+
#if DT_NODE_EXISTS(DT_NODELABEL(arduino_pwm))
35+
#define ZARD_PWM_CONNECTOR arduino_pwm
36+
#endif
37+
3038
#define ZARD_ADD_NGPIOS(i, n, p) DT_PROP(DT_PROP_BY_IDX(n, p, i), ngpios) +
3139
#define ZARD_ACCUM_NGPIOS(n, p, i, nd) \
3240
COND_CODE_1(DT_SAME_NODE(DT_PROP_BY_IDX(n, p, i), nd), \
@@ -74,10 +82,6 @@ enum analogPins {
7482
};
7583
#else
7684

77-
#if DT_NODE_EXISTS(DT_NODELABEL(arduino_adc))
78-
#define ZARD_ADC_CONNECTOR arduino_adc
79-
#endif
80-
8185
#define ZARD_MKR_ADC_AN_ENUMS(n, p, i) \
8286
UTIL_CAT(A, DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0)) = \
8387
ZARD_GLOBAL_GPIO_NUM_(DT_MAP_ENTRY_PARENT_BY_IDX(DT_NODELABEL(ZARD_CONNECTOR), gpio_map, i)) \

cores/arduino/zephyrCommon.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,18 @@ const struct pwm_dt_spec arduino_pwm[] = {
148148
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), pwms, PWM_DT_SPEC, (,))
149149
};
150150

151+
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), pwm_pin_gpios)
151152
/* pwm-pins node provides a mapping digital pin numbers to pwm channels */
152153
const pin_size_t arduino_pwm_pins[] = {
153154
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), pwm_pin_gpios, ZARD_GLOBAL_GPIO_NUM, (,))
154155
};
156+
#else
157+
#define ZARD_PWM_CONNECTOR_PINNUM(n, p, i) DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0)
158+
const pin_size_t arduino_pwm_pins[] = {
159+
DT_FOREACH_MAP_ENTRY_SEP(DT_NODELABEL(ZARD_PWM_CONNECTOR), pwm_map, ZARD_PWM_CONNECTOR_PINNUM, (, )),
160+
};
161+
162+
#endif
155163

156164
size_t pwm_pin_index(pin_size_t pinNumber) {
157165
for(size_t i=0; i<ARRAY_SIZE(arduino_pwm_pins); i++) {
@@ -179,7 +187,7 @@ const pin_size_t arduino_analog_pins[] = {
179187
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), adc_pin_gpios, ZARD_GLOBAL_GPIO_NUM, (,))
180188
};
181189
#else
182-
#define ZARD_ADC_CONNECTOR_AN(n, p, i) UTIL_CAT(A, i)
190+
#define ZARD_ADC_CONNECTOR_AN(n, p, i) DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0)
183191
const pin_size_t arduino_analog_pins[] = {
184192
DT_FOREACH_MAP_ENTRY_SEP(DT_NODELABEL(ZARD_ADC_CONNECTOR), io_channel_map, ZARD_ADC_CONNECTOR_AN, (, )),
185193
};

0 commit comments

Comments
 (0)