You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by "David G. Simmons" <sa...@mac.com> on 2016/06/30 16:46:21 UTC

Using the ADC on nrf52dk

I think I’m finally getting a handle on mynewt … I’m able to add tasks, schedule them, respond to them, etc. so this is some progress. :-)

I do have a question about the ADC though. I can find scant info on how to use the ADC. In looking through the header files, I see that hal_adc.h defines some useful looking things like

/* This is the device for an ADC. The application using the ADC device
 * does not need to know the definition of this device and can operate
 * with a pointer to this device.  you can get/build device pointers in the
 * BSP
 */
struct hal_adc;

/* initialize the ADC on the corresponding BSP Pin. Returns a pointer
 * to the adc object to use for the methods below. Returns NULL on
 * error
 */
 struct hal_adc *hal_adc_init(enum system_device_id sysid);

/* read the ADC corresponding to sysid in your system.  Returns
 * the  adc value read or negative on error, See
 * hal_adc_get_resolution to check the range of the return value
 */
int hal_adc_read(struct hal_adc *padc);

But the “you can get/build device pointers in the BSP is a tad vague.

I know (or at least think I know) that the ADC pin is P0.03, so that would be pin 3, but since hal_adc has no size, or real definition.

So, anyone used the ADC on the NRF52 Dev board?

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.



Re: Using the ADC on nrf52dk

Posted by "David G. Simmons" <sa...@mac.com>.
Actually, I get:  "error: storage size of 'hr_adc' isn't known” when HR_ADC is declared as hal_adc, but I think it amounts to the same error. ;-)

It sounds like what you’re saying is that ADC has not been implemented yet, and if I want/need to use the ADC I’m going to have to implement it first.  Which also would appear to be the case for I2C and SPI, etc. In other words, we currently don’t support any peripherals  other than GPIO, UART and flash.

That’s going to be a bit of work on my part then I guess … :-)

Thanks!
dg

> On Jun 30, 2016, at 3:02 PM, paul@wrada.com wrote:
> 
> I just pulled from develop and my version does not have hal_adc support for the nrf52.
> 
> I looked in the following place and didn’t see a hal_adc.c file.
> 
> 
> $ ls repos/apache-mynewt-core/hw/mcu/nordic/nrf52xxx/src/
> 
> hal_cputime.c hal_gpio.c hal_system.c hal_uart.c
> 
> hal_flash.c hal_os_tick.c hal_system_start.c nrf52_hw_id.c
> 
> 
> There is a method in hal_adc_int.h (I think this should be in hal_adc.h) that you can use to get a hal_adc object from the bsp
> 
> 
> /* The  BSP must implement this factory to get devices for the application.  */
> 
> extern struct hal_adc *bsp_get_hal_adc(enum system_device_id sysid);
> 
> 
> However, I think if you call this for nrf52 you will get an undefined external.
> 
> 
> 
> 
> 
> 
> From: "David G. Simmons" <sa...@mac.com>>
> Reply-To: <de...@mynewt.incubator.apache.org>>
> Date: Thursday, June 30, 2016 at 9:46 AM
> To: <de...@mynewt.incubator.apache.org>>
> Subject: Using the ADC on nrf52dk
> 
> 
> I think I’m finally getting a handle on mynewt … I’m able to add tasks, schedule them, respond to them, etc. so this is some progress. :-)
> 
> I do have a question about the ADC though. I can find scant info on how to use the ADC. In looking through the header files, I see that hal_adc.h defines some useful looking things like
> 
> /* This is the device for an ADC. The application using the ADC device
> * does not need to know the definition of this device and can operate
> * with a pointer to this device.  you can get/build device pointers in the
> * BSP
> */
> struct hal_adc;
> 
> /* initialize the ADC on the corresponding BSP Pin. Returns a pointer
> * to the adc object to use for the methods below. Returns NULL on
> * error
> */
> struct hal_adc *hal_adc_init(enum system_device_id sysid);
> 
> /* read the ADC corresponding to sysid in your system.  Returns
> * the  adc value read or negative on error, See
> * hal_adc_get_resolution to check the range of the return value
> */
> int hal_adc_read(struct hal_adc *padc);
> 
> But the “you can get/build device pointers in the BSP is a tad vague.
> 
> I know (or at least think I know) that the ADC pin is P0.03, so that would be pin 3, but since hal_adc has no size, or real definition.
> 
> So, anyone used the ADC on the NRF52 Dev board?
> 
> 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/ 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.
> 
> 
> 

--
David G. Simmons
(919) 534-5099
Web • Blog • Linkedin • Twitter • GitHub
/** Message digitally signed for security and authenticity.
* If you cannot read the PGP.sig attachment, please go to
 * http://www.gnupg.com/ Secure your email!!!
 * Public key available at 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.



Re: Using the ADC on nrf52dk

Posted by "paul@wrada.com" <pa...@wrada.com>.
I just pulled from develop and my version does not have hal_adc support for the nrf52.

I looked in the following place and didn’t see a hal_adc.c file.


$ ls repos/apache-mynewt-core/hw/mcu/nordic/nrf52xxx/src/

hal_cputime.c hal_gpio.c hal_system.c hal_uart.c

hal_flash.c hal_os_tick.c hal_system_start.c nrf52_hw_id.c


There is a method in hal_adc_int.h (I think this should be in hal_adc.h) that you can use to get a hal_adc object from the bsp


/* The  BSP must implement this factory to get devices for the application.  */

extern struct hal_adc *bsp_get_hal_adc(enum system_device_id sysid);


However, I think if you call this for nrf52 you will get an undefined external.






From: "David G. Simmons" <sa...@mac.com>>
Reply-To: <de...@mynewt.incubator.apache.org>>
Date: Thursday, June 30, 2016 at 9:46 AM
To: <de...@mynewt.incubator.apache.org>>
Subject: Using the ADC on nrf52dk


I think I’m finally getting a handle on mynewt … I’m able to add tasks, schedule them, respond to them, etc. so this is some progress. :-)

I do have a question about the ADC though. I can find scant info on how to use the ADC. In looking through the header files, I see that hal_adc.h defines some useful looking things like

/* This is the device for an ADC. The application using the ADC device
 * does not need to know the definition of this device and can operate
 * with a pointer to this device.  you can get/build device pointers in the
 * BSP
 */
struct hal_adc;

/* initialize the ADC on the corresponding BSP Pin. Returns a pointer
 * to the adc object to use for the methods below. Returns NULL on
 * error
 */
 struct hal_adc *hal_adc_init(enum system_device_id sysid);

/* read the ADC corresponding to sysid in your system.  Returns
 * the  adc value read or negative on error, See
 * hal_adc_get_resolution to check the range of the return value
 */
int hal_adc_read(struct hal_adc *padc);

But the “you can get/build device pointers in the BSP is a tad vague.

I know (or at least think I know) that the ADC pin is P0.03, so that would be pin 3, but since hal_adc has no size, or real definition.

So, anyone used the ADC on the NRF52 Dev board?

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/ 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.