keever50 commented on issue #16916:
URL: https://github.com/apache/nuttx/issues/16916#issuecomment-3229017601

   ### ----Design philosophy----
   **Simple default path**
   It can be quite challenging to target all use cases at once. I think it 
would be reasonable to target about 80-90% of ADC projects that does nothing 
fancy with ADC and just want a voltage.
   
   **Advanced path**
   For the users that just want a bit more, they can tinker with the IOCTL. It 
still attempts to unify common, yet detailed settings.
   But for the most advanced settings, it is better to go to driver specifics. 
This probably gives more confidence to developers finding full control.
   
   **Common applications**
   Common applications that are incredibly basic and low speed
   - Battery monitoring
   - Analog based sensors, like light, moisture, temperature etc
   - Controls. Potentiometers.
   - Threshold / hysteresis triggering
   
   Less common. Dedicated hardware is usually preferred, because its sometimes 
more precise or faster.
   But sometimes cost is more important.
   - Microphone recording (very low voltages)
   - Signal DSP, including audio but also faster signals. Even I/Q demodulation 
and sampling.
   
   ### ----**The simple API**----
   We can easily cover the most common ones by configuring the ADC to common 
default values.
   Probably after ``open()``
   1. Voltage range. Probably GND to REF, where REF is maximum.
   2. Resolution. We can also leave this on highest.
   3. Sampling modes. Whatever is the most basic and suits the common 
applications the best. User should not notice this.
   
   From here and on, we can start with a very basic API.
   ### read()
   Return a single shot samples with above default settings.
   The value is a pre-calculated voltage. The value is probably a 16 or 32-bit 
unsigned scaled x1000. Giving you millivolts with 1mV steps. Good enough for 
most simple projects.
   
   Maybe if we read (request) more, we can enable multi sample? But what would 
the sample rate be?
   
   ### ----**The advanced API**----
   These are IOCTL calls for more complicated projects that require tuning of 
parameters.
   I'd cover the most common ADC params.
   
   ### GET_CAPS
   Gets capabilities.
   Returns maximum and minimum settings.
   Such as resolution, voltage range, name, options, etc.
   
   ### GET/SET_VREF
   Gets or sets the voltage reference.
   _Problem:
   How to tell the ADC on an unified way, to either use internal reference or 
external reference? And which reference?_
   
   ### GET/SET_BITRES
   The bit resolution of the ADC.
   Takes an enum or uint8_t with number of bits.
   Returns something to verify that this worked.
   
   ### READ_MULTIPLE
   Often ADC can be configured to sample rapidly and stream into a buffer. 
Using DMA or interrupts.
   Maybe this can take a pointer to a buffer which gets populated with values.
   You can pass this the sample rate.
   This is probably blocking. Or maybe poll some on some way.
   
   
   What do we think? This might be a good starting point?


-- 
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-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to