- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- `$INSTANCE_NAME`_Start()
- `$INSTANCE_NAME`_Stop()
- `$INSTANCE_NAME`_Sleep()
- `$INSTANCE_NAME`_Wakeup()
- `$INSTANCE_NAME`_SaveConfig ()
- `$INSTANCE_NAME`_RestoreConfig()
- `$INSTANCE_NAME`_Init()
- `$INSTANCE_NAME`_Enable()
- `$INSTANCE_NAME`_SetPower() (If any Analog Block is being used in the component)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ralf,
Q: "Is it really that simple that each developer can implement it freely on his own?"
A: "Yes"
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
that sounds great.
I'll post the component if I have it up and running, along with documentation.
Regards,
Ralf