7 Replies Latest reply on Feb 5, 2014 9:13 AM by user_246598725

    API generation wizard

    user_246598725

      Hi,

         

       

         

      I'm dealing with my first custom component The UDB part has been finished, now the API has to be generated. After that I can go into testing/debugging my component.

         

       

         

      So, first I want to make the suggestion that there should be an API wizard to help to create the API files.

         

      This also leads to my question: How to?

         

      All I found regarding API implementation is http://www.cypress.com/?docID=31502 , but it only makes recommendations about which API functions should be included, but it's not explained in detail how to do it right.

         

      Now, I'm a bit lost. Seems that API generation is a big part by itself. Currently I'm looking into the components provided by Cypress to figure out how to create APIs, but this not very effective.

         

       

         

      Anyone can help?

         

       

         

      Regards,

         

       

         

      Ralf

        • 1. Re: API generation wizard
          user_1377889

          The matter is not too complicated, but unfortunately there is no API generation wizard afaik.

             

          Just like writing your own set of procedures to access a usermodule you'll have to write a template-file (.c) from which the .c-file is generated. To allow for multiple instances of your module all routine-names and globals have to be prepended by the actual choosen module-name. This is accomplished by prepending all APIs with

             

          `instance_name`_

             

          which will be replaced in the code-generating step with the choosen name.

             

           

             

          Bob

          • 2. Re: API generation wizard
            user_246598725

            Hi Bob,

               

             

               

            the matter is not too complicated, but unfortunately there is no API generation wizard afaik.

               

            Would be a nice feature. It seems that the API creation part is not documented in detail at all... maybe Cypress should provide an application note regarding API creation.

               

             

               

            Just like writing your own set of procedures to access a usermodule you'll have to write a template-file (.c) from which the .c-file is generated. To allow for multiple instances of your module all routine-names and globals have to be prepended by the actual choosen module-name. This is accomplished by prepending all APIs with `instance_name`_ which will be replaced in the code-generating step with the choosen name.

               

            But which procedures to implement (beside the functions necessary to use the component)? For example, if I take the document from my above link as a base, it states that at least the following functions should be implemented:

               
                  
            1. `$INSTANCE_NAME`_Start()
            2.     
            3. `$INSTANCE_NAME`_Stop()
            4.     
            5. `$INSTANCE_NAME`_Sleep()
            6.     
            7. `$INSTANCE_NAME`_Wakeup()
            8.     
            9. `$INSTANCE_NAME`_SaveConfig ()
            10.     
            11. `$INSTANCE_NAME`_RestoreConfig()
            12.     
            13. `$INSTANCE_NAME`_Init()
            14.     
            15. `$INSTANCE_NAME`_Enable()
            16.     
            17. `$INSTANCE_NAME`_SetPower() (If any Analog Block is being used in the component)
            18.    
               

            Now, using the clock component datasheet as an example, there's no Init() function... (keep in mind, I used clock component as example). On the other side, the shift register component has all of the above mentioned functions (except SetPower()) - fine. Digging deeper, you can see that the Start() function calls the Init() and Enable() functions - is this according to a guideline, is it a rule or is it simply up to the developer which functions are provided? Another example, take the above mentioned SaveConfig()/RestoreConfig() functions - they have to store the components non-retention data prior to entering a reduced power state. But, how should I know where I have to save the data? How to make this device dependant?

               

            Is it really that simple that each developer can implement it freely on his own?

               

             

               

            Regards,

               

             

               

            Ralf

            • 3. Re: API generation wizard
              user_1377889

              Ralf,

                 

              Q: "Is it really that simple that each developer can implement it freely on his own?"

                 

              A: "Yes"

                 

               

                 

              Bob

              • 4. Re: API generation wizard
                user_1377889

                Q:"But, how should I know where I have to save the (initial) data? How to make this device dependant? "

                   

                A: struct ModuleDataStruct `instance_name`_SaveArea;

                   

                and define the struct just as you need it.

                   

                -That easy

                   

                 

                   

                Bob

                • 5. Re: API generation wizard
                  user_246598725
                          Hi Bob, thank you very much for trying to help me :) Okay, if it's really on my own, I'll do so. After reading your second post I realized it's really simple: simply save the non-retention values to a memory location which retains it's state. It seems that I'm thinking too complex at the moment. I'll implement an API and post the component when (I think) it's finished. Regards, Ralf   
                  • 6. Re: API generation wizard
                    user_1377889

                    When you start posting your component (with some docs) BEFORE (you think) it is finished we might have an eye on it and may give you more help.

                       

                     

                       

                    Bob

                    • 7. Re: API generation wizard
                      user_246598725

                      Hi Bob,

                         

                       

                         

                      that sounds great.

                         

                      I'll post the component if I have it up and running, along with documentation.

                         

                       

                         

                      Regards,

                         

                       

                         

                      Ralf