mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
risc-v/gd32vw55x: fix ADC reopen and add gd32vw553k-start adc example
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
adc_shutdown() gates the ADC clock (RCU_APB2EN.ADCEN) when the device is closed, but the one-shot adc_reset() that first enabled it only runs at registration and adc_setup() never re-enabled it. A second open() then drove a clock-gated peripheral whose conversions never completed, so a second run of a reader such as the adc example hung after opening the device. adc_setup() now re-enables the ADC clock; clock gating preserves the register configuration, so nothing else has to be re-programmed. Add an "adc" configuration that exercises the driver. It is the nsh base plus the ADC driver, registered as /dev/adc0 and read by the adc example. ADC channel 8 (ADC_IN8) is routed to PB0 on the J1 header so an analog voltage applied there is sampled. The board bringup samples that channel when the pin is routed, and PB0 is only claimed for the ADC when SPI is off (with SPI on it belongs to the I2C0 fallback), so the periph configuration is unaffected. The GD32VW55x ADC converts on demand rather than continuously, so the example uses the software trigger (CONFIG_EXAMPLES_ADC_SWTRIG) and is bounded to 20 sample groups so it returns to the prompt. Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
bbc0bdd40c
commit
5ecdf31364
5 changed files with 108 additions and 1 deletions
|
|
@ -300,6 +300,33 @@ on ``/mnt/sd``, so no manual ``mount`` is needed::
|
|||
GD32 on NuttX
|
||||
nsh> ls -l /mnt/sd
|
||||
|
||||
adc
|
||||
---
|
||||
|
||||
NSH plus the ADC driver, registered as ``/dev/adc0`` and read by the ``adc``
|
||||
example. Channel 8 (ADC_IN8) is routed to **PB0** on the J1 header, so an
|
||||
analog voltage applied there is sampled.
|
||||
|
||||
The ADC converts on demand rather than continuously, so the example is built
|
||||
with ``CONFIG_EXAMPLES_ADC_SWTRIG``: it issues a software trigger and then
|
||||
reads a group of samples. It is bounded to 20 groups
|
||||
(``CONFIG_EXAMPLES_ADC_NSAMPLES``) so it returns to the prompt::
|
||||
|
||||
nsh> adc
|
||||
adc_main: g_adcstate.count: 20
|
||||
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
|
||||
Sample:
|
||||
1: channel: 8 value: 2108
|
||||
Sample:
|
||||
1: channel: 8 value: 2115
|
||||
Sample:
|
||||
1: channel: 8 value: 2112
|
||||
...
|
||||
|
||||
The reported ``value`` is the 12-bit conversion (0..4095) spanning 0..3.3 V; a
|
||||
1.65 V input (half of the reference) reads about 2048, and tying PB0 to GND or
|
||||
3.3 V drives it to the rails.
|
||||
|
||||
littlefs
|
||||
--------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue