diff --git a/cores/nRF5/rtos.cpp b/cores/nRF5/rtos.cpp index 58e4bd86..7afe79b0 100644 --- a/cores/nRF5/rtos.cpp +++ b/cores/nRF5/rtos.cpp @@ -45,6 +45,7 @@ static void _redirect_task(void* arg) while(1) { taskfunc(); + delay(0); } } @@ -53,25 +54,15 @@ SchedulerRTOS::SchedulerRTOS(void) _num = 1; // loop is already created by default } -bool SchedulerRTOS::startLoop(taskfunc_t task, uint32_t stack_size) +bool SchedulerRTOS::startLoop(taskfunc_t task, uint32_t stack_size, uint32_t prio, const char* name) { - char name[8] = "loop0"; - name[4] += _num; - - if ( startLoop(task, name, stack_size) ) + static char const * const name_default = "unnamed_task"; + if (name == NULL) { - _num++; - return true; - }else - { - return false; + name = name_default; } -} - -bool SchedulerRTOS::startLoop(taskfunc_t task, const char* name, uint32_t stack_size) -{ TaskHandle_t handle; - return pdPASS == xTaskCreate( _redirect_task, name, stack_size, (void*) task, TASK_PRIO_LOW, &handle); + return pdPASS == xTaskCreate( _redirect_task, name, stack_size, (void*) task, prio, &handle); } diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h index 49fef4a6..7c610ff0 100644 --- a/cores/nRF5/rtos.h +++ b/cores/nRF5/rtos.h @@ -93,8 +93,7 @@ public: SchedulerRTOS(void); - bool startLoop(taskfunc_t task, uint32_t stack_size = SCHEDULER_STACK_SIZE_DFLT); - bool startLoop(taskfunc_t task, const char* name, uint32_t stack_size = SCHEDULER_STACK_SIZE_DFLT); + bool startLoop(taskfunc_t task, uint32_t stack_size = SCHEDULER_STACK_SIZE_DFLT, uint32_t prio = TASK_PRIO_LOW, const char* name = NULL); }; extern SchedulerRTOS Scheduler;