Undefined NRF_DRV_SPI_INSTANCE() macro

Hi,

I am trying to compile an old project.

I am using SEGGER_Embedded_Studio_Nordic_v568_win_x64 with nRF5_SDK_17.0.2

I am getting an error message for the following line;

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);

And SPI_INSTANCE is zero.

Here below the error message;

implicit declaration of function 'NRF_DRV_SPI_INSTANCE' is invalid in C99 [-Wimplicit-function-declaration]

initializing 'const nrf_drv_spi_t' with an expression of incompatible type 'int'

Here below the nrf_drv_spi_t definition;

typedef struct

{

    uint8_t inst_idx;

    union

    {

#ifdef SPIM_PRESENT

        nrfx_spim_t spim;

#endif

#ifdef SPI_PRESENT

        nrfx_spi_t  spi;

#endif

    } u;

    bool    use_easy_dma;

} nrf_drv_spi_t;

 

I looked everywhere and could not find the definition of NRF_DRV_SPI_INSTANCE() macro.

Where can I get it?

Parents
  • Hi,

    The definition should be in <sdk folder>\integration\nrfx\legacy\nrf_drv_spi.h.

    Please make sure the directory is included as an include directory in your project, and that you use the proper include directive in the relevant source files.

    Please also check that the SPI instance is enabled, since otherwise the NRF_DRV_SPI_INSTANCE() macro is never defined.

    Regards,
    Terje

  • Hi Terje,

     

    Many thanks for your response. In my sdk_config.h file it was written as;

     

    #ifndef SPI_ENABLED

    #define SPI_ENABLED 0

    #endif

     

    I made it as 1

    And added to my source file (main.c) the line;

    #include "nrf_drv_spi.h"

    This time I get the following compiler error;

     

        use of undeclared identifier 'NRF_DRV_SPI_INSTANCE_0'; did you mean 'NRF_DRV_SPI_MODE_0'?

        expanded from macro 'NRF_DRV_SPI_INSTANCE'

        expanded from macro 'NRF_DRV_SPI_INSTANCE_'

        expanded from here

        'NRF_DRV_SPI_MODE_0' declared here

        initializing 'const nrf_drv_spi_t' with an expression of incompatible type 'int'

     

    This time I searched for 'NRF_DRV_SPI_INSTANCE_0 It again only defined in nrf_drv_spi.h as;

     

    #define NRF_DRV_SPI_INSTANCE(id)    NRF_DRV_SPI_INSTANCE_(id)

    #define NRF_DRV_SPI_INSTANCE_(id)   NRF_DRV_SPI_INSTANCE_ ## id

    #if NRFX_CHECK(NRFX_SPIM0_ENABLED)

        #define NRF_DRV_SPI_INSTANCE_0 \

            { 0, { .spim = NRFX_SPIM_INSTANCE(0) }, true }

    #elif NRFX_CHECK(NRFX_SPI0_ENABLED)

        #define NRF_DRV_SPI_INSTANCE_0 \

            { 0, { .spi = NRFX_SPI_INSTANCE(0) }, false }

    #endif

     

    I think the latter should apply. NRFX_CHECK is defined in nrfx_common.h as;

     

    #define NRFX_CHECK(module_enabled)  (module_enabled)

     

    It is a dummy definition.

    NRFX_SPI0_ENABLED is defined in nrf_drv_spi.h and I made it as 1;

     

    #ifndef NRFX_SPI0_ENABLED

    #define NRFX_SPI0_ENABLED 1

    #endif

     

    But still the same compiler error. I added the following line to main.c

     

    #define NRF_DRV_SPI_INSTANCE_0   { 0, { .spi = NRFX_SPI_INSTANCE(0) }, false }

     

    This time compiler error is changed to;

     

    use of undeclared identifier 'NRFX_SPI0_INST_IDX'

     

    It is clear that it will continue like this. I downloaded both SDK and IDE as zip files. And it seems that I could not have managed to configure them correctly. How can I integrate the SDK to IDE?

     

    Best regards.

  • Hi Terje,

    The project was an IAR project. I created a new project and import main.c.

    Wtih this manner I managed to compile without any modification on the source code. Bu this time I am getting linker errors;

    Rebuilding ‘BLE’ from solution ‘BLE’ in configuration ‘Debug’
      Compiling ‘system_nrf52.c’
      Compiling ‘main.c’
      Assembling ‘SEGGER_THUMB_Startup.s’
      Assembling ‘ses_startup_nrf_common.s’
      Assembling ‘ses_startup_nrf52840.s’
      Linking BLE.elf
        undefined symbol app_error_handler referenced by symbol ADXL362_ReadReg (section .text.ADXL362_ReadReg in file main.o)
        undefined symbol app_timer_create referenced by symbol timers_init (section .text.timers_init in file main.o)
        undefined symbol app_timer_init referenced by symbol timers_init (section .text.timers_init in file main.o)
        undefined symbol app_timer_start referenced by symbol application_timers_start (section .text.application_timers_start in file main.o)
        undefined symbol ble_advdata_encode referenced by symbol advertising_init (section .text.advertising_init in file main.o)
        undefined symbol nrf_drv_spi_init referenced by symbol spi_adxl362_init (section .text.spi_adxl362_init in file main.o)
        undefined symbol nrf_pwr_mgmt_init referenced by symbol power_management_init (section .text.power_management_init in file main.o)
        undefined symbol nrf_pwr_mgmt_run referenced by symbol idle_state_handle (section .text.idle_state_handle in file main.o)
        undefined symbol nrf_sdh_ble_default_cfg_set referenced by symbol ble_stack_init (section .text.ble_stack_init in file main.o)
        undefined symbol nrf_sdh_ble_enable referenced by symbol ble_stack_init (section .text.ble_stack_init in file main.o)
        undefined symbol nrf_sdh_enable_request referenced by symbol ble_stack_init (section .text.ble_stack_init in file main.o)
        undefined symbol nrfx_spim_xfer referenced by symbol nrf_drv_spi_transfer (section .text.nrf_drv_spi_transfer in file main.o)
    Build failed

    I hope I will alson solve it in some time :-)

  • I solved the problem with creating a new GCC project.
    Sorry for the message traffic that I caused.

    You may delete this post completely.

Reply Children
No Data
Related