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

NRF_DRV_SPI_INSTANCE_0 undeclared here

0743.upload_config.txt

Hi all,

I wrote a nice library for using an offboard SPI flash chip and am now trying to port it to our master code which runs on freertos.. I wrote the library starting with the spi example in the sdk15.. and it works great. I did this because the freertos code that we already have is built on sdk15 and I thought it would be simple to port.. anyways I keep getting this 'NRF_DRV_SPI_INSTANCE_0 undeclared here' error in nrf_drv_spi.h even though I think I've set up sdk.config exactly the same(with respect to spi) as in the example.. I've spent a lot of time playing with the definitions in sdk_config, commenting and uncommenting and re-defining the sections for mspi, spi, and nrfx_spi... to no avail..

it almost seems as if the sdk_config doesen't affect the defines in_nrf_drv_spi.h.. I am looking at the lines in nrf_drv_spi.h.. I can't seem to get the bottom 3 lines to be black..

***************************************************************************************

#define NRF_DRV_SPI_INSTANCE(id)    NRF_DRV_SPI_INSTANCE_(id)
#define NRF_DRV_SPI_INSTANCE_(id)   NRF_DRV_SPI_INSTANCE_ ## id

/*colin If I add this in here, the bottom becomes defined, but I enter a whole other pool of undefined errors.. this is not how I'm supposed to do this...
#define NRF_DRV_SPI_INSTANCE_0 \
        { 0, { .spim = NRFX_SPIM_INSTANCE(0) }, true }
//end colin*/

#if NRFX_CHECK(NRFX_SPIM0_ENABLED)
    #define NRF_DRV_SPI_INSTANCE_0 \
        { 0, { .spim = NRFX_SPIM_INSTANCE(0) }, true }

****************************************************************************************

I've seen a bunch of people on here with the same or similar error.. it's got something to do with the new spi stuff... I just don't really know what the 'propper' way to do this is...

I'm including my sdk config as a seperate (obnoxiously long) file...

Any addvice appreciated.. spent a while on this one.. ;)

thx-colin

