Skip to content

Commit 9086bc7

Browse files
Copilotsoburi
andcommitted
Implement TODOs for PWM and ADC global GPIO numbering
Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
1 parent a739fd1 commit 9086bc7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

cores/arduino/zephyrCommon.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
230230
DIGITAL_PIN_GPIOS_FIND_PIN( \
231231
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
232232
DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
233+
#define PWM_PINS_GLOBAL(n, p, i) \
234+
ZARD_GLOBAL_GPIO_NUM(DT_PHANDLE_BY_IDX(n, p, i)) + DT_PHA_BY_IDX(n, p, i, pin),
233235
#define PWM_CONN_CHANNEL_DT(n, p, i) \
234236
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
235237
({ .dev = DEVICE_DT_GET(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
@@ -255,7 +257,7 @@ const pin_size_t arduino_pwm_pins[] = {
255257
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
256258
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pin_gpios, PWM_PINS)
257259
#else // global pin rule
258-
//TODO
260+
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pin_gpios, PWM_PINS_GLOBAL)
259261
#endif
260262
#elif defined(ZARD_PWM_CONNECTOR)
261263
DT_FOREACH_MAP_ENTRY(DT_NODELABEL(ZARD_PWM_CONNECTOR), pwm_map, PWM_CONN_PINNUM)
@@ -282,6 +284,8 @@ size_t pwm_pin_index(pin_size_t pinNumber) {
282284
DIGITAL_PIN_GPIOS_FIND_PIN( \
283285
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
284286
DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
287+
#define ADC_PINS_GLOBAL(n, p, i) \
288+
ZARD_GLOBAL_GPIO_NUM(DT_PHANDLE_BY_IDX(n, p, i)) + DT_PHA_BY_IDX(n, p, i, pin),
285289
#define ADC_CH_CFG(n,p,i) arduino_adc[i].channel_cfg,
286290
#define ADC_CONN_CHANNEL_CFG(n, p, i) \
287291
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \
@@ -312,7 +316,7 @@ const pin_size_t arduino_analog_pins[] = {
312316
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
313317
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), adc_pin_gpios, ADC_PINS)
314318
#else // global pin rule
315-
// TODO
319+
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), adc_pin_gpios, ADC_PINS_GLOBAL)
316320
#endif
317321
#elif defined(ZARD_ADC_CONNECTOR)
318322
DT_FOREACH_MAP_ENTRY(DT_NODELABEL(ZARD_ADC_CONNECTOR), io_channel_map, ADC_CONN_PINNUM)

0 commit comments

Comments
 (0)