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

Using BLE with FreeRTOS

Hello,

I need an application with a Bluetooth stack and FreeRTOS to handle different tasks (like button reading, sensor reading, ADC, etc.). So I try to implement the BLE template from the SDK into my project:

#include <stdbool.h>
#include <stdint.h>

#include "nrf.h"
#include "nrf_delay.h"
#include "nrf_drv_spi.h"
#include "nrf_drv_twi.h"
#include "nrf_drv_clock.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 "nrf_pwr_mgmt.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#include "ble.h"
#include "ble_hci.h"
#include "ble_srv_common.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "ble_conn_params.h"
#include "ble_conn_state.h"
#include "app_timer.h"
#include "fds.h"
#include "peer_manager.h"
#include "peer_manager_handler.h"

#include "FreeRTOS.h"
#include "timers.h"

#include "boards.h"
#include "bsp_btn_ble.h"
#include "nordic_common.h"

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. */

void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info);

TaskHandle_t  Handle_ToggleLED;
TimerHandle_t Handle_SecondTick;

static void Task_ToggleLED(void* pvParameter);
static void Callback_SecondTick(void* pvParameter);

static uint16_t BLE_ConnectionHandle = BLE_CONN_HANDLE_INVALID;  
static ble_uuid_t BLE_UUID[] =
{
    {
        BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE
    }
};

/**@brief Initialize the NRF log module.
 */
static void Init_Log(void)
{
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
}

/**@brief Initialize the timer module.
 */
static void Init_Timer(void)
{
    APP_ERROR_CHECK(app_timer_init());
    APP_ERROR_CHECK(nrf_drv_clock_init());
}

/**@brief Initialize the power management.
 */
static void Init_PowerManagement(void)
{
    APP_ERROR_CHECK(nrf_pwr_mgmt_init());
}

int main(void)
{
    uint8_t sample_data;
    uint32_t Error;

    Init_Log();
    Init_Timer();
    Init_PowerManagement();

    bsp_board_init(BSP_INIT_LEDS);

    NRF_LOG_INFO("Initialize tasks..");
    UNUSED_VARIABLE(xTaskCreate(Task_ToggleLED, "LED0", configMINIMAL_STACK_SIZE + 200, NULL, 2, &Handle_ToggleLED));

    // Use this timer for the calendar function
    NRF_LOG_INFO("Starting timer..");
    Handle_SecondTick = xTimerCreate("LED1", 1000, pdTRUE, NULL, Callback_SecondTick);
    UNUSED_VARIABLE(xTimerStart(Handle_SecondTick, 0));

    NRF_LOG_FLUSH();

    // Start the FreeRTOS scheduler
    vTaskStartScheduler();

    while(true)
    {
    }
}

void Task_ToggleLED(void* pvParameter)
{
    UNUSED_PARAMETER(pvParameter);

    while(true)
    {
        bsp_board_led_invert(BSP_BOARD_LED_0);

        vTaskDelay(1024);
    }
}

void Callback_SecondTick(void* pvParameter)
{
    UNUSED_PARAMETER(pvParameter);

    bsp_board_led_invert(BSP_BOARD_LED_1);
}

void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
{
    while(1)
    {
        bsp_board_led_on(0);
        nrf_delay_ms(500);
    }
}

But I got this error messages:

Building ‘Project’ from solution ‘Trackeffekt’ in configuration ‘Release’
  Compiling ‘main.c’
  Linking Project.elf
    Output/Project Release/Obj/app_timer2.o: in function `get_now':
    undefined reference to `drv_rtc_counter_get'
    Output/Project Release/Obj/app_timer2.o: in function `app_timer_init':
    undefined reference to `drv_rtc_init'
    G:\Freelancing\Project\firmware\nordic\components\libraries\timer/app_timer2.c:543: undefined reference to `drv_rtc_overflow_enable'
    G:\Freelancing\Project\firmware\nordic\components\libraries\timer/app_timer2.c:544: undefined reference to `drv_rtc_compare_set'
    Output/Project Release/Obj/app_timer2.o: in function `app_timer_cnt_get':
    undefined reference to `drv_rtc_counter_get'
    Output/Project Release/Obj/app_timer2.o: in function `rtc_irq':
    undefined reference to `drv_rtc_overflow_pending'
    G:\Freelancing\Project\firmware\nordic\components\libraries\timer/app_timer2.c:463: undefined reference to `drv_rtc_compare_pending'
    G:\Freelancing\Project\firmware\nordic\components\libraries\timer/app_timer2.c:467: undefined reference to `drv_rtc_compare_pending'
    Output/Project Release/Obj/app_timer2.o: in function `rtc_schedule':
    undefined reference to `drv_rtc_windowed_compare_set'
    Output/Project Release/Obj/app_timer2.o: in function `rtc_update':
    undefined reference to `drv_rtc_start'
    Output/Project Release/Obj/app_timer2.o: in function `rtc_schedule':
    undefined reference to `drv_rtc_compare_disable'
    Output/Project Release/Obj/app_timer2.o: in function `rtc_update':
    undefined reference to `drv_rtc_stop'
Build failed

What is the problem with this code and how can I fix this?

Parents Reply Children
No Data
Related