221 | | |
| 223 | {{{ |
| 224 | TaskHandle_t Task1 = NULL; |
| 225 | TaskHandle_t Task2 = NULL; |
| 226 | TaskHandle_t Task3 = NULL; |
| 227 | TaskHandle_t Task4 = NULL; |
| 228 | |
| 229 | void setup() { |
| 230 | Serial.begin(115200); |
| 231 | delay(2000); |
| 232 | // Created 4 Task here |
| 233 | xTaskCreatePinnedToCore(f4_Task,"func4_Task",1000,NULL,4,&Task3,0); |
| 234 | xTaskCreatePinnedToCore(f3_Task,"func3_Task",1000,NULL,3,&Task3,0); |
| 235 | xTaskCreatePinnedToCore(f2_Task,"func2_Task",1000,NULL,2,&Task2,0); |
| 236 | xTaskCreatePinnedToCore(f1_Task,"func1_Task",1000,NULL,1,&Task1,0); |
| 237 | } |
| 238 | |
| 239 | void loop() { |
| 240 | |
| 241 | } |
| 242 | |
| 243 | void f4_Task(void *pvParam){ |
| 244 | |
| 245 | Serial.println(String("Hello from TASK4 , Priority is : ") + uxTaskPriorityGet(Task4)); |
| 246 | int newPriority = uxTaskPriorityGet(Task4) - 4; |
| 247 | Serial.println(String("NOW WE CHANGE PRIORITY OF TASK4 TO BE : ") + newPriority ); |
| 248 | vTaskPrioritySet(Task4,newPriority); |
| 249 | |
| 250 | Serial.println(String("Hello again from TASK4 , then delete TASK4 !")); |
| 251 | vTaskDelete(NULL); |
| 252 | |
| 253 | } |
| 254 | |
| 255 | void f3_Task(void *pvParam){ |
| 256 | |
| 257 | Serial.println(String("Hello from TASK3 , then Suspend TASK2 & TASK3 !")); |
| 258 | vTaskSuspend(Task2); |
| 259 | vTaskSuspend(NULL); |
| 260 | |
| 261 | Serial.println(String("Hello again from TASK3 , then delete TASK3 !")); |
| 262 | vTaskDelete(NULL); |
| 263 | |
| 264 | } |
| 265 | |
| 266 | void f2_Task(void *pvParam){ |
| 267 | |
| 268 | Serial.println(String("Hello from TASK2 , then Resume TASK3 !")); |
| 269 | vTaskResume(Task3); |
| 270 | |
| 271 | Serial.println(String("Hello again from TASK2 , then delete TASK2 !")); |
| 272 | vTaskDelete(Task2); |
| 273 | |
| 274 | } |
| 275 | |
| 276 | void f1_Task(void *pvParam){ |
| 277 | |
| 278 | Serial.println(String("Hello from TASK1 , then Resume TASK2 !")); |
| 279 | vTaskResume(Task2); |
| 280 | |
| 281 | Serial.println(String("Hello again from TASK1 , then delete TASK1 !")); |
| 282 | vTaskDelete(NULL); |
| 283 | |
| 284 | } |
| 285 | |
| 286 | }}} |