- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
is it possible to add kind of meta data or custom component parameters to the PSoC Creator components, that would be appear then in defs.h auto generated file?
Use case: same device driver can be used for slightly modified configuration, version compatibility check, .. etc.
BR Uros
Solved! Go to Solution.
- Labels:
-
PSoC general
- Tags:
- psoc creator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Uros,
I'm assuming you've already imported the component you are interested in modifying as Ekta suggested.
Here's an example of one of my custom components:
- In the "Components" tab, find the "<Component_name>_v<version>.cysym" file and open it (double-click)
- Right-click outside the symbol and select "Symbol Parameters..."
- In the "Paramemters Definition" window that pops up select the icon.
- A new window will pop up called "Create Parameter Definition". Here you can create your formal parameter to be shared outside the component.
You can change ALL the fields shown. The "Param name:" is used in a later step. The "Expr type:" is particularly useful to describe the way to treat the parameter in the "C" expression.
"Tab name:" and "Category:" are conveniences for parameter organization and do not effect the "C" result.
- Here an example list of some of my custom parameters.
- For this custom component I "Add Component Item..." "API Header File" called TMatch.h and selected "Create New"
In the TMatch.h file I added some useful #ifdef and #defines
#if !defined(`$INSTANCE_NAME`_TMATCH_H) #define `$INSTANCE_NAME`_TMATCH_H #include "add more include files if needed" /* Interrupt enable defines */ #define `$INSTANCE_NAME`_FIFO_FULL_INT_EN `$Full_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_FIFO_NOTEMPTY_INT_EN `$NotEmpty_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_FIFO_OVER_INT_EN `$Overrun_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_WATER_MARK_INT_EN `$WMark_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_HEAD_000_INT_EN `$Head0_Int_en` /* 1= Enabled */ ... more #defines and function prototypes if needed #endif //`$INSTANCE_NAME`_TMATCH_H /* [] END OF FILE */
- You will notice that I attached a "`$INSTANCE_NAME` prefix to my defined variables.
- You also notice the parameters I created in a previous step are listed as `$<param_name>`
- If your new component builds properly, and you place the component in your TopDesign correctly with an instance name, you should be able to resolve the parameters and it should be listed to a ".h" (or if you want a ".c" file" with the parameter value assigned.
Hopefully this will help.#if !defined(TMatch_TMATCH_H) #define TMatch_TMATCH_H #include "..." /* Interrupt enable defines */ #define TMatch_FIFO_FULL_INT_EN 0 /* 1= Enabled */ #define TMatch_FIFO_NOTEMPTY_INT_EN 0 /* 1= Enabled */ #define TMatch_FIFO_OVER_INT_EN 0 /* 1= Enabled */ #define TMatch_WATER_MARK_INT_EN 0 /* 1= Enabled */ #define TMatch_HEAD_000_INT_EN 0 /* 1= Enabled */ /* Interrupt shift position defines */ #define TMatch_FIFO_FULL_INT_SHIFT 0u #define TMatch_FIFO_NOTEMPTY_INT_SHIFT 1u #define TMatch_FIFO_OVER_INT_SHIFT 2u #define TMatch_WATER_MARK_INT_SHIFT 3u #define TMatch_HEAD_000_INT_SHIFT 4u ... #endif //TMatch_TMATCH_H /* [] END OF FILE */
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi BR Uros,
You can refer to the following KBA: https://community.cypress.com/t5/Knowledge-Base-Articles/Customizing-a-Component-using-PSoC-Creator-... which mentions how you can import an already available component, make changes in it and use the modified component in your project.
This would enable you to edit the generated source files directly. In case you want to change the component parameters that are displayed in the component configurator you can refer to the following appnote: https://www.cypress.com/documentation/application-notes/an82156-psoc-3-psoc-4-and-psoc-5lp-designing... which describes the same.
Kindly let me know if this is what you were looking for.
Best Regards
Ekta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ekta,
for given custom block, see picture, I've added a parameter driver_api:
but the _defs does not include it, and my question is, how to make / add a parameter that is also exported to the _defs?
#include "cyfitter.h"
#if ((CYDEV_CHIP_FAMILY_USED == CYDEV_CHIP_FAMILY_PSOC3) || \
(CYDEV_CHIP_FAMILY_USED == CYDEV_CHIP_FAMILY_PSOC4) || \
(CYDEV_CHIP_FAMILY_USED == CYDEV_CHIP_FAMILY_PSOC5))
#include "cytypes.h"
#else
#include "syslib/cy_syslib.h"
#endif
/* Note: Register pointers (denoted by a _PTR suffix) should be accessed
* via the CY_GET_REGn and CY_SET_REGn macros (defined in cytypes.h),
* where n is the width of the datapath with which they are associated.
*/
/******************** Datapath_1 (Width: 😎 Definitions ********************/
#define ad7768_1cmd_1_Datapath_1_A0_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__A0_REG)
#define ad7768_1cmd_1_Datapath_1_A0_REG (* ad7768_1cmd_1_Datapath_1_A0_PTR)
#define ad7768_1cmd_1_Datapath_1_A1_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__A1_REG)
#define ad7768_1cmd_1_Datapath_1_A1_REG (* ad7768_1cmd_1_Datapath_1_A1_PTR)
#define ad7768_1cmd_1_Datapath_1_D0_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__D0_REG)
#define ad7768_1cmd_1_Datapath_1_D0_REG (* ad7768_1cmd_1_Datapath_1_D0_PTR)
#define ad7768_1cmd_1_Datapath_1_D1_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__D1_REG)
#define ad7768_1cmd_1_Datapath_1_D1_REG (* ad7768_1cmd_1_Datapath_1_D1_PTR)
#define ad7768_1cmd_1_Datapath_1_F0_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__F0_REG)
#define ad7768_1cmd_1_Datapath_1_F0_REG (* ad7768_1cmd_1_Datapath_1_F0_PTR)
#define ad7768_1cmd_1_Datapath_1_F1_PTR ((reg8 *) ad7768_1cmd_1_Datapath_1_u0__F1_REG)
#define ad7768_1cmd_1_Datapath_1_F1_REG (* ad7768_1cmd_1_Datapath_1_F1_PTR)
/* Note: To avoid corruption of a shared register, call the following registers from within
* a critical section (See Component Author Guide for details).
*/
/* Macros to clear DP FIFOs.*/
#define ad7768_1cmd_1_Datapath_1_F0_CLEAR do { \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x01u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)));\
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xfeu & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)));\
} while(0)
#define ad7768_1cmd_1_Datapath_1_F1_CLEAR do { \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x02u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)));\
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xfdu & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)));\
} while(0)
/* Macros to set FIFO level mode. See the TRM for details */
#define ad7768_1cmd_1_Datapath_1_F0_SET_LEVEL_NORMAL \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xfbu & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
#define ad7768_1cmd_1_Datapath_1_F1_SET_LEVEL_NORMAL \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xf7u & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
#define ad7768_1cmd_1_Datapath_1_F0_SET_LEVEL_MID \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x04u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
#define ad7768_1cmd_1_Datapath_1_F1_SET_LEVEL_MID \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x08u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
/* Macros to set FIFO to single-buffer mode. */
#define ad7768_1cmd_1_Datapath_1_F0_SINGLE_BUFFER_SET \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x01u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
#define ad7768_1cmd_1_Datapath_1_F1_SINGLE_BUFFER_SET \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0x02u | \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
/* Macros to return the FIFO to normal mode. */
#define ad7768_1cmd_1_Datapath_1_F0_SINGLE_BUFFER_UNSET \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xfeu & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
#define ad7768_1cmd_1_Datapath_1_F1_SINGLE_BUFFER_UNSET \
CY_SET_XTND_REG8(\
((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG), 0xfdu & \
CY_GET_XTND_REG8(((reg8 *) ad7768_1cmd_1_Datapath_1_u0__DP_AUX_CTL_REG)))
/* End macros which should be called from within a critical section */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ekta,
for a custom component you can add parameters (that are later configured using "configure"). How to get these into the auto-generated _defs.h file?
Uros
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Uros,
I'm assuming you've already imported the component you are interested in modifying as Ekta suggested.
Here's an example of one of my custom components:
- In the "Components" tab, find the "<Component_name>_v<version>.cysym" file and open it (double-click)
- Right-click outside the symbol and select "Symbol Parameters..."
- In the "Paramemters Definition" window that pops up select the icon.
- A new window will pop up called "Create Parameter Definition". Here you can create your formal parameter to be shared outside the component.
You can change ALL the fields shown. The "Param name:" is used in a later step. The "Expr type:" is particularly useful to describe the way to treat the parameter in the "C" expression.
"Tab name:" and "Category:" are conveniences for parameter organization and do not effect the "C" result.
- Here an example list of some of my custom parameters.
- For this custom component I "Add Component Item..." "API Header File" called TMatch.h and selected "Create New"
In the TMatch.h file I added some useful #ifdef and #defines
#if !defined(`$INSTANCE_NAME`_TMATCH_H) #define `$INSTANCE_NAME`_TMATCH_H #include "add more include files if needed" /* Interrupt enable defines */ #define `$INSTANCE_NAME`_FIFO_FULL_INT_EN `$Full_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_FIFO_NOTEMPTY_INT_EN `$NotEmpty_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_FIFO_OVER_INT_EN `$Overrun_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_WATER_MARK_INT_EN `$WMark_Int_en` /* 1= Enabled */ #define `$INSTANCE_NAME`_HEAD_000_INT_EN `$Head0_Int_en` /* 1= Enabled */ ... more #defines and function prototypes if needed #endif //`$INSTANCE_NAME`_TMATCH_H /* [] END OF FILE */
- You will notice that I attached a "`$INSTANCE_NAME` prefix to my defined variables.
- You also notice the parameters I created in a previous step are listed as `$<param_name>`
- If your new component builds properly, and you place the component in your TopDesign correctly with an instance name, you should be able to resolve the parameters and it should be listed to a ".h" (or if you want a ".c" file" with the parameter value assigned.
Hopefully this will help.#if !defined(TMatch_TMATCH_H) #define TMatch_TMATCH_H #include "..." /* Interrupt enable defines */ #define TMatch_FIFO_FULL_INT_EN 0 /* 1= Enabled */ #define TMatch_FIFO_NOTEMPTY_INT_EN 0 /* 1= Enabled */ #define TMatch_FIFO_OVER_INT_EN 0 /* 1= Enabled */ #define TMatch_WATER_MARK_INT_EN 0 /* 1= Enabled */ #define TMatch_HEAD_000_INT_EN 0 /* 1= Enabled */ /* Interrupt shift position defines */ #define TMatch_FIFO_FULL_INT_SHIFT 0u #define TMatch_FIFO_NOTEMPTY_INT_SHIFT 1u #define TMatch_FIFO_OVER_INT_SHIFT 2u #define TMatch_WATER_MARK_INT_SHIFT 3u #define TMatch_HEAD_000_INT_SHIFT 4u ... #endif //TMatch_TMATCH_H /* [] END OF FILE */
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Len.