Vision Apps User Guide
Application RTOS OSAL/DPL APIs

Introduction

This section contains APIs for providing abstraction between PDK OSAL and MCU+SDK DPL.

Data Structures

struct  app_rtos_semaphore_params_t
 Semaphore parameters. More...
 
struct  app_rtos_task_params_t
 Task parameters. More...
 

Functions

void appRtosSemaphoreParamsInit (app_rtos_semaphore_params_t *params)
 Initialize params structure to default values. More...
 
app_rtos_semaphore_handle_t appRtosSemaphoreCreate (app_rtos_semaphore_params_t params)
 Creates a semaphore instance. More...
 
app_rtos_status_t appRtosSemaphoreDelete (app_rtos_semaphore_handle_t *semhandle)
 Function to delete a semaphore. More...
 
app_rtos_status_t appRtosSemaphorePend (app_rtos_semaphore_handle_t semhandle, uint32_t timeout)
 Function to pend (wait) on a semaphore. More...
 
app_rtos_status_t appRtosSemaphorePost (app_rtos_semaphore_handle_t semhandle)
 Function to post (signal) a semaphore. More...
 
app_rtos_status_t appRtosSemaphoreReset (app_rtos_semaphore_handle_t semhandle)
 Function to clear a semaphore for reuse. More...
 
void appRtosTaskParamsInit (app_rtos_task_params_t *params)
 Initialize params structure to default values. More...
 
app_rtos_task_handle_t appRtosTaskCreate (const app_rtos_task_params_t *params)
 Function to create a task. More...
 
app_rtos_status_t appRtosTaskDelete (app_rtos_task_handle_t *handle)
 Function to delete a task. More...
 
uint32_t appRtosTaskIsTerminated (app_rtos_task_handle_t handle)
 Check if task is terminated. More...
 
void appRtosTaskYield (void)
 Function for Task yield. More...
 
void appRtosTaskSleep (uint32_t timeout)
 Function for Task sleep in units of OS tick. More...
 
void appRtosTaskSleepInMsecs (uint32_t timeoutInMsecs)
 Function for Task sleep in units of msecs. More...
 

Typedefs

typedef void * app_rtos_semaphore_handle_t
 Opaque client reference to an instance of a semaphore. More...
 
typedef void * app_rtos_task_handle_t
 Opaque client reference to an instance of a task. More...
 

Macros

#define APP_RTOS_SEMAPHORE_WAIT_FOREVER   (~((uint32_t)0U))
 Wait forever define. More...
 
#define APP_RTOS_SEMAPHORE_NO_WAIT   ((uint32_t)0U)
 No wait define. More...
 

App Rtos status code

typedef int32_t app_rtos_status_t
 Status codes for App Rtos APIs. More...
 
#define APP_RTOS_STATUS_SUCCESS   (0)
 
#define APP_RTOS_STATUS_FAILURE   (-(int32_t)1)
 
#define APP_RTOS_STATUS_TIMEOUT   (-(int32_t)2)
 

Semaphore Modes

API failed because of a timeout

typedef uint32_t app_rtos_semaphore_mode_t
 Mode of the semaphore. More...
 
#define APP_RTOS_SEMAPHORE_MODE_COUNTING   (0x0U)
 
#define APP_RTOS_SEMAPHORE_MODE_BINARY   (0x1U)
 
#define APP_RTOS_SEMAPHORE_MODE_MUTEX   (0x2U)
 

Macro Definition Documentation

◆ APP_RTOS_STATUS_SUCCESS

#define APP_RTOS_STATUS_SUCCESS   (0)

◆ APP_RTOS_STATUS_FAILURE

#define APP_RTOS_STATUS_FAILURE   (-(int32_t)1)

API completed successfully

◆ APP_RTOS_STATUS_TIMEOUT

#define APP_RTOS_STATUS_TIMEOUT   (-(int32_t)2)

API failed

◆ APP_RTOS_SEMAPHORE_MODE_COUNTING

#define APP_RTOS_SEMAPHORE_MODE_COUNTING   (0x0U)

◆ APP_RTOS_SEMAPHORE_MODE_BINARY

#define APP_RTOS_SEMAPHORE_MODE_BINARY   (0x1U)

◆ APP_RTOS_SEMAPHORE_MODE_MUTEX

#define APP_RTOS_SEMAPHORE_MODE_MUTEX   (0x2U)

◆ APP_RTOS_SEMAPHORE_WAIT_FOREVER

#define APP_RTOS_SEMAPHORE_WAIT_FOREVER   (~((uint32_t)0U))

Wait forever define.

◆ APP_RTOS_SEMAPHORE_NO_WAIT

#define APP_RTOS_SEMAPHORE_NO_WAIT   ((uint32_t)0U)

No wait define.

Typedef Documentation

◆ app_rtos_status_t

typedef int32_t app_rtos_status_t

Status codes for App Rtos APIs.

◆ app_rtos_semaphore_mode_t

