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

FreeRTOS & ble central hrs

Hi All,

I would like to make bluetooth data collector with a serial line. There are max 16 bluetooth devices on the air where I need to collect data. There is a PC which continuosly polling this device by serial line. Maybe I need FreeRTOS to solve this problem. I found blinky and hrs emulator freertos version, and ble_central HRS application examples.

I use a PAC10040 board. The ble task is like this:

bool erase_bonds=false;
timers_init();
    ble_stack_init();
    peer_manager_init(erase_bonds);
    if (erase_bonds == true)
        NRF_LOG_INFO("Bonds erased!\r\n");
   gatt_init();
   db_discovery_init();
   hrs_c_init();
   bas_c_init();
   scan_start();
   for (;;)
   {
	      while(pdFALSE==xSemaphoreTake(m_ble_event_ready, portMAX_DELAY))
		;

	      intern_softdevice_events_execute();
   }

}

and main function is like this:

ret_code_t err_code;
//bool erase_bonds;
timers_init();
err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
bsp_board_leds_init();
bsp_board_buttons_init();
    m_ble_event_ready = xSemaphoreCreateBinary();
    if (NULL == m_ble_event_ready)
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    if (pdPASS != xTaskCreate(ble_stack_thread, "BLE", 256, NULL, 2, &m_ble_stack_thread))
    APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    if (pdPASS != xTaskCreate(logger_thread, "LOG", 256, NULL, 1, &m_logger_thread))
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    if (pdPASS != xTaskCreate(alive_thread, "ALV", 63, NULL, 1, &m_alive_thread))
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);

    serial_init();
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
   NRF_LOG_INFO("Starting system\r\n");
   vTaskStartScheduler();
   while (true)
       ;

serial_init starts a new task which is handle the serial port. Everything works well when I not started ble_thread. If I start ble_thread, there is no log messages, the tasks are run (I checked them with breakpoint), and there is no ble handling.

I use sdk nRF5_SDK_12.3.0_d7731ad. Logging works in RTT link.

I gave more heap (16384bytes) to freeRTOS in config, and I changed port_cmsis_systick.c as suggested devzone.nordicsemi.com/.../

Is there any documentaion for the init sequences under freertos?

thx Zamek

Related