Parents
  • I've seen a bunch of people on here with the same or similar error

    Yes, getting the sdk_config.h right can be a real pain.

    Perhaps it might help to look at the preprocessor output - so you can see what the compiler's actually seeing ... ?

  • Building ‘aw_ble_node’ from solution ‘aw_ble_node’ in configuration ‘Debug’
    1> Output/Debug/Obj/aw_ble_node/thumb_crt0.o does not exist.
    1> Assembling ‘thumb_crt0.s’
    2> Output/Debug/Obj/aw_ble_node/nrf_log_backend_rtt.o does not exist.
    2> Preprocessing nrf_log_backend_rtt.c
    3> Output/Debug/Obj/aw_ble_node/nrf_log_backend_serial.o does not exist.
    3> Preprocessing nrf_log_backend_serial.c
    4> Output/Debug/Obj/aw_ble_node/nrf_log_backend_uart.o does not exist.
    4> Preprocessing nrf_log_backend_uart.c
    2> Compiling ‘nrf_log_backend_rtt.c’
    1> Output/Debug/Obj/aw_ble_node/nrf_log_default_backends.o does not exist.
    1> Preprocessing nrf_log_default_backends.c
    3> Compiling ‘nrf_log_backend_serial.c’
    4> Compiling ‘nrf_log_backend_uart.c’
    2> Output/Debug/Obj/aw_ble_node/nrf_log_frontend.o does not exist.
    2> Preprocessing nrf_log_frontend.c
    1> Compiling ‘nrf_log_default_backends.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_log_str_formatter.o does not exist.
    3> Preprocessing nrf_log_str_formatter.c
    4> Output/Debug/Obj/aw_ble_node/app_button.o does not exist.
    4> Preprocessing app_button.c
    2> Compiling ‘nrf_log_frontend.c’
    1> Output/Debug/Obj/aw_ble_node/app_error.o does not exist.
    1> Preprocessing app_error.c
    3> Compiling ‘nrf_log_str_formatter.c’
    1> Compiling ‘app_error.c’
    4> Compiling ‘app_button.c’
    3> Output/Debug/Obj/aw_ble_node/app_error_handler_gcc.o does not exist.
    3> Preprocessing app_error_handler_gcc.c
    2> Output/Debug/Obj/aw_ble_node/app_error_weak.o does not exist.
    2> Preprocessing app_error_weak.c
    1> Output/Debug/Obj/aw_ble_node/app_timer_freertos.o does not exist.
    1> Preprocessing app_timer_freertos.c
    4> Output/Debug/Obj/aw_ble_node/app_util_platform.o does not exist.
    4> Preprocessing app_util_platform.c
    3> Compiling ‘app_error_handler_gcc.c’
    2> Compiling ‘app_error_weak.c’
    4> Compiling ‘app_util_platform.c’
    1> Compiling ‘app_timer_freertos.c’
    3> Output/Debug/Obj/aw_ble_node/crc16.o does not exist.
    3> Preprocessing crc16.c
    2> Output/Debug/Obj/aw_ble_node/fds.o does not exist.
    2> Preprocessing fds.c
    4> Output/Debug/Obj/aw_ble_node/hardfault_handler_gcc.o does not exist.
    4> Preprocessing hardfault_handler_gcc.c
    1> Output/Debug/Obj/aw_ble_node/hardfault_implementation.o does not exist.
    1> Preprocessing hardfault_implementation.c
    3> Compiling ‘crc16.c’
    4> Compiling ‘hardfault_handler_gcc.c’
    2> Compiling ‘fds.c’
    1> Compiling ‘hardfault_implementation.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_assert.o does not exist.
    3> Preprocessing nrf_assert.c
    3> Compiling ‘nrf_assert.c’
    4> Output/Debug/Obj/aw_ble_node/nrf_atfifo.o does not exist.
    4> Preprocessing nrf_atfifo.c
    1> Output/Debug/Obj/aw_ble_node/nrf_atflags.o does not exist.
    1> Preprocessing nrf_atflags.c
    4> Compiling ‘nrf_atfifo.c’
    1> Compiling ‘nrf_atflags.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_atomic.o does not exist.
    3> Preprocessing nrf_atomic.c
    2> Output/Debug/Obj/aw_ble_node/nrf_balloc.o does not exist.
    2> Preprocessing nrf_balloc.c
    3> Compiling ‘nrf_atomic.c’
    4> Output/Debug/Obj/aw_ble_node/nrf_fprintf.o does not exist.
    4> Preprocessing nrf_fprintf.c
    1> Output/Debug/Obj/aw_ble_node/nrf_fprintf_format.o does not exist.
    1> Preprocessing nrf_fprintf_format.c
    2> Compiling ‘nrf_balloc.c’
    4> Compiling ‘nrf_fprintf.c’
    1> Compiling ‘nrf_fprintf_format.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_fstorage.o does not exist.
    3> Preprocessing nrf_fstorage.c
    2> Output/Debug/Obj/aw_ble_node/nrf_fstorage_sd.o does not exist.
    2> Preprocessing nrf_fstorage_sd.c
    4> Output/Debug/Obj/aw_ble_node/nrf_memobj.o does not exist.
    3> Compiling ‘nrf_fstorage.c’
    4> Preprocessing nrf_memobj.c
    1> Output/Debug/Obj/aw_ble_node/nrf_ringbuf.o does not exist.
    1> Preprocessing nrf_ringbuf.c
    2> Compiling ‘nrf_fstorage_sd.c’
    4> Compiling ‘nrf_memobj.c’
    1> Compiling ‘nrf_ringbuf.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_section_iter.o does not exist.
    3> Preprocessing nrf_section_iter.c
    4> Output/Debug/Obj/aw_ble_node/nrf_strerror.o does not exist.
    4> Preprocessing nrf_strerror.c
    2> Output/Debug/Obj/aw_ble_node/sensorsim.o does not exist.
    2> Preprocessing sensorsim.c
    1> Output/Debug/Obj/aw_ble_node/ses_startup_nrf52840.o does not exist.
    1> Assembling ‘ses_startup_nrf52840.s’
    2> Compiling ‘sensorsim.c’
    3> Compiling ‘nrf_section_iter.c’
    4> Compiling ‘nrf_strerror.c’
    1> Output/Debug/Obj/aw_ble_node/ses_startup_nrf_common.o does not exist.
    1> Assembling ‘ses_startup_nrf_common.s’
    2> Output/Debug/Obj/aw_ble_node/system_nrf52840.o does not exist.
    2> Preprocessing system_nrf52840.c
    3> Output/Debug/Obj/aw_ble_node/croutine.o does not exist.
    1> Output/Debug/Obj/aw_ble_node/event_groups.o does not exist.
    1> Preprocessing event_groups.c
    3> Preprocessing croutine.c
    4> Output/Debug/Obj/aw_ble_node/heap_1.o does not exist.
    2> Compiling ‘system_nrf52840.c’
    4> Preprocessing heap_1.c
    1> Compiling ‘event_groups.c’
    3> Compiling ‘croutine.c’
    4> Compiling ‘heap_1.c’
    2> Output/Debug/Obj/aw_ble_node/list.o does not exist.
    2> Preprocessing list.c
    3> Output/Debug/Obj/aw_ble_node/port.o does not exist.
    3> Preprocessing port.c
    1> Output/Debug/Obj/aw_ble_node/port_cmsis.o does not exist.
    1> Preprocessing port_cmsis.c
    2> Compiling ‘list.c’
    4> Output/Debug/Obj/aw_ble_node/port_cmsis_systick.o does not exist.
    4> Preprocessing port_cmsis_systick.c
    3> Compiling ‘port.c’
    1> Compiling ‘port_cmsis.c’
    2> Output/Debug/Obj/aw_ble_node/queue.o does not exist.
    2> Preprocessing queue.c
    3> Output/Debug/Obj/aw_ble_node/stream_buffer.o does not exist.
    3> Preprocessing stream_buffer.c
    1> Output/Debug/Obj/aw_ble_node/tasks.o does not exist.
    1> Preprocessing tasks.c
    4> Compiling ‘port_cmsis_systick.c’
    2> Compiling ‘queue.c’
    3> Compiling ‘stream_buffer.c’
    1> Compiling ‘tasks.c’
    4> Output/Debug/Obj/aw_ble_node/timers.o does not exist.
    4> Preprocessing timers.c
    3> Output/Debug/Obj/aw_ble_node/boards.o does not exist.
    3> Preprocessing boards.c
    2> Output/Debug/Obj/aw_ble_node/nrf_drv_clock.o does not exist.
    2> Preprocessing nrf_drv_clock.c
    4> Compiling ‘timers.c’
    1> Output/Debug/Obj/aw_ble_node/nrf_drv_uart.o does not exist.
    1> Preprocessing nrf_drv_uart.c
    3> Compiling ‘boards.c’
    2> Compiling ‘nrf_drv_clock.c’
    4> Output/Debug/Obj/aw_ble_node/nrfx_atomic.o does not exist.
    4> Preprocessing nrfx_atomic.c
    1> Compiling ‘nrf_drv_uart.c’
    3> Output/Debug/Obj/aw_ble_node/nrfx_clock.o does not exist.
    3> Preprocessing nrfx_clock.c
    2> Output/Debug/Obj/aw_ble_node/nrfx_gpiote.o does not exist.
    2> Preprocessing nrfx_gpiote.c
    4> Compiling ‘nrfx_atomic.c’
    1> Output/Debug/Obj/aw_ble_node/nrfx_prs.o does not exist.
    1> Preprocessing nrfx_prs.c
    3> Compiling ‘nrfx_clock.c’
    2> Compiling ‘nrfx_gpiote.c’
    1> Compiling ‘nrfx_prs.c’
    4> Output/Debug/Obj/aw_ble_node/nrfx_uart.o does not exist.
    4> Preprocessing nrfx_uart.c
    3> Output/Debug/Obj/aw_ble_node/nrfx_uarte.o does not exist.
    3> Preprocessing nrfx_uarte.c
    4> Compiling ‘nrfx_uart.c’
    1> Output/Debug/Obj/aw_ble_node/nrf_drv_spi.o does not exist.
    1> Preprocessing nrf_drv_spi.c
    3> Compiling ‘nrfx_uarte.c’
    1> Compiling ‘nrf_drv_spi.c’
    2> Output/Debug/Obj/aw_ble_node/bsp.o does not exist.
    2> Preprocessing bsp.c
    4> Output/Debug/Obj/aw_ble_node/bsp_btn_ble.o does not exist.
    4> Preprocessing bsp_btn_ble.c
    1> Output/Debug/Obj/aw_ble_node/aw_ble_node_main.o does not exist.
    1> Preprocessing aw_ble_node_main.c
    2> Compiling ‘bsp.c’
    3> Output/Debug/Obj/aw_ble_node/SEGGER_RTT.o does not exist.
    3> Preprocessing SEGGER_RTT.c
    4> Compiling ‘bsp_btn_ble.c’
    3> Compiling ‘SEGGER_RTT.c’
    2> Output/Debug/Obj/aw_ble_node/SEGGER_RTT_Syscalls_SES.o does not exist.
    2> Preprocessing SEGGER_RTT_Syscalls_SES.c
    1> Compiling ‘aw_ble_node_main.c’
    2> Compiling ‘SEGGER_RTT_Syscalls_SES.c’
    4> Output/Debug/Obj/aw_ble_node/SEGGER_RTT_printf.o does not exist.
    4> Preprocessing SEGGER_RTT_printf.c
    3> Output/Debug/Obj/aw_ble_node/auth_status_tracker.o does not exist.
    3> Preprocessing auth_status_tracker.c
    1> Output/Debug/Obj/aw_ble_node/ble_advdata.o does not exist.
    1> Preprocessing ble_advdata.c
    4> Compiling ‘SEGGER_RTT_printf.c’
    2> Output/Debug/Obj/aw_ble_node/ble_advertising.o does not exist.
    2> Preprocessing ble_advertising.c
    3> Compiling ‘auth_status_tracker.c’
    1> Compiling ‘ble_advdata.c’
    2> Compiling ‘ble_advertising.c’
    4> Output/Debug/Obj/aw_ble_node/ble_conn_params.o does not exist.
    4> Preprocessing ble_conn_params.c
    3> Output/Debug/Obj/aw_ble_node/ble_conn_state.o does not exist.
    3> Preprocessing ble_conn_state.c
    4> Compiling ‘ble_conn_params.c’
    1> Output/Debug/Obj/aw_ble_node/ble_srv_common.o does not exist.
    1> Preprocessing ble_srv_common.c
    3> Compiling ‘ble_conn_state.c’
    2> Output/Debug/Obj/aw_ble_node/gatt_cache_manager.o does not exist.
    2> Preprocessing gatt_cache_manager.c
    1> Compiling ‘ble_srv_common.c’
    2> Compiling ‘gatt_cache_manager.c’
    4> Output/Debug/Obj/aw_ble_node/gatts_cache_manager.o does not exist.
    4> Preprocessing gatts_cache_manager.c
    3> Output/Debug/Obj/aw_ble_node/id_manager.o does not exist.
    3> Preprocessing id_manager.c
    1> Output/Debug/Obj/aw_ble_node/nrf_ble_gatt.o does not exist.
    1> Preprocessing nrf_ble_gatt.c
    4> Compiling ‘gatts_cache_manager.c’
    3> Compiling ‘id_manager.c’
    1> Compiling ‘nrf_ble_gatt.c’
    2> Output/Debug/Obj/aw_ble_node/nrf_ble_qwr.o does not exist.
    2> Preprocessing nrf_ble_qwr.c
    4> Output/Debug/Obj/aw_ble_node/peer_data_storage.o does not exist.
    4> Preprocessing peer_data_storage.c
    2> Compiling ‘nrf_ble_qwr.c’
    3> Output/Debug/Obj/aw_ble_node/peer_database.o does not exist.
    3> Preprocessing peer_database.c
    1> Output/Debug/Obj/aw_ble_node/peer_id.o does not exist.
    1> Preprocessing peer_id.c
    4> Compiling ‘peer_data_storage.c’
    3> Compiling ‘peer_database.c’
    1> Compiling ‘peer_id.c’
    2> Output/Debug/Obj/aw_ble_node/peer_manager.o does not exist.
    2> Preprocessing peer_manager.c
    2> Compiling ‘peer_manager.c’
    4> Output/Debug/Obj/aw_ble_node/peer_manager_handler.o does not exist.
    1> Output/Debug/Obj/aw_ble_node/pm_buffer.o does not exist.
    1> Preprocessing pm_buffer.c
    4> Preprocessing peer_manager_handler.c
    3> Output/Debug/Obj/aw_ble_node/security_dispatcher.o does not exist.
    3> Preprocessing security_dispatcher.c
    1> Compiling ‘pm_buffer.c’
    4> Compiling ‘peer_manager_handler.c’
    3> Compiling ‘security_dispatcher.c’
    2> Output/Debug/Obj/aw_ble_node/security_manager.o does not exist.
    2> Preprocessing security_manager.c
    1> Output/Debug/Obj/aw_ble_node/utf.o does not exist.
    1> Preprocessing utf.c
    1> Compiling ‘utf.c’
    4> Output/Debug/Obj/aw_ble_node/ble_bas.o does not exist.
    2> Compiling ‘security_manager.c’
    4> Preprocessing ble_bas.c
    3> Output/Debug/Obj/aw_ble_node/ble_dis.o does not exist.
    3> Preprocessing ble_dis.c
    4> Compiling ‘ble_bas.c’
    1> Output/Debug/Obj/aw_ble_node/ble_hrs.o does not exist.
    1> Preprocessing ble_hrs.c
    3> Compiling ‘ble_dis.c’
    2> Output/Debug/Obj/aw_ble_node/nrf_sdh.o does not exist.
    2> Preprocessing nrf_sdh.c
    1> Compiling ‘ble_hrs.c’
    3> Output/Debug/Obj/aw_ble_node/nrf_sdh_ble.o does not exist.
    3> Preprocessing nrf_sdh_ble.c
    4> Output/Debug/Obj/aw_ble_node/nrf_sdh_freertos.o does not exist.
    4> Preprocessing nrf_sdh_freertos.c
    2> Compiling ‘nrf_sdh.c’
    3> Compiling ‘nrf_sdh_ble.c’
    1> Output/Debug/Obj/aw_ble_node/nrf_sdh_soc.o does not exist.
    1> Preprocessing nrf_sdh_soc.c
    4> Compiling ‘nrf_sdh_freertos.c’
    2> Output/Debug/Obj/aw_ble_node/adc_ingestion_thread.o does not exist.
    1> Compiling ‘nrf_sdh_soc.c’
    2> Preprocessing adc_ingestion_thread.c
    4> Output/Debug/Obj/aw_ble_node/hrm_example.o does not exist.
    4> Preprocessing hrm_example.c
    3> Output/Debug/Obj/aw_ble_node/flash_fxns.o does not exist.
    3> Preprocessing flash_fxns.c
    2> Compiling ‘adc_ingestion_thread.c’
    3> Compiling ‘flash_fxns.c’
    2> In file included from C:\Users\ccunn\Documents\ble_node\new_branch\BleNode\ses\adc_ingestion_thread.c:14:
    2> C:\Users\ccunn\Documents\ble_node\new_branch\BleNode\ses\flash_fxns.h:28:42: error: 'NRF_DRV_SPI_INSTANCE_0' undeclared here (not in a function); did you mean 'NRF_DRV_SPI_MODE_0'?
    3> In file included from C:\Users\ccunn\Documents\ble_node\new_branch\BleNode\ses\flash_fxns.c:12:
    3> C:\Users\ccunn\Documents\ble_node\new_branch\BleNode\ses\flash_fxns.h:28:42: error: 'NRF_DRV_SPI_INSTANCE_0' undeclared here (not in a function); did you mean 'NRF_DRV_SPI_MODE_0'?
    Build failed
    

    thanks, so- a coworker of mine also said to check out the preprocessor output.. so this is the build output when I clean it and check the keep preprocessor output option.. I looked at this a bit and nothing really jumped out at me.. is this what you mean? is there a way to get a more verbose output?

    my basic problem is that this spi instance is not declared... I shouldn't need to declare this in my code right?? It should be defined globally by sdk_config no? Also- I really can't figure out where/when sdk config is included.. 

    does this make any more sense to you?

    thanks, coin

  • I nice tip to prevent all the hassle with the sdk_config file is to act like the NRFX definitions don't exist. When you want to enable something, you should always use the legacy definitions (non-NRFX). E.g. use SPI_ENABLED instead of NRFX_SPI_ENABLED.

    You should also use the legacy API instead of the NRFX API. E.g. use nrf_drv_spi_init() instead of nrfx_spi(m)_init(). 

    The legacy api/definitions will always override the NRFX counterpart.

    If you do this, everything will work much smoother.

    Best regards,

    Simon

  • Thanks all..

    I ended up re-starting this whole process this morning, had the same problem.. honestly I couldn't get this to work as intended I think, I cheated a couple of times and dropped in some #def's right before they were tested.. Its not pretty, I'm not proud of it but it does functionally work as intended... and I'm up and running again.. then I had some errors w some other include and moved that to the master and it was all happy :/

    again, thanks for the input, I think my takeaway is to always build up from the project I want and never attempt a merger..

Reply
  • Thanks all..

    I ended up re-starting this whole process this morning, had the same problem.. honestly I couldn't get this to work as intended I think, I cheated a couple of times and dropped in some #def's right before they were tested.. Its not pretty, I'm not proud of it but it does functionally work as intended... and I'm up and running again.. then I had some errors w some other include and moved that to the master and it was all happy :/

    again, thanks for the input, I think my takeaway is to always build up from the project I want and never attempt a merger..

Children
No Data
Related