<< Previous | Next >>

OSFlagPend

OS_FLAGS OSFlagPend( OS_FLAG_GRP * pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U * err );

Description

This function is called to wait for a combination of bits to be set in an event flag group. Your application can wait for ANY bit to be set or ALL bits to be set.

Parameters

pgrp
Pointer to the desired event flag group.

flags
Bit pattern indicating which bit(s) (i.e. flags) you wish to wait for. E.g. if your application wants to wait for bits 0 and 1 then flags should be 0x03.

wait_type
Specifies whether you want ALL bits to be set or ANY of the bits to be set. You can specify the following argument:

  • OS_FLAG_WAIT_CLR_ALL - You will wait for ALL bits in mask to be clear (0)

  • OS_FLAG_WAIT_SET_ALL - You will wait for ALL bits in mask to be set (1)

  • OS_FLAG_WAIT_CLR_ANY - You will wait for ANY bit in mask to be clear (0)

  • OS_FLAG_WAIT_SET_ANY - You will wait for ANY bit in mask to be set (1)

NOTE Add OS_FLAG_CONSUME if you want the event flag to be consumed by the call. E.g., to wait for any flag in a group AND then clear the flags that are present, set the wait_type parameter to:

OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME

timeout
An optional timeout (in clock ticks) that your task will wait for the desired bit combination. If you specify 0, however, your task will wait forever at the specified event flag group or, until a message arrives.

err
Pointer to an error code. Possible values are:

OS_NO_ERR - The desired bits have been set within the specified time- out.

OS_ERR_PEND_ISR - If you tried to PEND from an ISR.

OS_FLAG_INVALID_PGRP - If pgrp is a null pointer.

OS_ERR_EVENT_TYPE - You are not pointing to an event flag group

OS_TIMEOUT - The bit(s) have not been set in the specified time-out.

OS_FLAG_ERR_WAIT_TYPE - You didn't specify a proper wait_type argument.

Return value

The new state of the flags in the event flag group when the task is resumed or, 0 if a timeout or an error occurred.

Library

OS_FLAG.C (Prior to DC 8:UCOS2.LIB)


Dynamic C Functions << Previous | Next >> rabbit.com