Skip to content

Commit dd32c52

Browse files
authored
Merge pull request #13 from soburi/copilot/sub-pr-4-a39d8ef7-6197-4fa0-a715-fd87b6b4c807
Implement global GPIO numbering for PWM and ADC pin mappings
2 parents 28f13f0 + c559b55 commit dd32c52

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
rust/Cargo.lock
2+
_codeql_build_dir/
3+
_codeql_detected_source_root

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)