Jump to main content

##

# 1.4.4.8 OSAL_CRIT_Leave Function

## C

    void  OSAL_CRIT_Leave(OSAL_CRIT_TYPE severity, OSAL_CRITSECT_DATA_TYPE status)

## Summary

Leaves a critical section with the specified severity level.

## Description

This function leaves a critical section of code. It is assumed that the sequence of operations bounded by the enter and leave critical section operations is treated as one atomic sequence that will not be disturbed. The severity should match the severity level used in the corresponding OSAL_CRIT_Enter call to ensure that the RTOS carries out the correct action.

## Precondition

None.

## Parameters

Param | Description
--- | ---
severity | OSAL_CRIT_TYPE_LOW, The scheduler will be unlocked, if no other nested calls to OSAL_CRIT_ENTER have been made. OSAL_CRIT_TYPE_HIGH, Interrupts are returned to the state passed into this function. The state should of been saved by an earlier call to OSAL_CRIT_Enter
status | The value which will be used to set the state of global interrupts, if OSAL_CRIT_TYPE_HIGH is passed in

## Returns

None.

## Example

    OSAL_CRITSECT_DATA_TYPE IntState;
    // prevent other tasks preempting this sequence of code
    intState = OSAL_CRIT_Enter(OSAL_CRIT_TYPE_LOW);
    // modify the peripheral
    DRV_USART_Reinitialize( objUSART, &initData);
    OSAL_CRIT_Leave(OSAL_CRIT_TYPE_LOW, IntState);

## Remarks

The sequence of operations bounded by the OSAL_CRIT_Enter and OSAL_CRIT_Leave form a critical section. The severity level defines whether the RTOS should perform task locking or completely disable all interrupts.