PDK API Guide for J721E
SemaphoreP

Introduction

SemaphoreP interface

Files

file  SemaphoreP.h
 Semaphore module for the RTOS Porting Interface.
 

Data Structures

struct  SemaphoreP_Params
 Basic SemaphoreP Parameters. More...
 

Functions

SemaphoreP_Handle SemaphoreP_create (uint32_t count, const SemaphoreP_Params *semParams)
 Function to create a semaphore. More...
 
SemaphoreP_Status SemaphoreP_delete (SemaphoreP_Handle semPhandle)
 Function to delete a semaphore. More...
 
void SemaphoreP_Params_init (SemaphoreP_Params *semParams)
 Initialize params structure to default values. More...
 
SemaphoreP_Status SemaphoreP_pend (SemaphoreP_Handle semPhandle, uint32_t timeout)
 Function to pend (wait) on a semaphore. More...
 
SemaphoreP_Status SemaphoreP_post (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore. More...
 
SemaphoreP_Status SemaphoreP_postFromClock (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore from an ClockP function. More...
 
SemaphoreP_Status SemaphoreP_postFromISR (SemaphoreP_Handle semPhandle)
 Function to post (signal) a semaphore from an ISR. More...
 
int32_t SemaphoreP_getCount (SemaphoreP_Handle semPhandle)
 Function to return the count of a semaphore. More...
 
SemaphoreP_Status SemaphoreP_reset (SemaphoreP_Handle semPhandle)
 Function to clear a semaphore for resuse. More...
 

Typedefs

typedef void * SemaphoreP_Handle
 Opaque client reference to an instance of a SemaphoreP. More...
 

Macros

#define SemaphoreP_WAIT_FOREVER   (~((uint32_t)0U))
 Wait forever define. More...
 
#define SemaphoreP_NO_WAIT   ((uint32_t)0U)
 No wait define. More...
 

Semaphore status code

typedef int32_t SemaphoreP_Status
 Status codes for SemaphoreP APIs. More...
 
#define SemaphoreP_OK   (0)
 
#define SemaphoreP_FAILURE   (-(int32_t)1)
 
#define SemaphoreP_TIMEOUT   (-(int32_t)2)
 
#define SemaphoreP_UNSUPPORTED   (-(int32_t)3)
 

Mode of Semaphore

typedef uint32_t SemaphoreP_Mode
 Mode of the semaphore. More...
 
#define SemaphoreP_Mode_COUNTING   (0x0U)
 
#define SemaphoreP_Mode_BINARY   (0x1U)
 

Macro Definition Documentation

#define SemaphoreP_OK   (0)
#define SemaphoreP_FAILURE   (-(int32_t)1)

API completed successfully

#define SemaphoreP_TIMEOUT   (-(int32_t)2)

API failed

#define SemaphoreP_UNSUPPORTED   (-(int32_t)3)

API failed because of a timeout

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

Wait forever define.

API failed because of not supported

#define SemaphoreP_NO_WAIT   ((uint32_t)0U)

No wait define.

#define SemaphoreP_Mode_COUNTING   (0x0U)
#define SemaphoreP_Mode_BINARY   (0x1U)

Typedef Documentation

typedef int32_t SemaphoreP_Status

Status codes for SemaphoreP APIs.

typedef void* SemaphoreP_Handle

Opaque client reference to an instance of a SemaphoreP.

A SemaphoreP_Handle returned from the SemaphoreP_create represents that instance and is used in the other instance based functions (e.g. SemaphoreP_post or SemaphoreP_pend, etc.).

typedef uint32_t SemaphoreP_Mode

Mode of the semaphore.

Function Documentation

SemaphoreP_Handle SemaphoreP_create ( uint32_t  count,
const SemaphoreP_Params semParams 
)

Function to create a semaphore.

Parameters
countInitial count of the semaphore. For binary semaphores, only values of 0 or 1 are valid.
semParamsPointer to the instance configuration parameters. NULL denotes to use the default parameters (SemaphoreP default parameters as noted in SemaphoreP_Params_init.
Returns
A SemaphoreP_Handle on success or a NULL on an error
SemaphoreP_Status SemaphoreP_delete ( SemaphoreP_Handle  semPhandle)

Function to delete a semaphore.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
Returns
Status of the functions
  • SemaphoreP_OK: Deleted the semaphore instance
  • SemaphoreP_FAILED: Failed to delete the semaphore instance
void SemaphoreP_Params_init ( SemaphoreP_Params semParams)

Initialize params structure to default values.

The default parameters are:

  • mode: SemaphoreP_Mode_COUNTING
  • name: NULL
Parameters
semParamsPointer to the instance configuration parameters.
SemaphoreP_Status SemaphoreP_pend ( SemaphoreP_Handle  semPhandle,
uint32_t  timeout 
)

Function to pend (wait) on a semaphore.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
timeoutTimeout (in milliseconds) to wait for the semaphore to be posted (signalled).
Returns
Status of the functions
  • SemaphoreP_OK: Obtain the semaphore
  • SemaphoreP_TIMEOUT: Timed out. Semaphore was not obtained.
  • SemaphoreP_FAILED: Non-time out failure.
SemaphoreP_Status SemaphoreP_post ( SemaphoreP_Handle  semPhandle)

Function to post (signal) a semaphore.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
Returns
Status of the functions
  • SemaphoreP_OK: Released the semaphore
  • SemaphoreP_FAILED: Failed to post the semaphore
SemaphoreP_Status SemaphoreP_postFromClock ( SemaphoreP_Handle  semPhandle)

Function to post (signal) a semaphore from an ClockP function.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
Returns
Status of the functions
  • SemaphoreP_OK: Released the semaphore
  • SemaphoreP_FAILED: Failed to post the semaphore
SemaphoreP_Status SemaphoreP_postFromISR ( SemaphoreP_Handle  semPhandle)

Function to post (signal) a semaphore from an ISR.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
Returns
Status of the functions
  • SemaphoreP_OK: Released the semaphore
  • SemaphoreP_FAILED: Failed to post the semaphore
int32_t SemaphoreP_getCount ( SemaphoreP_Handle  semPhandle)

Function to return the count of a semaphore.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create
Returns
The count of the semaphore
SemaphoreP_Status SemaphoreP_reset ( SemaphoreP_Handle  semPhandle)

Function to clear a semaphore for resuse.

Parameters
semPhandleA SemaphoreP_Handle returned from SemaphoreP_create