How to determine the source of constants in libraries?

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question

























    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.







    share|improve this question























      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.







      share|improve this question













      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.









      share|improve this question












      share|improve this question




      share|improve this question








      edited 10 hours ago









      Greenonline

      1,83841439




      1,83841439









      asked 11 hours ago









      BE-Bob

      111




      111




















          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:



          1. File > Preferences > Compiler Warnings > All > OK


          2. In your sketch, add a #define directive for the macro name that definitely changes the definition:



            #define TC_CTRLA_PRESCALER_DIV1 foobar


          3. Sketch > Verify/Compile


          4. 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)

          ^





          share|improve this answer






























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






            share|improve this answer





















              Your Answer





              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("schematics", function ()
              StackExchange.schematics.init();
              );
              , "cicuitlab");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "540"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );








               

              draft saved


              draft discarded


















              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






























              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:



              1. File > Preferences > Compiler Warnings > All > OK


              2. In your sketch, add a #define directive for the macro name that definitely changes the definition:



                #define TC_CTRLA_PRESCALER_DIV1 foobar


              3. Sketch > Verify/Compile


              4. 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)

              ^





              share|improve this answer



























                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:



                1. File > Preferences > Compiler Warnings > All > OK


                2. In your sketch, add a #define directive for the macro name that definitely changes the definition:



                  #define TC_CTRLA_PRESCALER_DIV1 foobar


                3. Sketch > Verify/Compile


                4. 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)

                ^





                share|improve this answer

























                  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:



                  1. File > Preferences > Compiler Warnings > All > OK


                  2. In your sketch, add a #define directive for the macro name that definitely changes the definition:



                    #define TC_CTRLA_PRESCALER_DIV1 foobar


                  3. Sketch > Verify/Compile


                  4. 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)

                  ^





                  share|improve this answer















                  The name TC_CTRLA_PRESCALER_DIV1 indicates this is a macro. A trick for quickly finding the exact location of a macro definition is:



                  1. File > Preferences > Compiler Warnings > All > OK


                  2. In your sketch, add a #define directive for the macro name that definitely changes the definition:



                    #define TC_CTRLA_PRESCALER_DIV1 foobar


                  3. Sketch > Verify/Compile


                  4. 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)

                  ^






                  share|improve this answer















                  share|improve this answer



                  share|improve this answer








                  edited 7 hours ago


























                  answered 9 hours ago









                  per1234

                  2,66211029




                  2,66211029




















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






                      share|improve this answer

























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






                        share|improve this answer























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






                          share|improve this answer













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







                          share|improve this answer













                          share|improve this answer



                          share|improve this answer











                          answered 11 hours ago









                          tttapa

                          830118




                          830118






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              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













































































                              Comments

                              Popular posts from this blog

                              What is the equation of a 3D cone with generalised tilt?

                              Relationship between determinant of matrix and determinant of adjoint?

                              Color the edges and diagonals of a regular polygon