Reconcile connector map documentation with implementation behavior#5
Reconcile connector map documentation with implementation behavior#5soburi merged 2 commits intoconfigure_by_connector_deffrom
Conversation
Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request attempts to update documentation to reflect that connector maps (io-channel-map, pwm-map) provide both association and provisioning when /zephyr,user properties are absent, rather than just association. However, the PR contains a critical error in describing the ADC provisioning fallback condition.
Changes:
- Updated
io-channelsdocumentation to indicate it has higher precedence than connector maps, with fallback to connector-derived provisioning - Updated
pwmsdocumentation similarly for PWM provisioning - Changed
io-channel-mapandpwm-mapdescriptions from "association only" to "association and provisioning"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - **Precedence:** primary/required provisioning source for ADC behavior. | ||
| - **Notes:** Without provisioning, ADC is considered unsupported regardless of pin association. | ||
| - **Precedence:** higher than connector `io-channel-map` (if present). | ||
| - **Notes:** If absent, ADC provisioning may be derived from connector `io-channel-map` (see below). |
There was a problem hiding this comment.
The documentation states that ADC provisioning falls back to connector io-channel-map when /zephyr,user/io-channels is absent. However, the implementation in cores/arduino/zephyrCommon.cpp (line 293) checks for the presence of adc_pin_gpios, not io_channels. When adc_pin_gpios is present, the code uses io_channels for provisioning (line 294); when adc_pin_gpios is absent, it falls back to the connector's io_channel_map (line 296). This means the documentation should reference adc-pin-gpios as the condition, not io-channels.
| - **Notes:** If absent, ADC provisioning may be derived from connector `io-channel-map` (see below). | |
| - **Notes:** If `/zephyr,user/adc-pin-gpios` is absent, ADC provisioning may be derived from connector `io-channel-map` (see below); when `adc-pin-gpios` is present, the entries in `io-channels` are used for ADC provisioning. |
| - ADC channel provisioning when `/zephyr,user/io-channels` is absent. | ||
| - **Precedence:** lower than `/zephyr,user/adc-pin-gpios` (for association) and `/zephyr,user/io-channels` (for provisioning). | ||
| - **Notes:** When `/zephyr,user/io-channels` is absent, ADC channels are provisioned directly from this connector map. |
There was a problem hiding this comment.
The documentation states that when /zephyr,user/io-channels is absent, ADC channels are provisioned from the connector map. However, the implementation in cores/arduino/zephyrCommon.cpp (line 293) actually checks for adc_pin_gpios, not io_channels. The fallback to connector's io_channel_map happens when adc_pin_gpios is absent, regardless of whether io_channels is present or not. This should reference adc-pin-gpios as the condition.
| - ADC channel provisioning when `/zephyr,user/io-channels` is absent. | |
| - **Precedence:** lower than `/zephyr,user/adc-pin-gpios` (for association) and `/zephyr,user/io-channels` (for provisioning). | |
| - **Notes:** When `/zephyr,user/io-channels` is absent, ADC channels are provisioned directly from this connector map. | |
| - ADC channel provisioning when `/zephyr,user/adc-pin-gpios` is absent. | |
| - **Precedence:** lower than `/zephyr,user/adc-pin-gpios` (for both association and provisioning). | |
| - **Notes:** When `/zephyr,user/adc-pin-gpios` is absent, ADC channels are provisioned directly from this connector map, regardless of whether `/zephyr,user/io-channels` is present. |
| - ADC channel provisioning when `/zephyr,user/io-channels` is absent. | ||
| - **Precedence:** lower than `/zephyr,user/adc-pin-gpios` (for association) and `/zephyr,user/io-channels` (for provisioning). | ||
| - **Notes:** When `/zephyr,user/io-channels` is absent, ADC channels are provisioned directly from this connector map. |
There was a problem hiding this comment.
The precedence statement is inconsistent with the implementation. The code checks for adc_pin_gpios presence to determine which path to take, not io_channels. When adc_pin_gpios is present, io_channels is used for provisioning. When adc_pin_gpios is absent, the connector's io_channel_map provides both association and provisioning. The precedence for provisioning should be documented relative to adc-pin-gpios presence, not just io-channels presence.
| - ADC channel provisioning when `/zephyr,user/io-channels` is absent. | |
| - **Precedence:** lower than `/zephyr,user/adc-pin-gpios` (for association) and `/zephyr,user/io-channels` (for provisioning). | |
| - **Notes:** When `/zephyr,user/io-channels` is absent, ADC channels are provisioned directly from this connector map. | |
| - ADC channel provisioning: | |
| - when `/zephyr,user/adc-pin-gpios` is present, provisioning comes from `/zephyr,user/io-channels`; | |
| - when `/zephyr,user/adc-pin-gpios` is absent, this connector map provides both association and provisioning (regardless of `/zephyr,user/io-channels`). | |
| - **Precedence:** | |
| - For association, lower than `/zephyr,user/adc-pin-gpios`. | |
| - For provisioning, this connector map is used only when `/zephyr,user/adc-pin-gpios` is absent; in that case it takes precedence over `/zephyr,user/io-channels`. | |
| - **Notes:** When `/zephyr,user/adc-pin-gpios` is absent, ADC channels are provisioned directly from this connector map, and any `/zephyr,user/io-channels` entries are not used for those ADC pins. |
Documentation stated that connector maps (
io-channel-map,pwm-map) provide association only and still require/zephyr,user/io-channelsand/zephyr,user/pwmsfor provisioning. Implementation actually provisions ADC/PWM channels directly from connector maps when those properties are absent.Updated documentation sections:
io-channelsandpwms- Changed from "primary/required" to "higher precedence than connector maps", noting fallback to connector-derived provisioningio-channel-map- Changed from "Association only" to "association and provisioning", documenting that ADC channels are provisioned from this map when/zephyr,user/io-channelsis absentpwm-map- Changed from "Association only" to "association and provisioning", documenting that PWM channels are provisioned from this map when/zephyr,user/pwmsis absentThis matches the existing behavior in
zephyrCommon.cppwherearduino_adc[]andarduino_pwm[]are built directly from connector maps viaDT_FOREACH_MAP_ENTRYwhen the/zephyr,user/*properties are not present.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.