yangsong8-a1 opened a new pull request, #21594:
URL: https://github.com/apache/nuttx/pull/21594

   ## Summary
   The ADC, DAC, comparator and opamp upper halves use the global critical
   section to protect their FIFOs and to wrap ao_setup()/ao_shutdown().
   Use a spinlock in adc_dev_s and dac_dev_s for the FIFO accesses, release
   it around the blocking waits, and call ao_setup()/ao_shutdown() under the
   existing open/close mutex only. The DAC and opamp ad_closelock is renamed
   to ad_lock, as in the ADC and comparator.
   
   ## Impact
   drivers/analog and include/nuttx/analog only. Lower halves are not
   changed; out-of-tree code that uses ad_closelock of dac_dev_s or
   opamp_dev_s needs to use ad_lock.
   
   ## Testing
   Ubuntu 22.04, gcc 13.1, sim:nsh with CONFIG_ADC, CONFIG_DAC, CONFIG_COMP
   and CONFIG_OPAMP. There are no analog lower halves on sim, so a test
   program registers fake ADC, DAC, comparator and opamp devices. A thread
   acting as the ISR feeds ADC samples with au_receive(), completes DAC
   sends with dac_txdone() and raises comparator events with au_notify(),
   with interrupts disabled. Each device is opened twice to check that
   ao_setup() and ao_shutdown() run only on the first open and last close;
   the ADC and comparator are read with poll()/read(), the DAC is written in
   a loop:
   ```
   register: comp=0 opamp=0
   register: adc=0 dac=0
   adc: open fd=3 fd2=4 setup calls=1
   adc: after closing fd2 shutdown calls=0
   adc: 3000 samples read, out of order: 0, setup=1 shutdown=1
   dac: 1000 messages written, 1000 sent by lower half
   comp: after closing fd2 shutdown calls=0
   comp: 50 events read, setup=1 shutdown=1
   opamp: after closing fd2 shutdown calls=0
   opamp: setup=1 shutdown=1
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to