This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to combine the ble_app_uart with libuartes example ?

Hi,
I have a project that is comunication between nRF and Smartphone via BLE and using libuartes to comunicate with 2 another devices via 2Uarts.
Now I need to combine 2 examples into 1 project. How many stepI have to do ?
I have compared 2 sdk_config.h of 2  examples. there are some differences in 2 sdk_config.h. I think just merge them into one file

What about another files? What I need to combine them and work in 1 project step by step? 
Hope your reply soon. Thank you 
Best regard,

Parents
  • Hello,

    When combining different examples from the nRF5 SDK, my advice is usually to start with one of them (in this case I would start with the one containing the softdevice, so ble_app_uart). 

    Start by adding the libuarte functions that you see in the main.c file from the libuarte example, and the .h and .c files where these are declared and defined, respectively. Then start compiling your application, and look for the missing functions or headers. If you struggle to find what file they are defined in, look them up in the libuarte example. Remember that you need to both include the file, and enable them if they have a guard. (enable them by setting the define from sdk_config.h). If you lack the definitions from sdk_config.h, then copy them from the libuartes example.

    Give it a go, and let me know if you are stuck. 

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for your reply. I understand flow you suggested but I stuck in step how to include header file ?

    In Project Explorer window I just find .c file. 

    step1 : added the links to the folder which contain .c files in Preferences -> General -> Processors > User include directories

    step2 : then I added .c file by right clicking => add existing file.
    And I don't know where contain header file (.h file) and how to add them ?

    Addititon, How to add Dependencies and Output Files in .c file ? When I add nrfx_ppi.c I didn't find them like nrfx_gpioe.c, nrfx_clock.c....  which are already in ble_app_uart example 



  • This is specified in the C-language. 

    .C files are included the way that you describe (add existing file), while the header file is included by typing this near the top of the .c file:

    #include "my_header_file.h"

    You need to do this in the file from where you want to use the functions in the .h/.c file you are using. So if you want to add e.g ppi and use those functions from main.c, then you would add 

    #include "nrfx_ppi.h"

    near the top of main.c (where all the other .h files are included).

    Note that you don't need to include all the files that nrfx_ppi.h includes near the top of nrfx_ppi.h in main. These are automatically included to main when you include nrfx_ppi.h.

    Best regards,

    Edvin

Reply
  • This is specified in the C-language. 

    .C files are included the way that you describe (add existing file), while the header file is included by typing this near the top of the .c file:

    #include "my_header_file.h"

    You need to do this in the file from where you want to use the functions in the .h/.c file you are using. So if you want to add e.g ppi and use those functions from main.c, then you would add 

    #include "nrfx_ppi.h"

    near the top of main.c (where all the other .h files are included).

    Note that you don't need to include all the files that nrfx_ppi.h includes near the top of nrfx_ppi.h in main. These are automatically included to main when you include nrfx_ppi.h.

    Best regards,

    Edvin

