Jump to main content

##

# 1.4.4.3 OSAL_SEM_Pend Function

## C

    OSAL_RESULT OSAL_SEM_Pend(OSAL_SEM_HANDLE_TYPE* semID, uint16_t waitMS)

## Summary

Waits on a semaphore. Returns true if the semaphore was obtained within the time limit.

## Description

This function is a blocking function call that waits (i.e., pends) on a semaphore. The function will return true if the semaphore has been obtained, or false if it was not available or the time limit was exceeded.

## Precondition

Semaphore must have been created.

## Parameters

Param | Description
--- | ---
semID | Pointer to the Semaphore ID
waitMS | Time limit to wait in milliseconds: 0 - do not wait, OSAL_WAIT_FOREVER - return only when semaphore is obtained, Other values - time-out delay

## Returns

OSAL_RESULT_TRUE - Semaphore obtained

OSAL_RESULT_FALSE - Semaphore not obtained or time-out occurred

## Example

    if (OSAL_SEM_Pend(&semUARTRX, 50) == OSAL_RESULT_TRUE)
    {
        // character available
        c = DRV_USART_ReadByte(drvID);
        ...
    }
    else
    {
        // character not available, resend prompt
        ...
    }

## Remarks

None.