typedef uint32_t app_rtos_semaphore_mode_t

Mode of the semaphore.

◆ app_rtos_semaphore_handle_t

Opaque client reference to an instance of a semaphore.

◆ app_rtos_task_handle_t

typedef void* app_rtos_task_handle_t

Opaque client reference to an instance of a task.

Function Documentation

◆ appRtosSemaphoreParamsInit()

void appRtosSemaphoreParamsInit ( app_rtos_semaphore_params_t params)

Initialize params structure to default values.

The default parameters are:

  • mode: APP_RTOS_SEMAPHORE_MODE_COUNTING
  • maxValue: 255
  • initValue: 0
Parameters
paramsPointer to the instance configuration parameters.

◆ appRtosSemaphoreCreate()

app_rtos_semaphore_handle_t appRtosSemaphoreCreate ( app_rtos_semaphore_params_t  params)

Creates a semaphore instance.

Parameters
params[in] parameters for semaphore creation
Returns
app_rtos_semaphore_handle_t on success or a NULL on an error

◆ appRtosSemaphoreDelete()

app_rtos_status_t appRtosSemaphoreDelete ( app_rtos_semaphore_handle_t semhandle)

Function to delete a semaphore.

Parameters
semhandleA app_rtos_semaphore_handle_t returned from appRtosSemaphoreCreate
Returns
Status of the functions
  • APP_RTOS_STATUS_SUCCESS: Deleted the semaphore instance
  • APP_RTOS_STATUS_FAILURE: Failed to delete the semaphore instance

◆ appRtosSemaphorePend()

app_rtos_status_t appRtosSemaphorePend ( app_rtos_semaphore_handle_t  semhandle,
uint32_t  timeout 
)

Function to pend (wait) on a semaphore.

Parameters
semhandleA app_rtos_semaphore_handle_t returned from appRtosSemaphoreCreate
timeoutTimeout (in milliseconds) to wait for the semaphore to be posted (signaled).
Returns
Status of the functions
  • APP_RTOS_STATUS_SUCCESS: Obtain the semaphore
  • APP_RTOS_STATUS_TIMEOUT: Timed out. Semaphore was not obtained.
  • APP_RTOS_STATUS_FAILURE: Non-time out failure.

◆ appRtosSemaphorePost()

app_rtos_status_t appRtosSemaphorePost ( app_rtos_semaphore_handle_t  semhandle)

Function to post (signal) a semaphore.

Parameters
semhandleA app_rtos_semaphore_handle_t returned from appRtosSemaphoreCreate
Returns
Status of the functions
  • APP_RTOS_STATUS_SUCCESS: Released the semaphore
  • APP_RTOS_STATUS_FAILURE: Failed to post the semaphore

◆ appRtosSemaphoreReset()

app_rtos_status_t appRtosSemaphoreReset ( app_rtos_semaphore_handle_t  semhandle)

Function to clear a semaphore for reuse.

Parameters
semhandleA app_rtos_semaphore_handle_t returned from appRtosSemaphoreCreate
Returns
Status of the functions
  • APP_RTOS_STATUS_SUCCESS: Reset the semaphore
  • APP_RTOS_STATUS_FAILURE: Failed to reset the semaphore

◆ appRtosTaskParamsInit()

void appRtosTaskParamsInit ( app_rtos_task_params_t params)

Initialize params structure to default values.

Parameters
paramsPointer to the instance configuration parameters.

◆ appRtosTaskCreate()

app_rtos_task_handle_t appRtosTaskCreate ( const app_rtos_task_params_t params)

Function to create a task.

Parameters
paramsPointer to the instance configuration parameters.
Returns
app_rtos_task_handle_t on success or a NULL on an error

◆ appRtosTaskDelete()

app_rtos_status_t appRtosTaskDelete ( app_rtos_task_handle_t handle)

Function to delete a task.

Parameters
handleA app_rtos_semaphore_handle_t returned from appRtosSemaphoreCreate
Returns
Status of the functions
  • APP_RTOS_STATUS_SUCCESS: Deleted the task
  • APP_RTOS_STATUS_FAILURE: Failed to delete the task

◆ appRtosTaskIsTerminated()

uint32_t appRtosTaskIsTerminated ( app_rtos_task_handle_t  handle)

Check if task is terminated.

Typically a task MUST be terminated before it can be deleted.

Returns
0: task is not terminated, 1: task is terminated

◆ appRtosTaskYield()

void appRtosTaskYield ( void  )

Function for Task yield.

◆ appRtosTaskSleep()

void appRtosTaskSleep ( uint32_t  timeout)

Function for Task sleep in units of OS tick.

Parameters
timeoutsleep ticks.

◆ appRtosTaskSleepInMsecs()

void appRtosTaskSleepInMsecs ( uint32_t  timeoutInMsecs)

Function for Task sleep in units of msecs.

Parameters
timeoutInMsecssleep in units of msecs.