1.4.4.1 OSAL_SEM_Create Function
1.4.4.1 C
OSAL_RESULT OSAL_SEM_Create(OSAL_SEM_HANDLE_TYPE* semID, OSAL_SEM_TYPE type, uint8_t maxCount, uint8_t initialCount)
1.4.4.1 Summary
Creates an OSAL Semaphore.
1.4.4.1 Description
This function creates an OSAL binary or counting semaphore. If OSAL_SEM_TYPE_BINARY is specified, the maxcount and initialCount values are ignored.
1.4.4.1 Precondition
Semaphore must have been declared.
1.4.4.1 Parameters
| Parameters | Description |
|---|---|
| semID | Pointer to the Semaphore ID. Updated with valid semaphore handle if call was successful. |
| type | If OSAL_SEM_TYPE_BINARY, create a binary semaphore. If OSAL_SEM_TYPE_COUNTING, create a counting semaphore with the specified count values. |
| maxCount | Maximum value for a counting semaphore (ignored for a BINARY semaphore). This parameter is ignored for ThreadX and Micrium OS-III as these RTOS libraries do not support this parameter. |
| initialCount | Starting count value for the semaphore (ignored for a BINARY semaphore). This should be less than or equal to maxCount when used with a RTOS library that supports the maxCount parameter (e.g., FreeRTOS and OPENRTOS). |
1.4.4.1 Returns
OSAL_RESULT_TRUE - Semaphore created.
OSAL_RESULT_FALSE - Semaphore creation failed.
1.4.4.1 Example
OSAL_SEM_Create(&mySemID, OSAL_SEM_TYPE_COUNTING, 10, 5);
1.4.4.1 Remarks
None.
