This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Detect in my SES source code using a #define whether compiling for the nRF9160 DK or the Thingy91

Shalom!

 I want my code example to be able to run on both the nRF9160 and the Thingy91. I ran the SES Open nRF project menu twice and have two separate build folders under my project with different SES project files. I can't find in the UI or the files how I can in my common code use a #ifdef to differentiate between the builds. When I set a Project solution build macro, it is undetectable by my code.

 In my sample code, I use UART_0 serial port and blink a LED.

Is UART_0 used on both boards?

Thanks David

Parents
  • Hi,

    A simple way to check which board is being used is to check the define CONFIG_BOARD, which should be defined as the current board. "nrf9160dk_nrf9160" or "thingy91_nrf9160" for your two cases.

    There are also specific defines for each board, CONFIG_BOARD_NRF9160DK_NRF9160 for example. Unlike CONFIG_BOARD, these differentiate between secure and non-secure applications, so a non-secure application on the nRF9160DK would set CONFIG_BOARD_NRF9160DK_NRF9160NS.

    UART_0 is by default used for logging on both the nRF9160DK and the Thingy91.

Reply
  • Hi,

    A simple way to check which board is being used is to check the define CONFIG_BOARD, which should be defined as the current board. "nrf9160dk_nrf9160" or "thingy91_nrf9160" for your two cases.

    There are also specific defines for each board, CONFIG_BOARD_NRF9160DK_NRF9160 for example. Unlike CONFIG_BOARD, these differentiate between secure and non-secure applications, so a non-secure application on the nRF9160DK would set CONFIG_BOARD_NRF9160DK_NRF9160NS.

    UART_0 is by default used for logging on both the nRF9160DK and the Thingy91.

Children
Related