Morse Micro IoT SDK  2.9.7

Detailed Description

Provides counting semaphore support for task synchronization.

Functions

struct mmosal_sem * mmosal_sem_create (unsigned max_count, unsigned initial_count, const char *name)
 Create a new counting semaphore. More...
 
void mmosal_sem_delete (struct mmosal_sem *sem)
 Delete the given counting semaphore. More...
 
bool mmosal_sem_give (struct mmosal_sem *sem)
 Give a counting semaphore. More...
 
bool mmosal_sem_give_from_isr (struct mmosal_sem *sem)
 Give a counting semaphore (from ISR context). More...
 
bool mmosal_sem_wait (struct mmosal_sem *sem, uint32_t timeout_ms)
 Wait for a counting semaphore. More...
 
uint32_t mmosal_sem_get_count (struct mmosal_sem *sem)
 Returns the current count of the semaphore. More...
 

Function Documentation

◆ mmosal_sem_create()

struct mmosal_sem * mmosal_sem_create ( unsigned  max_count,
unsigned  initial_count,
const char *  name 
)

Create a new counting semaphore.

Parameters
max_countThe maximum count (i.e., number of times the semaphore can be given).
initial_countThe initial count (i.e., number of times the semaphore is implicitly given when it is created).
nameThe name of the semaphore.
Returns
an opaque handle to the semaphore, or NULL on failure.

◆ mmosal_sem_delete()

void mmosal_sem_delete ( struct mmosal_sem *  sem)

Delete the given counting semaphore.

Parameters
semSemaphore to delete.

◆ mmosal_sem_get_count()

uint32_t mmosal_sem_get_count ( struct mmosal_sem *  sem)

Returns the current count of the semaphore.

Parameters
semThe semaphore being queried.
Returns
The count of the semaphore being queried.

◆ mmosal_sem_give()

bool mmosal_sem_give ( struct mmosal_sem *  sem)

Give a counting semaphore.

Warning
May not be invoked from an ISR.
Parameters
semThe semaphore to give.
Returns
true on success, else false.

◆ mmosal_sem_give_from_isr()

bool mmosal_sem_give_from_isr ( struct mmosal_sem *  sem)

Give a counting semaphore (from ISR context).

Warning
May only be invoked from an ISR.
Parameters
semThe semaphore to give.
Returns
true on success, else false.

◆ mmosal_sem_wait()

bool mmosal_sem_wait ( struct mmosal_sem *  sem,
uint32_t  timeout_ms 
)

Wait for a counting semaphore.

Parameters
semThe semaphore to wait for.
timeout_msTimeout after which to give up waiting (in milliseconds).
Returns
true if the the semaphore was taken successfully, else false.