Useful PSoC Macros
Working Out What PSoC IC You Are Using
PSoC Creator will define the following variable-like macros depending on what IC you’ve instructed it to compile for. These are useful for including IC-specific blocks of code using the preprocessor
#ifdef directives. These macros are defined in
cytypes.h, which is in the
cy_boot folder under “Generated_Source” in the Workspace Explorer window in PSoC Creator. They are included if you include the standard PSoC catch-all header
<device.h> into your code.
Note that these are only define once the precompiler passes the line
#define <device.h>, therefore there is no way to write code that detects if you are compiling on a PSoC chip, and if so, then including
device.h. A way to get around this is to add a compiler macro as a compiler flag (e.g.
-D PSOC), and then use the following code.
This work is licensed under a Creative Commons Attribution 4.0 International License .