Page 1 of 1

#include adc.h

Posted: Thu Jan 19, 2017 5:50 pm
by frax84
Hello,
I'm using Eclipse Neon.2 and i need to use ADC and BLE for my project.
I started from gatt_example and with a little of work i have been able to fully compile and flash the project on my devkit. I'm trying to add the adc part so this is what i did:

1) I added to the "include" paths of the project properties: "${IDF_PATH}/components/driver/include/driver" that is the folder where "adc.h" is
2) I called the needed code (setting width, attenuation and get voltage). Please note that functions have been recognized and can be explored with the hotkey (CTRL+click)

The problem is that when i try to compile i get error "adc.h no such file or directory". Please note that if i CTRL+click on "adc.h" in the include i can explore the library. I just don't understand how is possible that i'm able to explore the files and the function but i get this error.

Any suggestion?
Thank you!
Frax

Re: #include adc.h

Posted: Thu Jan 19, 2017 6:04 pm
by loboris
Add include path ${IDF_PATH}/components/driver/include
and use

Code: Select all

#include "driver/adc.h"

Re: #include adc.h

Posted: Fri Jan 20, 2017 9:34 am
by frax84
It works! Thank you very much.
Can anyone explain me why the way i did was not right?

Frax

Re: #include adc.h

Posted: Fri Jan 20, 2017 10:07 am
by kolban
The Eclipse environment allows us to supply a set of directories which the "editor" searches for entry assist and validation. Thus when you edited your Eclipse environment paths, the editor was able to find them and any warning you had about unresolved includes (as produced by the editor) went away. However, if you are using the out-of-the-box ESP-IDF build system and just running "make" then that uses its own build directories locations that are dynamically located based on the ESP-IDF component concept see ...

http://esp-idf.readthedocs.io/en/latest ... ystem.html

The ESP-IDF build system knows nothing about the paths you set to satisfy the Eclipse editor.

Re: #include adc.h

Posted: Fri Jan 20, 2017 11:20 am
by frax84
I see,
so, if i well understand, it's not important that the path i set is correct. It's important that the "syntax" i use in the #include is the same one the pre-built ESP-IDF expects. Can you confirm?

Thank you as usual :D
Frax

Re: #include adc.h

Posted: Fri Jan 20, 2017 5:12 pm
by kolban
Frax,
Yes sir ... that's correct. By and large, the directory that is called:

<component>/include

Is added to the include lookup path in the build system.

So if there is a component called XYZ then <XYZ>/include will be in the build path.

If we look at the "driver" component ... we see that it has an include directory which ... itself ... has a directory called "driver" within it ... hence the need to #include <driver/adc.h>

Re: #include adc.h

Posted: Sat Jan 21, 2017 8:50 am
by frax84
Understood!
Thank you!

frax