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
|
|
@ -419,6 +419,15 @@ static int adc_setup(struct adc_dev_s *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Re-enable the ADC clock. adc_shutdown() gates it on close, and the
|
||||
* one-shot adc_reset() that first turned it on only runs at registration;
|
||||
* without this a second open would drive a clock-gated peripheral and its
|
||||
* conversions would never complete. Clock gating preserves the register
|
||||
* configuration set up by adc_reset(), so nothing has to be re-programmed.
|
||||
*/
|
||||
|
||||
modifyreg32(GD32VW55X_RCU_APB2EN, 0, RCU_APB2EN_ADCEN);
|
||||
|
||||
/* Make sure that the interrupts are disabled and power up the ADC */
|
||||
|
||||
modifyreg32(GD32VW55X_ADC_CTL0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue