Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 15.1 nrfx_qspi.h wont compile under C++

The gnu C++ compiler wont do non trivial assignments designated initialisers, but by simply reordering this will work, Its a bit annoying, 

nrfx_qspi.h line 73 replace with the following...

/**
 * @brief QSPI instance default configuration.
 */
#define NRFX_QSPI_DEFAULT_CONFIG                                        \
{                                                                       \
    .xip_offset  = NRFX_QSPI_CONFIG_XIP_OFFSET,                         \
    .pins = {                                                           \
       .sck_pin     = NRFX_QSPI_PIN_SCK,                                \
       .csn_pin     = NRFX_QSPI_PIN_CSN,                                \
       .io0_pin     = NRFX_QSPI_PIN_IO0,                                \
       .io1_pin     = NRFX_QSPI_PIN_IO1,                                \
       .io2_pin     = NRFX_QSPI_PIN_IO2,                                \
       .io3_pin     = NRFX_QSPI_PIN_IO3,                                \
    },                                                                  \
    .prot_if = {                                                        \
        .readoc     = (nrf_qspi_readoc_t)NRFX_QSPI_CONFIG_READOC,       \
        .writeoc    = (nrf_qspi_writeoc_t)NRFX_QSPI_CONFIG_WRITEOC,     \
        .addrmode   = (nrf_qspi_addrmode_t)NRFX_QSPI_CONFIG_ADDRMODE,   \
        .dpmconfig  = false,                                            \
    },                                                                  \
    .phy_if = {                                                         \
        .sck_delay  = (uint8_t)NRFX_QSPI_CONFIG_SCK_DELAY,              \
        .dpmen      = false,                                            \
        .spi_mode   = (nrf_qspi_spi_mode_t)NRFX_QSPI_CONFIG_MODE,       \
        .sck_freq   = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY, \
    },                                                                  \
    .irq_priority   = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY,           \
}

Parents Reply Children
  • Hi,

    Unfortunately yes, we were made aware of this issue too late for including any patch for it in the v15.2 release.

    Regards,
    Terje

  • No problem I have to patch a few files to get C++ to work, ie 

    app_util.h,

    nrf_pwr_mgmt.h

    nrfx_qspi.h 

  • Hi,

    I see. What are the required changes, is there anything we should do in those files to facilitate C++?

    Regards,
    Terje

  • nrfx_qspi.h:
    o rearrange the static initialisers in order of declaration
    @@ -83,0 +84 @@ typedef struct
    +    .irq_priority   = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY,           \
    @@ -90,0 +92 @@ typedef struct
    +        .sck_freq   = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY, \
    @@ -92 +93,0 @@ typedef struct
    -        .dpmen      = false,                                            \
    @@ -94 +95 @@ typedef struct
    -        .sck_freq   = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY, \
    +        .dpmen      = false                                             \
    @@ -96 +96,0 @@ typedef struct
    -    .irq_priority   = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY,           \
    nrf_pwr_mgmt.h:
    o Add a C++ inclusion guard
    @@ -55,5 +54,0 @@
    -#ifdef __cplusplus
    -extern "C" {
    -#endif
    -
    @@ -154,4 +148,0 @@ void nrf_pwr_mgmt_shutdown(nrf_pwr_mgmt_shutdown_t
    -#ifdef __cplusplus
    -}
    -#endif
    app_util.h
    o comment out the STATIC ASSERTs
    @@ -206,2 +206,2 @@ enum
    -#define STATIC_ASSERT_SIMPLE(EXPR)      //_Static_assert(EXPR, "unspecified message")
    -#define STATIC_ASSERT_MSG(EXPR, MSG)    //_Static_assert(EXPR, MSG)
    +#define STATIC_ASSERT_SIMPLE(EXPR)      _Static_assert(EXPR, "unspecified message")
    +#define STATIC_ASSERT_MSG(EXPR, MSG)    _Static_assert(EXPR, MSG)
  • Hi,

    Thank you! We may choose to do some changes to the SDK in the future, for better compatibility with C++, based on your feedback.

    Regards,
    Terje

Related