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

Errors Merging "ble_app_uart" and "twi_sensor"

I found similar questions, but none that were marked as "answered".

I have a working version of "nRF5_SDK_160.0.0_98a08e2/examples/ble_peripheral/ble_app_uart". I also have a modified "nRF5_SDK_160.0.0_98a08e2/examples/peripheral/twi_sensor" that works to communicate with my TWI device. I am using Segger IDE.

I am attempting to merge the two projects into one by starting from the BLE and added the TWI components. TL;DR Why can't I merge these two projects to get a functional program?

In partial merge 1, nothing compiles with error "undefined reference to `nrf_log_backend_uart_init"

To fix this, I added more values to emProject and called it partial merge 2. Without yet attempting to communicate with the TWI board, everything compiles fine. But when I run the program, I hit "app_error_handler_gcc.c/app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name) with error code 0x08.

To fix this, I added the final missing parts to the .emProject, which causes the error "'NRF_SUCCESS' undeclared (first use in this function); did you mean 'NRFX_SUCCESS'?"

Partial merge 1 means

  • main.c/main.h now initializes the TWI communication as well as handle the nRF52840 UART initialization process.
  • The bluetooth control has been moved to its own file
  • The TWI initialization driver has been added to the "ble_app_uart" from the working "twi_sensor" example
  • the .emProject File has been updated (see "ble_twi-partialMerge1.emProject.txt" since .emProject files won't load)
    • The Nordic drivers are moved into their own file so that the project is kept clean (nRF_files and Segger_files)
    • The missing includes from "twi_sensor" have NOT been added to "ble_app_uart"
  • The sdk_config.h file has been updated with everything from both files (see "sdk_config-ble_only.h" and "sdk_config-twi_added.h")

Partial merge 2 means (same as partial 1 except...)

  • .emProject (see "ble_twi-partialMerge2.emProject" since .emProject files won't load)
    • Some of the missing includes from "twi_sensor" HAVE been added to "ble_app_uart"
    • to "<folder Name="nRF_Drivers">"
      • File <file file_name="nRF_sdk/integration/nrfx/legacy/nrf_drv_twi.c" /> is added
      • File <file file_name="nRF_sdk/modules/nrfx/drivers/src/nrfx_twi.c" /> is added
      • File <file file_name="nRF_sdk/modules/nrfx/drivers/src/nrfx_twim.c" /> is added
    • to "<folder Name="nRF_Log">" the value "<file file_name="nRF_sdk/components/libraries/log/src/nrf_log_backend_uart.c" />" is added

Complete merge means (same as partial 2, except...)

  • .emProject (see "ble_twi-completeMerge.emProject" since .emProject files won't load)
    • All the missing includes from "twi_sensor" HAVE been added to "ble_app_uart"
    • to "configuration/c_preprocessor_definitions" the value "BSP_DEFINES_ONLY;" is added
    • to "configuration/c_user_include_directories" the value "nRF_sdk/components/drivers_nrf/nrf_soc_nosd;" is added

Example Code

main.h

twi_driver.h

ISP1807.h

sdk_config-TWI_added.hsdk_config-BLE_only.h

Parents
  • This line right here broke it. It's the 12116 line long sdk_config.h file. When this value was 1, the logging used UART and therefore the BLE can't use it.
    When init_uart was called, it evaluate this if statement in "nrfx_uart.c" to true and set the error code to 0x08.
    EDIT: I also had to remove "BSP_DEFINES_ONLY" and "nRF_sdk/components/drivers_nrf/nrf_soc_nosd"
Reply
  • This line right here broke it. It's the 12116 line long sdk_config.h file. When this value was 1, the logging used UART and therefore the BLE can't use it.
    When init_uart was called, it evaluate this if statement in "nrfx_uart.c" to true and set the error code to 0x08.
    EDIT: I also had to remove "BSP_DEFINES_ONLY" and "nRF_sdk/components/drivers_nrf/nrf_soc_nosd"
Children
No Data