How to determine the source of constants in libraries?

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Preamble:
I am trying to figure out how to program and use the timers in the Feather M0 using the Arduino IDE. I have seen a number of examples published, but I'm not one to just blindly copy some code and expect it to work. The issue that I'm having (and it seems to be ubiquitous in Arduino) is that there does not seem to be a concept of dependencies. In order to reference constants, they have to be defined somewhere.
Question:
How can I find the source of the definition of the constants that people keep referring to in their code? For example, in this code a Arduino Zero, M0 timer example, reference is made to TC_CTRLA_PRESCALER_DIV1 among other constants. Where is this constant defined?
Efforts:
I've searched generally and specifically for these constants. But, as you would imagine in C, it's difficult to find the actual source versus a simple reference to the constant.
I've also tried a search in the installed Arduino IDE with SAMD and Adafruit SAMD libraries installed. For example
~/Arduino$ grep -r --include=*.h --include=*.cpp "TC.*_PRESCALER_DIV"
Did not yield anything. I apologize if this is a naive question, but I haven't been able to find a simple, obvious answer. Actually, I haven't been able to find any answer.
library constants samd21g
add a comment |Â
up vote
2
down vote
favorite
Preamble:
I am trying to figure out how to program and use the timers in the Feather M0 using the Arduino IDE. I have seen a number of examples published, but I'm not one to just blindly copy some code and expect it to work. The issue that I'm having (and it seems to be ubiquitous in Arduino) is that there does not seem to be a concept of dependencies. In order to reference constants, they have to be defined somewhere.
Question:
How can I find the source of the definition of the constants that people keep referring to in their code? For example, in this code a Arduino Zero, M0 timer example, reference is made to TC_CTRLA_PRESCALER_DIV1 among other constants. Where is this constant defined?
Efforts:
I've searched generally and specifically for these constants. But, as you would imagine in C, it's difficult to find the actual source versus a simple reference to the constant.
I've also tried a search in the installed Arduino IDE with SAMD and Adafruit SAMD libraries installed. For example
~/Arduino$ grep -r --include=*.h --include=*.cpp "TC.*_PRESCALER_DIV"
Did not yield anything. I apologize if this is a naive question, but I haven't been able to find a simple, obvious answer. Actually, I haven't been able to find any answer.
library constants samd21g
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Preamble:
I am trying to figure out how to program and use the timers in the Feather M0 using the Arduino IDE. I have seen a number of examples published, but I'm not one to just blindly copy some code and expect it to work. The issue that I'm having (and it seems to be ubiquitous in Arduino) is that there does not seem to be a concept of dependencies. In order to reference constants, they have to be defined somewhere.
Question:
How can I find the source of the definition of the constants that people keep referring to in their code? For example, in this code a Arduino Zero, M0 timer example, reference is made to TC_CTRLA_PRESCALER_DIV1 among other constants. Where is this constant defined?
Efforts:
I've searched generally and specifically for these constants. But, as you would imagine in C, it's difficult to find the actual source versus a simple reference to the constant.
I've also tried a search in the installed Arduino IDE with SAMD and Adafruit SAMD libraries installed. For example
~/Arduino$ grep -r --include=*.h --include=*.cpp "TC.*_PRESCALER_DIV"
Did not yield anything. I apologize if this is a naive question, but I haven't been able to find a simple, obvious answer. Actually, I haven't been able to find any answer.
library constants samd21g
Preamble:
I am trying to figure out how to program and use the timers in the Feather M0 using the Arduino IDE. I have seen a number of examples published, but I'm not one to just blindly copy some code and expect it to work. The issue that I'm having (and it seems to be ubiquitous in Arduino) is that there does not seem to be a concept of dependencies. In order to reference constants, they have to be defined somewhere.
Question:
How can I find the source of the definition of the constants that people keep referring to in their code? For example, in this code a Arduino Zero, M0 timer example, reference is made to TC_CTRLA_PRESCALER_DIV1 among other constants. Where is this constant defined?
Efforts:
I've searched generally and specifically for these constants. But, as you would imagine in C, it's difficult to find the actual source versus a simple reference to the constant.
I've also tried a search in the installed Arduino IDE with SAMD and Adafruit SAMD libraries installed. For example
~/Arduino$ grep -r --include=*.h --include=*.cpp "TC.*_PRESCALER_DIV"
Did not yield anything. I apologize if this is a naive question, but I haven't been able to find a simple, obvious answer. Actually, I haven't been able to find any answer.
library constants samd21g
edited 10 hours ago
Greenonline
1,83841439
1,83841439
asked 11 hours ago
BE-Bob
111
111
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:
- File > Preferences > Compiler Warnings > All > OK
In your sketch, add a
#definedirective for the macro name that definitely changes the definition:#define TC_CTRLA_PRESCALER_DIV1 foobarSketch > Verify/Compile
- After the compilation finishes, examine the compiler output in the black console window at the bottom of the Arduino IDE window (you will need to scroll up to see it all) for a "macro redefined" warning. The warning will state the path of the original definition:
C:UsersperAppDataLocalTemparduino_modified_sketch_804921sketch_aug05a.ino:1:0: warning: "TC_CTRLA_PRESCALER_DIV1" redefined [enabled by default]
#define TC_CTRLA_PRESCALER_DIV1 foobar
^
In file included from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:268:0,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd.h:105,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/sam.h:470,
from C:UsersperAppDataLocalArduino15packagesarduinohardwaresamd1.6.19coresarduino/Arduino.h:48,
from C:UsersperAppDataLocalTemparduino_build_309126sketchsketch_aug05a.ino.cpp:1:
C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/component/tc.h:113:0: note: this is the location of the previous definition
#define TC_CTRLA_PRESCALER_DIV1 (TC_CTRLA_PRESCALER_DIV1_Val << TC_CTRLA_PRESCALER_Pos)
^
add a comment |Â
up vote
1
down vote
First of all, the definitions of these constants won't tell you very much. They just represent the registers and bits used in the datasheet of the microcontroller.
If you do want to find their definitions, try looking in ~/.arduino15/.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:
- File > Preferences > Compiler Warnings > All > OK
In your sketch, add a
#definedirective for the macro name that definitely changes the definition:#define TC_CTRLA_PRESCALER_DIV1 foobarSketch > Verify/Compile
- After the compilation finishes, examine the compiler output in the black console window at the bottom of the Arduino IDE window (you will need to scroll up to see it all) for a "macro redefined" warning. The warning will state the path of the original definition:
C:UsersperAppDataLocalTemparduino_modified_sketch_804921sketch_aug05a.ino:1:0: warning: "TC_CTRLA_PRESCALER_DIV1" redefined [enabled by default]
#define TC_CTRLA_PRESCALER_DIV1 foobar
^
In file included from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:268:0,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd.h:105,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/sam.h:470,
from C:UsersperAppDataLocalArduino15packagesarduinohardwaresamd1.6.19coresarduino/Arduino.h:48,
from C:UsersperAppDataLocalTemparduino_build_309126sketchsketch_aug05a.ino.cpp:1:
C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/component/tc.h:113:0: note: this is the location of the previous definition
#define TC_CTRLA_PRESCALER_DIV1 (TC_CTRLA_PRESCALER_DIV1_Val << TC_CTRLA_PRESCALER_Pos)
^
add a comment |Â
up vote
2
down vote
The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:
- File > Preferences > Compiler Warnings > All > OK
In your sketch, add a
#definedirective for the macro name that definitely changes the definition:#define TC_CTRLA_PRESCALER_DIV1 foobarSketch > Verify/Compile
- After the compilation finishes, examine the compiler output in the black console window at the bottom of the Arduino IDE window (you will need to scroll up to see it all) for a "macro redefined" warning. The warning will state the path of the original definition:
C:UsersperAppDataLocalTemparduino_modified_sketch_804921sketch_aug05a.ino:1:0: warning: "TC_CTRLA_PRESCALER_DIV1" redefined [enabled by default]
#define TC_CTRLA_PRESCALER_DIV1 foobar
^
In file included from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:268:0,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd.h:105,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/sam.h:470,
from C:UsersperAppDataLocalArduino15packagesarduinohardwaresamd1.6.19coresarduino/Arduino.h:48,
from C:UsersperAppDataLocalTemparduino_build_309126sketchsketch_aug05a.ino.cpp:1:
C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/component/tc.h:113:0: note: this is the location of the previous definition
#define TC_CTRLA_PRESCALER_DIV1 (TC_CTRLA_PRESCALER_DIV1_Val << TC_CTRLA_PRESCALER_Pos)
^
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:
- File > Preferences > Compiler Warnings > All > OK
In your sketch, add a
#definedirective for the macro name that definitely changes the definition:#define TC_CTRLA_PRESCALER_DIV1 foobarSketch > Verify/Compile
- After the compilation finishes, examine the compiler output in the black console window at the bottom of the Arduino IDE window (you will need to scroll up to see it all) for a "macro redefined" warning. The warning will state the path of the original definition:
C:UsersperAppDataLocalTemparduino_modified_sketch_804921sketch_aug05a.ino:1:0: warning: "TC_CTRLA_PRESCALER_DIV1" redefined [enabled by default]
#define TC_CTRLA_PRESCALER_DIV1 foobar
^
In file included from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:268:0,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd.h:105,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/sam.h:470,
from C:UsersperAppDataLocalArduino15packagesarduinohardwaresamd1.6.19coresarduino/Arduino.h:48,
from C:UsersperAppDataLocalTemparduino_build_309126sketchsketch_aug05a.ino.cpp:1:
C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/component/tc.h:113:0: note: this is the location of the previous definition
#define TC_CTRLA_PRESCALER_DIV1 (TC_CTRLA_PRESCALER_DIV1_Val << TC_CTRLA_PRESCALER_Pos)
^
The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:
- File > Preferences > Compiler Warnings > All > OK
In your sketch, add a
#definedirective for the macro name that definitely changes the definition:#define TC_CTRLA_PRESCALER_DIV1 foobarSketch > Verify/Compile
- After the compilation finishes, examine the compiler output in the black console window at the bottom of the Arduino IDE window (you will need to scroll up to see it all) for a "macro redefined" warning. The warning will state the path of the original definition:
C:UsersperAppDataLocalTemparduino_modified_sketch_804921sketch_aug05a.ino:1:0: warning: "TC_CTRLA_PRESCALER_DIV1" redefined [enabled by default]
#define TC_CTRLA_PRESCALER_DIV1 foobar
^
In file included from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:268:0,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd.h:105,
from C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/sam.h:470,
from C:UsersperAppDataLocalArduino15packagesarduinohardwaresamd1.6.19coresarduino/Arduino.h:48,
from C:UsersperAppDataLocalTemparduino_build_309126sketchsketch_aug05a.ino.cpp:1:
C:UsersperAppDataLocalArduino15packagesarduinotoolsCMSIS-Atmel1.1.0/CMSIS/Device/ATMEL/samd21/include/component/tc.h:113:0: note: this is the location of the previous definition
#define TC_CTRLA_PRESCALER_DIV1 (TC_CTRLA_PRESCALER_DIV1_Val << TC_CTRLA_PRESCALER_Pos)
^
edited 7 hours ago
answered 9 hours ago
per1234
2,66211029
2,66211029
add a comment |Â
add a comment |Â
up vote
1
down vote
First of all, the definitions of these constants won't tell you very much. They just represent the registers and bits used in the datasheet of the microcontroller.
If you do want to find their definitions, try looking in ~/.arduino15/.
add a comment |Â
up vote
1
down vote
First of all, the definitions of these constants won't tell you very much. They just represent the registers and bits used in the datasheet of the microcontroller.
If you do want to find their definitions, try looking in ~/.arduino15/.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
First of all, the definitions of these constants won't tell you very much. They just represent the registers and bits used in the datasheet of the microcontroller.
If you do want to find their definitions, try looking in ~/.arduino15/.
First of all, the definitions of these constants won't tell you very much. They just represent the registers and bits used in the datasheet of the microcontroller.
If you do want to find their definitions, try looking in ~/.arduino15/.
answered 11 hours ago
tttapa
830118
830118
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f55047%2fhow-to-determine-the-source-of-constants-in-libraries%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
