Dynamic Reconfiguration of ADC/COMP in Zephyr

I'm trying to figure out how to get around Zephyrs' dismal hardware model and am too green on zephyr to figure it out.  I'm using an nRF52840 and currently have SDK15.3 doing what I need.  I see there is a 2.6 version of the Connect SDK setup (which, I must say is on the right path to some sense) and am trying to figure out how to do what I need in a Zephyr context.

My scenario: I've got 2 different analog pins that I'm using to measure 2 different subsystems.  The first pin, I grab an ADC reading from every few minutes.  The second pin I monitor continuously with a comparitor to give me a level ISR trigger when something interesting happens.  At times, on that pin I'm running ADC in DMA at 25KHz to watch what's going on in detail.

Apparently on this part, you can't run COMP and ADC at the same time or you get wonky values on the ADC so, in SDK 15, I've got these functions paying attention to each other and keeping from stepping each others toes.

When asking for a single ADC read, I turn off the COMP (de_init), configure and turn on/init the ADC looking at the first pin, take a reading and then turn it off, turning on the COMP again on the second pin.

When asking for lots of ADC, I go through the same process but with a lot of DMA traffic and ping-pong buffer processing with the ADC reading on the second pin. Again this turns off the ADC and turns on COMP for the long haul when I'm done looking closely at that pin.

This, on SDK 15 is done through nrfx_saadc_init() and nrfx_saadc_uninit() calls at each time I want to do something.  It leaves the part using the COMP for low power long term watching

So, how does one do that in Zephyr context? 

Parents Reply Children
Related