Repository navigation
[bsp][bluetrum] validate AB32 ADC channels - #11962
Open
usualtreee wants to merge 1 commit into
Open
usualtreee wants to merge 1 commit into
usualtreee wants to merge 1 commit into
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The AB32 ADC driver maps the requested channel for the HAL conversion, but then uses the original unchecked channel to index the ADC data registers. Values outside 0 through 15 therefore select memory outside the sixteen-register window. The callback channel types also do not match
struct rt_adc_ops.Fixes #11948.
Changes
rt_adc_opsinterface.-RT_EINVALfor channels without a defined AB32 ADC mapping instead of silently falling back to channel 0.Valid channel mappings and the existing conversion polling behavior are unchanged.
Verification
channel = 16produced an AddressSanitizer global-buffer-overflow at the original register access.-RT_EINVAL, do not call the HAL, and leave the output value unchanged. Invalid enable requests are also rejected without calling the HAL.riscv64-unknown-elf-gcc 14.2.0and the AB32rv32imc/ilp32flags produces a 32-bit RISC-V relocatable object for the driver.git diff --checkand changed-line checks with clang-format 22.1.8 pass locally.Not tested on physical AB32 hardware. Only the driver object was cross-compiled; a complete firmware image was not built or linked.