APIs for acquiring and working with Semaphores.
cy_rslt_t | cy_rtos_semaphore_init (cy_semaphore_t *semaphore, uint32_t maxcount, uint32_t initcount) |
Create a semaphore. More... | |
cy_rslt_t | cy_rtos_semaphore_get (cy_semaphore_t *semaphore, cy_time_t timeout_ms) |
Get/Acquire a semaphore. More... | |
cy_rslt_t | cy_rtos_semaphore_set (cy_semaphore_t *semaphore) |
Set/Release a semaphore. More... | |
cy_rslt_t | cy_rtos_semaphore_get_count (cy_semaphore_t *semaphore, size_t *count) |
Get the count of a semaphore. More... | |
cy_rslt_t | cy_rtos_semaphore_deinit (cy_semaphore_t *semaphore) |
Deletes a semaphore. More... | |
#define | cy_rtos_init_semaphore(semaphore, maxcount, initcount) cy_rtos_semaphore_init(semaphore, maxcount, initcount) |
Create a semaphore. More... | |
#define | cy_rtos_get_semaphore(semaphore, timeout_ms, in_isr) cy_rtos_semaphore_get(semaphore, timeout_ms) |
Get/Acquire a semaphore. More... | |
#define | cy_rtos_set_semaphore(semaphore, in_isr) cy_rtos_semaphore_set(semaphore) |
Set/Release a semaphore. More... | |
#define | cy_rtos_get_count_semaphore(semaphore, count) cy_rtos_semaphore_get_count(semaphore, count) |
Get the count of a semaphore. More... | |
#define | cy_rtos_deinit_semaphore(semaphore) cy_rtos_semaphore_deinit(semaphore) |
Deletes a semaphore. More... | |
#define cy_rtos_init_semaphore | ( | semaphore, | |
maxcount, | |||
initcount | |||
) | cy_rtos_semaphore_init(semaphore, maxcount, initcount) |
Create a semaphore.
This is basically a counting semaphore. It can be used for synchronization between tasks and tasks and interrupts.
[in,out] | semaphore | Pointer to the semaphore handle to be initialized |
[in] | maxcount | The maximum count for this semaphore |
[in] | initcount | The initial count for this semaphore |
#define cy_rtos_get_semaphore | ( | semaphore, | |
timeout_ms, | |||
in_isr | |||
) | cy_rtos_semaphore_get(semaphore, timeout_ms) |
Get/Acquire a semaphore.
If the semaphore count is zero, waits until the semaphore count is greater than zero. Once the semaphore count is greater than zero, this function decrements the count and return. It may also return if the timeout is exceeded.
[in] | semaphore | Pointer to the semaphore handle |
[in] | timeout_ms | Maximum number of milliseconds to wait while attempting to get the semaphore. Use the CY_RTOS_NEVER_TIMEOUT constant to wait forever. Must be zero if in_isr is true. |
[in] | in_isr | true if we are trying to get the semaphore from with an ISR |
#define cy_rtos_set_semaphore | ( | semaphore, | |
in_isr | |||
) | cy_rtos_semaphore_set(semaphore) |
Set/Release a semaphore.
Increments the semaphore count, up to the maximum count for this semaphore.
[in] | semaphore | Pointer to the semaphore handle |
[in] | in_isr | Value of true indicates calling from interrupt context Value of false indicates calling from normal thread context |
#define cy_rtos_get_count_semaphore | ( | semaphore, | |
count | |||
) | cy_rtos_semaphore_get_count(semaphore, count) |
Get the count of a semaphore.
Gets the number of available tokens on the semaphore.
[in] | semaphore | Pointer to the semaphore handle |
[out] | count | Pointer to the return count |
#define cy_rtos_deinit_semaphore | ( | semaphore | ) | cy_rtos_semaphore_deinit(semaphore) |
Deletes a semaphore.
This function frees the resources associated with a semaphore.
[in] | semaphore | Pointer to the semaphore handle |
cy_rslt_t cy_rtos_semaphore_init | ( | cy_semaphore_t * | semaphore, |
uint32_t | maxcount, | ||
uint32_t | initcount | ||
) |
Create a semaphore.
This is basically a counting semaphore. It can be used for synchronization between tasks and tasks and interrupts.
[in,out] | semaphore | Pointer to the semaphore handle to be initialized |
[in] | maxcount | The maximum count for this semaphore |
[in] | initcount | The initial count for this semaphore |
cy_rslt_t cy_rtos_semaphore_get | ( | cy_semaphore_t * | semaphore, |
cy_time_t | timeout_ms | ||
) |
Get/Acquire a semaphore.
If the semaphore count is zero, waits until the semaphore count is greater than zero. Once the semaphore count is greater than zero, this function decrements the count and return. It may also return if the timeout is exceeded.
[in] | semaphore | Pointer to the semaphore handle |
[in] | timeout_ms | Maximum number of milliseconds to wait while attempting to get the semaphore. Use the CY_RTOS_NEVER_TIMEOUT constant to wait forever. Must be zero if in_isr is true. |
cy_rslt_t cy_rtos_semaphore_set | ( | cy_semaphore_t * | semaphore | ) |
Set/Release a semaphore.
Increments the semaphore count, up to the maximum count for this semaphore.
[in] | semaphore | Pointer to the semaphore handle Value of false indicates calling from normal thread context |
cy_rslt_t cy_rtos_semaphore_get_count | ( | cy_semaphore_t * | semaphore, |
size_t * | count | ||
) |
Get the count of a semaphore.
Gets the number of available tokens on the semaphore.
[in] | semaphore | Pointer to the semaphore handle |
[out] | count | Pointer to the return count |
cy_rslt_t cy_rtos_semaphore_deinit | ( | cy_semaphore_t * | semaphore | ) |
Deletes a semaphore.
This function frees the resources associated with a semaphore.
[in] | semaphore | Pointer to the semaphore handle |