2 Replies Latest reply on Aug 10, 2018 2:54 AM by DheerajK_81

    How to list predefined macros in the preprocessor

    riluc_3624676

      Hi, I'm working on porting the Marlin 3D printing firmware to the PSoC 4 architecture, I have downloaded the Marlin repository and the conditional compiling checks for predefined macros to see what type of architecture/chip you are compiling to. I'm wandering if there are similar system specific predefined macros in the PSoC IDE preprocessor to tell the compiler to use the files I'll write. Something like "__TARGET_CY8C_4125__" or "__CY_4100_FAMILY__" as shown below:

       

      #ifdef __AVR__

        #define HAL_PLATFORM HAL_AVR

      #elif defined(ARDUINO_ARCH_SAM)

        #define HAL_PLATFORM HAL_DUE

      #elif defined(__MK64FX512__) || defined(__MK66FX1M0__)

        #define HAL_PLATFORM HAL_TEENSY35_36

      #elif defined(TARGET_LPC1768)

        #define HAL_PLATFORM HAL_LPC1768

      #elif defined(__STM32F1__) || defined(TARGET_STM32F1)

        #define HAL_PLATFORM HAL_STM32F1

      #elif defined(STM32F4) || defined(STM32F4xx)

        #define HAL_PLATFORM HAL_STM32F4

      #elif defined(STM32F7)

        #define HAL_PLATFORM HAL_STM32F7

      #elif defined(ARDUINO_ARCH_ESP32)

        #define HAL_PLATFORM HAL_ESP32

      #else

        #error "Unsupported Platform!"

      #endif

      At the moment I'm getting the "Unsupported Platform!" error as expected. I checked the GNU documentation included with PSoC creator and it says I can run the preprocessor alone with cpp -dM but I don't know where it is located to run it from the cmd window.

       

      Thanks for your feedback.

        • 1. Re: How to list predefined macros in the preprocessor
          riluc_3624676

          So, I think I found the preprocessor and run with -dM but output is empty:

          Something else I'm missing?

          • 2. Re: How to list predefined macros in the preprocessor
            DheerajK_81

            You can go over to Help > System Reference Guides in PSoC Creator where all the device macros are listed in page 15 under the section Device Version Defines.

            macro.PNG

            I have mentioned a small code snippet to help you understand how it is implemented:

             

            #define CY_PSOC4A  (CYDEV_CHIP_MEMBER_USED == CYDEV_CHIP_MEMBER_4A)

            #ifdef CYDEV_CHIP_MEMBER_4D

                #define CY_PSOC4D (CYDEV_CHIP_MEMBER_USED == CYDEV_CHIP_MEMBER_4D)

                #define CY_PSOC4SF (CY_PSOC4D)

            #else

                #define CY_PSOC4D (0u != 0u)

                #define CY_PSOC4SF (CY_PSOC4D)

            #endif

             

            I recommend you to run any code example which is listed for multiple boards and then view the entire implementation in the cytypes.h file.

             

            Regards,

            Dheeraj