Hi David,

I have partial answers:

> On Nov 29, 2016, at 8:37 AM, David G. Simmons <santa...@mac.com> wrote:
> 
> 
> Moving on from the BLE -- which now works perfectly -- and I understand how 
> 'subscribed' values work in nimBLE, thanks to all who responded! 
> 
> Next up is implementing an ADC-based sensor. All the NRF52DK stuff has been 
> moved out of -core and into mynewt-nordic, and I've looked through the source 
> there as well. 
> 
> From my understanding of the board, the ADC pin is P0.03, and I've tested the 
> sensor, and it works. So, only questions are:
> 
> Given the move to external packages, how does the #include work? I've tried 
> about every iteration of #include "drivers/adc/adc_nrf52/adc_nrf52.h" I can 
> think of. :-) 

That should happen through package dependencies.
So add dependency to @mynewt_nordic/hw/drivers/adc_nrf52.

Here’s a sample as I tried this out:

pkg.deps:
    - "@apache-mynewt-core/sys/console/full"
    - "@apache-mynewt-core/kernel/os"
    - "@apache-mynewt-core/sys/shell"
    - "@mynewt_nordic/hw/drivers/adc/adc_nrf52"

And then I can include it from my source:

#include <adc/adc.h>
#include <adc_nrf52/adc_nrf52.h>


> 
> Using the ADC: 
> 
> struct os_dev adc_dev;
> rc = nrf52_adc_dev_init(&adc_dev, void *);
> assert(rc == 0);
> 
> Should then initialize the ADC? Or do I need to nrf52_adc_open() first? 

Yes, you need to initialize it first. The preferred way to do this would be 
within
BSP's bsp_init(), but you can do it elsewhere early in the init.

I added this to my app’s main():

        rc = os_dev_create((struct os_dev *)&adc_dev, "adc0",
            OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT,
            nrf52_adc_dev_init, &adc_cfg);
        assert(rc == 0);

And then once the system has started, I open it from a task:

                dev = (struct adc_dev *)os_dev_open("adc0",
                                                    OS_TIMEOUT_NEVER,
                                                    &saadc_cfg);
                assert(dev);

> And subsequently, how to read the ADC. Do I nrf52_adc_read_channel(), 
> nrf52_adc_read_buffer() or ?? 
> 

I would go through the function pointers within dev->ad_funcs. Or the 
convenience functions
present in adc/adc.h. I don’t have sample code for this at hand though. Maybe 
someone else
does?

> This is the first ADC Tutorial for the Mynewt docs, so I'd like to get it 
> exactly right. :-) 

Hope this helps.

> Oh, the sensor is this one: https://www.adafruit.com/products/1786 which is a 
> pretty cool liquid level sensor. 
> 
> dg
> --
> David G. Simmons
> (919) 534-5099
> Web <https://davidgs.com/> • Blog <https://davidgs.com/davidgs_blog> • 
> Linkedin <http://linkedin.com/in/davidgsimmons> • Twitter 
> <http://twitter.com/TechEvangelist1> • GitHub <http://github.com/davidgs>
> /** Message digitally signed for security and authenticity.  
> * If you cannot read the PGP.sig attachment, please go to 
> * http://www.gnupg.com/ <http://www.gnupg.com/> Secure your email!!!
> * Public key available at keyserver.pgp.com <http://keyserver.pgp.com/>
> **/
> ♺ This email uses 100% recycled electrons. Don't blow it by printing!
> 
> There are only 2 hard things in computer science: Cache invalidation, naming 
> things, and off-by-one errors.
> 
> 

Reply via email to