Difference between revisions of "FreeRTOS"

From uGFX Wiki
Jump to: navigation, search
Line 3: Line 3:
 
== Initialization ==
 
== Initialization ==
 
As with all ports it's important that the underlying system is initialized prior to calling <code>gfxInit()</code>. In case of FreeRTOS this means that <code>vTaskStartScheduler()</code> needs to be executed prior to <code>gfxInit()</code>. However, due to the fact that <code>vTaskStartScheduler()</code> never returns the µGFX library can't be initialized inside the main thread. To illustrate the problem:
 
As with all ports it's important that the underlying system is initialized prior to calling <code>gfxInit()</code>. In case of FreeRTOS this means that <code>vTaskStartScheduler()</code> needs to be executed prior to <code>gfxInit()</code>. However, due to the fact that <code>vTaskStartScheduler()</code> never returns the µGFX library can't be initialized inside the main thread. To illustrate the problem:
 +
<source lang="c">
 +
// Initialize FreeRTOS. This function never returns.
 +
vTaskStartScheduler();
 +
 +
// Initialize uGFX. We never actually arrive here.
 +
gfxInit();
 +
</source>
 +
Swapping the order of the two function calls won't solve the problem either:
 +
 
<source lang="c">
 
<source lang="c">
 
// Initialize uGFX. This requires FreeRTOS to be initialized already. As that's not
 
// Initialize uGFX. This requires FreeRTOS to be initialized already. As that's not

Revision as of 13:57, 22 March 2017

The FreeRTOS port works out of the box without any modifications. Simply enable the port by setting GFX_USE_OS_FREERTOS to TRUE in your configuration file.

Initialization

As with all ports it's important that the underlying system is initialized prior to calling gfxInit(). In case of FreeRTOS this means that vTaskStartScheduler() needs to be executed prior to gfxInit(). However, due to the fact that vTaskStartScheduler() never returns the µGFX library can't be initialized inside the main thread. To illustrate the problem:

// Initialize FreeRTOS. This function never returns.
vTaskStartScheduler();
 
// Initialize uGFX. We never actually arrive here.
gfxInit();

Swapping the order of the two function calls won't solve the problem either:

// Initialize uGFX. This requires FreeRTOS to be initialized already. As that's not
// the case this function call will lead to a crash.
gfxInit();
 
// Initialize FreeRTOS. This function never returns.
vTaskStartScheduler();

The solution to this problem is creating a thread that initializes the entire system. It's a one-time task that doesn't contain a loop:

// ToDo