Skip to main content

OSWrappers

This class specifies OS wrappers for dealing with the framebuffer semaphore and the VSYNC signal.

Public Functions

voidgiveFrameBufferSemaphore()
Release the framebuffer semaphore.
voidgiveFrameBufferSemaphoreFromISR()
Release the framebuffer semaphore in a way that is safe in interrupt context.
voidinitialize()
Initialize framebuffer semaphore and queue/mutex for VSYNC signal.
boolisVSyncAvailable()
This function checks if a VSync occurred after last rendering.
voidsignalRenderingDone()
Signal that the rendering of the frame has completed.
voidsignalVSync()
Signal that a VSYNC has occurred.
voidtakeFrameBufferSemaphore()
Take the framebuffer semaphore.
voidtaskDelay(uint16_t ms)
A function that causes executing task to sleep for a number of milliseconds.
voidtaskYield()
A function that causes the executing task to yield control to another thread.
voidtryTakeFrameBufferSemaphore()
Attempt to obtain the framebuffer semaphore.
voidwaitForVSync()
This function blocks until a VSYNC occurs.

Public Functions Documentation

giveFrameBufferSemaphore

static void giveFrameBufferSemaphore()

Release the framebuffer semaphore.

giveFrameBufferSemaphoreFromISR

Release the framebuffer semaphore in a way that is safe in interrupt context.

Called from ISR.

initialize

static void initialize()

Initialize framebuffer semaphore and queue/mutex for VSYNC signal.

isVSyncAvailable

static bool isVSyncAvailable()

This function checks if a VSync occurred after last rendering.

The function is used in systems that cannot wait in waitForVSync (because they are also checking other event sources.

Returns:

True if VSync occurred.

Note

signalRenderingDone is typically used together with this function.

signalRenderingDone

static void signalRenderingDone()

Signal that the rendering of the frame has completed.

Used by some systems to avoid using any previous vsync.

signalVSync

static void signalVSync()

Signal that a VSYNC has occurred.

Should make the vsync queue/mutex available.

Note

This function is called from an ISR, and should (depending on OS) trigger a scheduling.

takeFrameBufferSemaphore

static void takeFrameBufferSemaphore()

Take the framebuffer semaphore.

Blocks until semaphore is available.

taskDelay

static void taskDelay(uint16_tms)

A function that causes executing task to sleep for a number of milliseconds.

This function is OPTIONAL. It is only used by the TouchGFX in the case of a specific frame refresh strategy (REFRESH_STRATEGY_OPTIM_SINGLE_BUFFER_TFT_CTRL). Due to backwards compatibility, in order for this function to be usable by the HAL the function must be explicitly registered: hal.registerTaskDelayFunction(&OSWrappers::taskDelay)

Parameters:
msThe number of milliseconds to sleep.
See also:

taskYield

static void taskYield()

A function that causes the executing task to yield control to another thread.

This function is used by the framework when it is necessary to wait a little before continuing (e.g. drawing).

The implementation should typically request the operating system to change to another task of similar priority. When running without an operating system, the implementation can run a very short task and return.

tryTakeFrameBufferSemaphore

Attempt to obtain the framebuffer semaphore.

If semaphore is not available, do nothing.

Note

must return immediately! This function does not care who has the taken the semaphore, it only serves to make sure that the semaphore is taken by someone.

waitForVSync

static void waitForVSync()

This function blocks until a VSYNC occurs.

Note

This function must first clear the mutex/queue and then wait for the next one to occur.