@@ -242,11 +242,19 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
242242 ())
243243
244244const struct pwm_dt_spec arduino_pwm[] = {
245+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), pwm_pin_gpios)
246+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
245247#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), pwms)
246248 DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), pwms, PWM_DT_SPEC )
247249#elif defined(ZARD_PWM_CONNECTOR)
248250 DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_PWM_CONNECTOR ), pwm_map, PWM_CONN_CHANNEL_DT )
249251#endif
252+ #else // global pin rule
253+ // TODO
254+ #endif
255+ #elif defined(ZARD_PWM_CONNECTOR)
256+ DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_PWM_CONNECTOR ), pwm_map, PWM_CONN_CHANNEL_DT )
257+ #endif
250258};
251259
252260/* pwm-pins node provides a mapping digital pin numbers to pwm channels */
@@ -295,11 +303,19 @@ size_t pwm_pin_index(pin_size_t pinNumber) {
295303 ())
296304
297305const struct adc_dt_spec arduino_adc[] = {
306+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), adc_pin_gpios)
307+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
298308#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), io_channels)
299309 DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), io_channels, ADC_DT_SPEC )
300310#elif defined(ZARD_ADC_CONNECTOR)
301311 DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_ADC_CONNECTOR ), io_channel_map, ADC_CONN_CHANNEL_DT )
302312#endif
313+ #else // global pin rule
314+ // TODO
315+ #endif
316+ #elif defined(ZARD_ADC_CONNECTOR)
317+ DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_ADC_CONNECTOR ), io_channel_map, ADC_CONN_CHANNEL_DT )
318+ #endif
303319};
304320
305321/* io-channel-pins node provides a mapping digital pin numbers to adc channels */
@@ -312,11 +328,19 @@ const pin_size_t arduino_analog_pins[] = {
312328};
313329
314330struct adc_channel_cfg channel_cfg[ARRAY_SIZE (arduino_analog_pins)] = {
331+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), adc_pin_gpios)
332+ #if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
315333#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), io_channels)
316334 DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), io_channels, ADC_CH_CFG )
317335#elif defined(ZARD_ADC_CONNECTOR)
318336 DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_ADC_CONNECTOR ), io_channel_map, ADC_CONN_CHANNEL_CFG )
319337#endif
338+ #else // global pin rule
339+ // TODO
340+ #endif
341+ #elif defined(ZARD_ADC_CONNECTOR)
342+ DT_FOREACH_MAP_ENTRY (DT_NODELABEL (ZARD_ADC_CONNECTOR ), io_channel_map, ADC_CONN_CHANNEL_CFG )
343+ #endif
320344};
321345
322346BUILD_ASSERT (ARRAY_SIZE (arduino_adc) == ARRAY_SIZE (arduino_analog_pins));
0 commit comments