-1

is it safe to create a task with a variable?

TaskHandle_t blablaTaskHandle= NULL;
...
bool startTask = readAVariable();

if(startTask ){
    xTaskCreate(&blabla, "blabla", 2048, NULL, 2, &blablaTaskHandle);
}

And also suspend it and resume:

 // this is in the main loop 
    bool suspendTask = true;
    if( suspendTask && (blablaTaskHandle!= NULL)){                  
        vTaskSuspend(blablaTaskHandle);
    }
    else{
        vTaskResume(blablaTaskHandle);
    }
D_A_8
  • 9
  • 4
  • 1
    Could you elaborate your problem a bit? I'm afraid it's not very clear and hard to help you right now. Are you trying to let a task "wait" for some even or action to happen? – StrawHat Feb 15 '22 at 07:44
  • 1
    What is `&blabla`? If it's not a pointer to the task function then it's wrong. – lurker Mar 11 '22 at 04:01

1 Answers1

0

You create a task with a function call, not a variable, so I'm not sure what you are asking. From the API documentation, and the hundreds of provided examples, it looks like your use of the first parameter to xTaskCreate() is probably wrong.

Richard
  • 3,081
  • 11
  • 9