Skip to Content
Hands-On RTOS with Microcontrollers
book

Hands-On RTOS with Microcontrollers

by Brian Amos
May 2020
Intermediate to advanced
496 pages
13h 54m
English
Packt Publishing
Content preview from Hands-On RTOS with Microcontrollers

Checking the return value

When creating a few tasks in main before starting the scheduler, it's necessary to check the return values as each task is created. Of course, there are many ways to accomplish this. Let's take a look at two of them:

  1. The first is by wrapping the call in an if statement with an inlined infinite while loop:
if( xTaskCreate(GreenTask, "GreenTask", STACK_SIZE, NULL,                 tskIDLE_PRIORITY + 2, NULL) != pdPASS){ while(1) }
  1. The second is by using ASSERT rather than the infinite while loop. If your project has ASSERT support, then it would be better to use ASSERT, rather than the infinite while loop. Since our project already has HAL included, we can make use of the assert_param macro:
retVal = xTaskCreate(BlueTask, "BlueTask", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers - Second Edition

Hands-On RTOS with Microcontrollers - Second Edition

Jim Yuill, Penn Linder

Publisher Resources

ISBN: 9781838826734Supplemental Content