You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "dcgong2917 (via GitHub)" <gi...@apache.org> on 2026/10/22 03:19:32 UTC
[PR] arch/arm/rtl8730e: add ADC driver support [nuttx]
dcgong2917 opened a new pull request, #20878:
URL: https://github.com/apache/nuttx/pull/20878
## Summary
Add the ADC driver on the AmebaSmart (RTL8730E) CA32 and register the
converter at `/dev/adc0`.
The chip has ten channels. CH0-CH5 are external and bound to the fixed pads
PA0-PA5; the rest are internal. PA0 and PA1 are not bonded out on the
RTL8730EAM/EAH packages, so the board registers CH2-CH5 (PA2-PA5). A new
`adc` configuration enables the driver and the `examples/adc` application.
Chip specifics live in `ameba_adc_chip.h`:
- The pads reach the converter through the cap-touch function (pinmux
function 18), and the CTC clock is gated together with the ADC clock.
- `ADC_Read()` keeps only the low 16 bits of the global data register on
this chip: channel id in [15:12], 12-bit sample in [11:0].
- `PAD_InputCtrl()` is a header-only inline in the SDK here, so the ROM has
no symbol for it. The chip header supplies its own version.
The shared driver gets two small hooks so a chip header can override the
conversion-word layout (`AMEBA_ADC_GET_CHNO`, `AMEBA_ADC_GET_DATA`) and the
`PAD_InputCtrl()` implementation (`AMEBA_ADC_PAD_INPUTCTRL`). The defaults
are the old behaviour, so the other Ameba chips are unchanged.
### Boot delay fix
`ADC_Init()` reads the vref calibration byte from the OTP. That needs two
things the port did not have:
- `SYSCFG_RLVersion()`, which `IPC_SEMTake()`/`IPC_SEMFree()` use to pick
their semaphore register layout. The SDK only ships it inside an object
that cannot be linked alone, so its logic is mirrored.
- `DelayUs()`. The ROM version only knows the LP (CPUID 0) and NP (CPUID 1)
cores. On the CA32 (CPUID 2) its `RBSS_UDELAY_FLAG == 0` fallback indexes
the `Clk[]`/`Div[]` tables out of bounds, so the divisor is stack garbage.
`OTP_Read8()` polls with `DelayUs(5)`, so the first `ADC_Init()` spun for
11 to 33 seconds and the NSH prompt appeared that much later after every
reset. It now calls `up_udelay()`, which is bounded by
`CONFIG_BOARD_LOOPSPERMSEC`.
The bug is in the ROM delay, not in the ADC code, so any other CA32 code
that reaches `DelayUs()` is exposed to it.
## Impact
RTL8730E only. Adds the `rtl8730e_evb:adc` configuration. The hooks in
`arch/arm/src/common/ameba/ameba_adc.c` default to the previous behaviour,
so the other Ameba chips build as before. No change to
`tools/nxstyle.c` or any other shared tool.
## Testing
Host: `make` and CMake builds of `rtl8730e_evb:adc` are clean (no errors or
warnings), `tools/checkpatch.sh` passes on both commits, and
`tools/refresh.sh` leaves the defconfig unchanged.
Board (RTL8730E EVB, C-cut), PA2 and PA3 to GND, PA4 to 3.3 V, PA5 floating:
```
nsh> adc -n 5
Sample:
1: channel: 2 value: 4
2: channel: 3 value: 5
3: channel: 4 value: 4095
4: channel: 5 value: 39
...
```
- CH2/CH3 read 2 to 6, CH4 reads 4095, and the floating CH5 drifts between
39 and 113. Each sample carries its own channel id, so the readings follow
the wiring.
- `mh 0x420082f8` reads `0xffc3` after registration: bits 2-5 (PA2-PA5) are
cleared and the rest are untouched, matching `PAD_InputCtrl()`.
- Boot delay: the time from reset to the `nsh>` prompt dropped from about
30 seconds to a few seconds. Before the fix, tick counters placed all of
it in the first `ADC_Init()`, and sampling the interrupted PC showed the
CPU spinning in `DelayNop()` for the whole time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] arch/arm/rtl8730e: add ADC driver support [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20878:
URL: https://github.com/apache/nuttx/pull/20878
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] arch/arm/rtl8730e: add ADC driver support [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20878:
URL: https://github.com/apache/nuttx/pull/20878#issuecomment-6336530869
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report · [Explore what changed →](https://membrowse.com/public/apache/nuttx?commit_sha=570804a47f1820f134f26aef41db51dbadf12be4)
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=570804a47f1820f134f26aef41db51dbadf12be4&base=a46119d43726b69bb91805af45ec94c5024c95d2)
---
<sub>Catch memory regressions in CI with [MemBrowse](https://membrowse.com). Free for open source.</sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org