Children
  • Hi Edvin,

    Thanks for your reply.
    Here is all steps I did 

    step 1 : added the links to the folder which contain .c files in Preferences -> General -> Processors > User include directories
    step 2 : then I added .c file by right clicking => add existing file.
    step 3: compare sdk_config.h files of 2 examples and merge them all
    step 4: compare include files in top of main.c of each example and merge them all
    then I buid project and got this errors

    Building ‘ble_app_uart_pca10056_s140’ from solution ‘ble_app_uart_pca10056_s140’ in configuration ‘Debug’
    5> Compiling ‘main.c’
    4> Compiling ‘ble_conn_params.c’
    6> Compiling ‘ble_conn_state.c’
    7> Compiling ‘ble_link_ctx_manager.c’
    1> Compiling ‘nrf_ble_gatt.c’
    2> Compiling ‘nrf_ble_qwr.c’
    8> Compiling ‘ble_nus.c’
    3> Compiling ‘nrf_sdh.c’
    5> In file included from c:\nrf_sdk\components\libraries\util\sdk_common.h:61,
    5>                  from c:\nrf_sdk\components\ble\common\ble_advdata.h:56,
    5>                  from C:\nrf_sdk\examples\MyProject\ble_libuarte\main.c:6:
    5> c:\nrf_sdk\components\libraries\util\app_util.h:220:41: error: static assertion failed: "Timer instance not enabled"
    5> c:\nrf_sdk\components\libraries\util\app_util.h:242:62: note: in definition of macro '_SELECT_ASSERT_FUNC'
    5> c:\nrf_sdk\components\libraries\util\app_util.h:258:25: note: in expansion of macro 'STATIC_ASSERT_MSG'
    5> c:\nrf_sdk\components\libraries\libuarte\nrf_libuarte_drv.h:176:5: note: in expansion of macro 'STATIC_ASSERT'
    5> c:\nrf_sdk\components\libraries\libuarte\nrf_libuarte_async.h:241:7: note: in expansion of macro 'NRF_LIBUARTE_DRV_DEFINE'
    5> C:\nrf_sdk\examples\MyProject\ble_libuarte\main.c:47:1: note: in expansion of macro 'NRF_LIBUARTE_ASYNC_DEFINE'
    5> In file included from c:\nrf_sdk\modules\nrfx\nrfx.h:45,
    5>                  from c:\nrf_sdk\modules\nrfx\hal\nrf_gpio.h:44,
    5>                  from c:\nrf_sdk\components\boards\boards.h:43,
    5>                  from c:\nrf_sdk\components\libraries\bsp\bsp.h:58,
    5>                  from c:\nrf_sdk\components\libraries\bsp\bsp_btn_ble.h:60,
    5>                  from C:\nrf_sdk\examples\MyProject\ble_libuarte\main.c:17:
    5> c:\nrf_sdk\modules\nrfx\drivers\include\nrfx_timer.h:72:39: error: 'NRFX_TIMER1_INST_IDX' undeclared here (not in a function); did you mean 'NRFX_TIMER_INSTANCE'?
    5> c:\nrf_sdk\modules\nrfx\drivers\nrfx_common.h:113:37: note: in definition of macro 'NRFX_CONCAT_3_'
    5> c:\nrf_sdk\modules\nrfx\drivers\include\nrfx_timer.h:72:25: note: in expansion of macro 'NRFX_CONCAT_3'
    5> c:\nrf_sdk\components\libraries\libuarte\nrf_libuarte_drv.h:180:18: note: in expansion of macro 'NRFX_TIMER_INSTANCE'
    5> c:\nrf_sdk\components\libraries\libuarte\nrf_libuarte_async.h:241:7: note: in expansion of macro 'NRF_LIBUARTE_DRV_DEFINE'
    5> C:\nrf_sdk\examples\MyProject\ble_libuarte\main.c:47:1: note: in expansion of macro 'NRF_LIBUARTE_ASYNC_DEFINE'
    Build failed

    here is my include file in top of main.c

    #include <stdint.h>
    #include <string.h>
    #include "nordic_common.h"
    #include "nrf.h"
    #include "ble_hci.h"
    #include "ble_advdata.h"
    #include "ble_advertising.h"
    #include "ble_conn_params.h"
    #include "nrf_sdh.h"
    #include "nrf_sdh_soc.h"
    #include "nrf_sdh_ble.h"
    #include "nrf_ble_gatt.h"
    #include "nrf_ble_qwr.h"
    #include "app_timer.h"
    #include "ble_nus.h"
    #include "app_util_platform.h"
    #include "bsp_btn_ble.h"
    #include "nrf_pwr_mgmt.h"
    
    #include "nrf_libuarte_async.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    #define APP_BLE_CONN_CFG_TAG            1                                           /**< A tag identifying the SoftDevice BLE configuration. */
    
    #define DEVICE_NAME       S              "BLE_libUARTE"                               /**< Name of device. Will be included in the advertising data. */
    #define NUS_SERVICE_UUID_TYPE           BLE_UUID_TYPE_VENDOR_BEGIN                  /**< UUID type for the Nordic UART Service (vendor specific). */
    
    #define APP_BLE_OBSERVER_PRIO           3                                           /**< Application's BLE observer priority. You shouldn't need to modify this value. */
    
    #define APP_ADV_INTERVAL                64                                          /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
    
    #define APP_ADV_DURATION                18000                                       /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
    
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)             /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)             /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
    #define SLAVE_LATENCY                   0                                           /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
    #define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
    #define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
    #define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */
    
    #define DEAD_BEEF                       0xDEADBEEF                                  /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
    
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    
    BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);                                   /**< BLE NUS service instance. */
    NRF_BLE_GATT_DEF(m_gatt);                                                           /**< GATT module instance. */
    NRF_BLE_QWR_DEF(m_qwr);                                                             /**< Context for the Queued Write module.*/
    BLE_ADVERTISING_DEF(m_advertising);                                                 /**< Advertising module instance. */
    
    static uint16_t   m_conn_handle          = BLE_CONN_HANDLE_INVALID;                 /**< Handle of the current connection. */
    static uint16_t   m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3;            /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */


    here is my Project Explorer


    Sorry about a lot of errors. But I will try to resolve. It's very important for me to develope many project later.
    Hope you to reply soon

  • It looks like you have not enabled TIMER1 from sdk_config.h.

    If you are not able to figure out how to do it, please upload your sdk_config.h file here. If you find definitions for both NRFX_TIMER1 and NRF_TIMER1, please enable both.

    (and by "enable" I mean change the definition from 0 to 1).

  • 51804.sdk_config.h
    Here is my sdk_config.h
    I have enabled NRFX_TIMER1 and not found NRF_TIMER1 problem was not solved.
    devzone.nordicsemi.com/.../app_util-h-118-41-error-static-assertion-failed-unspecified-message
    I follow this thread but It doesn't work
    ble_libuarte.rar
    Here is all my project

  • Sorry, I meant TIMER1_ENABLED, not NRF_TIMER1_ENABLED.

    I see that TIMER1_ENABLED is set to 0. Try to set it to 1. And set TIMER_ENABLED to 1 as well. So change these on line 5443 and 5379, respectively.

    Try this first, and let me know if it doesn't work.

  • Hi Edvin,
    Above errors disappeared ^^

    But I got  new errors like this

    Building ‘ble_app_uart_pca10056_s140’ from solution ‘ble_app_uart_pca10056_s140’ in configuration ‘Debug’
    3> Compiling ‘nrf_log_backend_rtt.c’
    4> Compiling ‘nrf_log_backend_serial.c’
    5> Compiling ‘nrf_log_default_backends.c’
    6> Compiling ‘nrf_log_frontend.c’
    7> Compiling ‘nrf_log_str_formatter.c’
    8> Compiling ‘app_button.c’
    2> Compiling ‘app_error_handler_gcc.c’
    1> Compiling ‘app_error_weak.c’
    1> Compiling ‘app_fifo.c’
    4> Compiling ‘app_scheduler.c’
    5> Compiling ‘app_timer2.c’
    6> Compiling ‘app_uart_fifo.c’
    7> Compiling ‘drv_rtc.c’
    2> Compiling ‘hardfault_implementation.c’
    3> Compiling ‘nrf_atfifo.c’
    8> Compiling ‘nrf_atflags.c’
    3> Compiling ‘nrf_atomic.c’
    2> Compiling ‘nrf_balloc.c’
    1> Compiling ‘nrf_fprintf.c’
    5> Compiling ‘nrf_fprintf_format.c’
    4> Compiling ‘nrf_memobj.c’
    6> Compiling ‘nrf_pwr_mgmt.c’
    7> Compiling ‘nrf_ringbuf.c’
    8> Compiling ‘nrf_section_iter.c’
    5> Compiling ‘nrf_sortlist.c’
    3> Compiling ‘nrf_strerror.c’
    2> Compiling ‘retarget.c’
    1> Compiling ‘nrf_libuarte_async.c’
    8> Compiling ‘nrf_libuarte_drv.c’
    4> Compiling ‘nrf_queue.c’
    7> Compiling ‘boards.c’
    6> Compiling ‘nrf_drv_clock.c’
    5> Compiling ‘nrf_drv_uart.c’
    3> Compiling ‘nrfx_atomic.c’
    2> Compiling ‘nrfx_clock.c’
    7> Compiling ‘nrfx_gpiote.c’
    1> Compiling ‘nrfx_prs.c’
    4> Compiling ‘nrfx_uart.c’
    8> Compiling ‘nrfx_uarte.c’
    6> Compiling ‘nrfx_ppi.c’
    5> Compiling ‘nrfx_rtc.c’
    3> Compiling ‘nrfx_timer.c’
    7> Compiling ‘bsp.c’
    2> Compiling ‘bsp_btn_ble.c’
    5> Compiling ‘main.c’
    1> Compiling ‘SEGGER_RTT.c’
    3> Compiling ‘SEGGER_RTT_Syscalls_SES.c’
    4> Compiling ‘SEGGER_RTT_printf.c’
    6> Compiling ‘ble_advdata.c’
    7> Compiling ‘ble_advertising.c’
    8> Compiling ‘ble_conn_params.c’
    3> Compiling ‘ble_conn_state.c’
    2> Compiling ‘ble_link_ctx_manager.c’
    4> Compiling ‘nrf_ble_gatt.c’
    8> Compiling ‘nrf_ble_qwr.c’
    1> Compiling ‘ble_nus.c’
    6> Compiling ‘nrf_sdh.c’
    7> Compiling ‘nrf_sdh_ble.c’
    5> Compiling ‘nrf_sdh_soc.c’
    1> Linking ble_app_uart_pca10056_s140.elf
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_async.o: in function `nrf_libuarte_async_init':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:480: undefined reference to `nrfx_ppi_channel_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:489: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:489: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:494: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:494: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_async.o: in function `nrf_libuarte_async_enable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:597: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:599: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `nrfx_ppi_channel_include_in_group':
    1> c:\nrf_sdk\modules\nrfx\drivers\include/nrfx_ppi.h:219: undefined reference to `nrfx_ppi_channels_include_in_group'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_channel_configure':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:117: undefined reference to `nrfx_ppi_channel_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:123: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:131: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_group_configure':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:147: undefined reference to `nrfx_ppi_group_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:161: undefined reference to `nrfx_ppi_group_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_free':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:178: undefined reference to `nrfx_ppi_channel_disable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:180: undefined reference to `nrfx_ppi_channel_free'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_group_free':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:189: undefined reference to `nrfx_ppi_group_free'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_enable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:206: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_disable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:214: undefined reference to `nrfx_ppi_channel_disable'
    Build failed
     

Related