arch/arm/ameba: add shared ADC driver for RTL8721Dx / RTL8720F / RTL8721F - #19899
Open
dcgong2917 wants to merge 3 commits into
Open
arch/arm/ameba: add shared ADC driver for RTL8721Dx / RTL8720F / RTL8721F#19899dcgong2917 wants to merge 3 commits into
dcgong2917 wants to merge 3 commits into
Conversation
Add a NuttX ADC lower-half for the Ameba SoC family, wired for the amebadplus/pke8721daf as /dev/adc0. The driver uses the fwlib ROM API and drives on-demand polled conversions via ADC_ReceiveBuf with the hardware auto channel-switch FIFO, because amebadplus disables the ADC software-trigger path. Per-chip wiring (channel count, pinmux function id, APB clock bits, optional aux clock) lives in a chip header so a new IC only supplies its own values without touching the shared driver. Reports raw conversion codes per the NuttX convention (12-bit effective, 0..~3876 for 0..3.3V), consistent with the STM32/i.MXRT/ Tiva ADC drivers. Verified on hardware: 0V->121, 3.3V->3876 on CH0(PB19) while CH1(PB18) held steady, confirming sampling, full-scale and multi-channel switch-list isolation. Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn> Assisted-by: Claude <noreply@anthropic.com>
Wire the shared Ameba ADC driver into the RTL8720F build: add the per-chip ameba_adc_chip.h (9 channels, CH0..CH5 external on PA13..PA18, PINMUX function 5, APB clock on bit24), the board ADC table and registration, the adc board config, and build glue for both cmake and make (including the fwlib RAM-layer ameba_adc.c in ameba_board.mk). Document the ADC on the board index. Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn> Assisted-by: Claude <noreply@anthropic.com>
Wire the shared Ameba ADC driver into the RTL8721F build: add the per-chip ameba_adc_chip.h (12 channels, CH0..CH7 external on PA20,PA19,PA18,PA17,PA15,PA14,PA13,PA12, PINMUX function 5), the board ADC table and registration, the adc board config, and build glue for both cmake and make (including the fwlib RAM-layer ameba_adc.c in ameba_board.mk). Document the ADC on the board index. Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn> Assisted-by: Claude <noreply@anthropic.com>
xiaoxiang781216
approved these changes
Aug 19, 2026
acassis
approved these changes
Aug 19, 2026
jerpelea
approved these changes
Aug 19, 2026
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.
Summary
Adds a shared Ameba SAR-ADC driver plus per-chip integration for three
Realtek parts. Structured as three self-contained commits (each builds and
can be reviewed independently):
arch/arm/rtl8721dx: the shared driver (arch/arm/src/common/ameba/ ameba_adc.{c,h}) + pke8721daf integration and board tablearch/arm/rtl8720f: RTL8720F chip header + board tablearch/arm/rtl8721f: RTL8721F chip header + board tableThe converter is exposed as a NuttX ADC character device at
/dev/adc0.It has a single channel-switch list; the board bring-up selects which
channels are sampled and which analog pad each external channel maps to.
Every listed channel is sampled, in order, on each
ANIOC_TRIGGER.The driver sits on the SDK fwlib register layer and reads the auto
channel-switch FIFO by polling in task context (the hardware does not
enable a software-trigger path, so this is the supported on-demand read).
It reports the raw right-aligned conversion code, matching the NuttX
convention used by other in-tree ADC drivers.
Per-chip differences (pinmux code, aux clock gate, the real fwlib
ADC_InitTypeDefsize) live in eachameba_adc_chip.h; the shared drivermirrors only the leading opmode/cvlistlen/cvlist prefix it actually writes
and sizes a
reserved[]tail fromAMEBA_ADC_INIT_SIZEwith astatic_assertso a new port cannot under-size the stack object. Theper-chip ClkDiv write is guarded by
AMEBA_ADC_HAS_CLKDIV(only amebadplushas that field at that offset).
Impact
New opt-in feature (
CONFIG_AMEBA_ADC, default n). No change to existingconfigurations. Documentation updated for each board's
index.rst.Testing
Built and hardware-tested on all three targets (
<board>:adcconfig,adcNSH example):other channel steady (channel isolation OK)
nxstyle clean (only the standing vendor-symbol Mixed-case exemptions).
CMake and make builds both verified for each board.