Where do i find all the class/structure used in arduino project?

I got a xiao arduino module and am learning how to use it.

I can get my program running from various google/github sources, but i would like to explore deeper.

unlike my familiar msvs project, which one can find his way around by combing through header files, or Intelligent code completion in IDE, arduino's IDE 2.0 doesn't give any suggestion as i typed, and there is no header files in the sketch.

Any pointer on how to find out the list of members of structure/class and available resources, interrupt service routine, etc in sketch? thanks!

Your topic was MOVED to its current forum category as it is more suitable than the original

Thanks

btw, I search my drive C: and I could not find any text file that contains the info i am looking for.

For example, a sample program has this line

ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1024 | ADC_AVGCTRL_ADJRES(4);

Obviously, ADC_AVGCTRL_SAMPLENUM_1024 is a predefined symbol, there may be other options that I could use, so I search c drive with grepWin utility, but I found nothing obviously.

Why "obviously" ?

ADC_AVGCTRL_SAMPLENUM_1024 is defined in a number of files named adc.h in a number of folders, for instance C:\Users\Bob2\AppData\Local_original Arduino15\packages\arduino\hardware\samd\1.8.11\bootloaders\sofia\Bootloader_D21_Sofia_V2.1\src\ASF\sam0\utils\cmsis\samd21\include\component\adc.h

For completeness here is its definition in that file

#define   ADC_AVGCTRL_SAMPLENUM_1024_Val  0xAu   /**< \brief (ADC_AVGCTRL) 1024 samples */

I found the files containing the definition using Agent Ransack on Windows 10

Thank you very much for the pointer!

Is there an environment path in arduino IDE that tells the users where to find the path for various configuration/board?

Sorry, not my area of expertise

Have you got verbose messages turned on for compilation in the IDE ? You will find all sorts of information about which files are used in the output

Great, thanks!

Because it exposes some low level code that beginners might find overwhelming or distracting, the IDE does not automatically provide suggestions as you type. If that is what you want, simply do this:

  1. Select File > Preferences... from the Arduino IDE menus.
  2. Check the box next to "☐ Editor Quick Suggestions".
  3. Click the OK button.

You also have the option of triggering suggestions on demand by using the "Trigger Suggest" keyboard shortcut (defaults to Ctrl+Space). You can customize the shortcut keys via File > Advanced > Keyboard Shortcuts.

You also might find the new "go to" features very useful for exploring the underlying code behind your sketch. Just right click on any code in the Arduino IDE editor and then select "Go to definition" or Peek > Peek definition from the context menu (depending on whether you want it to open in a new tab or inline in your current editor tab. You can also use the customizable keyboard shortcut for this.

There is a hidden one. Before compilation, this line is added to the primary .ino file of your sketch if it doesn't contain it already:

#include <Arduino.h>

You can also use the "go to" features on #include directives, so you might like to add this line to your sketch.

THanks for more pointers! it helps a lot to understand arduino

I successfully added #include <Arduino.h> but i can't add #include <adc.h>, the compiler complained " No such file or directory", but I did confirm ADC_AVGCTRL_SAMPLENUM_1024 is from one of the adc.h files, as suggested by UKHeliBob

Any comment?

Do you actually need to #include adc.h for some reason ?

so that i can find out which adc.h is being use in different sketch (i find six different adc.h files on my pc) and use "go to" to reveal what control i have on my adc

Just noticed you are an arduino guru, could you take a look at this possible arduino bug I ran into when you have free time? ( (I already have work around, so no rush)

Please tell us the path to that file.

the arduino module i used was called xiao, and i found ADC_AVGCTRL_SAMPLENUM_1024 from the following header files, that's why I would like to be able to add "include adc.h" to the sketch and use "go to" feature

C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samc21\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samd10\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samd11\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samd21\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samd51\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\saml21a1\include\component\adc_100.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\saml21b\include\component\adc.h
C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samr21\include\component\adc.h

What you need to do is check the verbose compilation output to find the parent path that is set via the -I compiler flag.

You will see something like this:

"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++14 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions "-D__SKETCH_NAME__=\"\"\"saveastest.ino\"\"\"" -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SEEED_XIAO_M0 -DARDUINO_ARCH_SAMD -DARDUINO_SAMD_ZERO -D__SAMD21__ -D__SAMD21G18A__ -DARM_MATH_CM0PLUS -DSEEED_XIAO_M0 -DUSB_VID=0x2886 -DUSB_PID=0x802F -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Seeed\"" "-DUSB_PRODUCT=\"Seeed XIAO M0\"" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" -DARDUINO_SAMD_ZERO -D__SAMD21__ -D__SAMD21G18A__ -DARM_MATH_CM0PLUS -DSEEED_XIAO_M0 -DUSB_VID=0x2886 -DUSB_PID=0x802F -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Seeed\"" "-DUSB_PRODUCT=\"Seeed XIAO M0\"" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS\\5.7.0/CMSIS/Core/Include/" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS\\5.7.0/CMSIS/DSP/Include/" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS-Atmel\\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\cores\\arduino" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.8.2\\variants\\XIAO_m0" "C:\\Users\\per\\AppData\\Local\\Temp\\arduino-sketch-BD1FB85753D46A456AC6C47D7805B607\\sketch\\saveastest.ino.cpp" -o nul

The important part there is:

"-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS-Atmel\\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/"

That is the include search path, so your #include directive must use the path to the file relative to that.

Since the Seeed XIAO uses the ATSAMD21G, we can see that the correct adc.h from your list is this one:

C:\Users\xc window 10\AppData\Local\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1\CMSIS-Atmel\CMSIS\Device\ATMEL\samd21\include\component\adc.h

So the relative path is:

samd21/include/component/adc.h

and the #include directive looks like this:

#include <samd21/include/component/adc.h>

thanks!

You're welcome. I'm glad if I was able to be of assistance.

Regards, Per

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.