Morse Micro IoT SDK  2.6.4-esp32

Detailed Description

Provides memory management functionality managing tasks (create, destroy, yield, etc.).

Macros

#define MMOSAL_TASK_ENTER_CRITICAL()
 Enter critical section. More...
 
#define MMOSAL_TASK_EXIT_CRITICAL()
 Exit critical section. More...
 

Typedefs

typedef void(* mmosal_task_fn_t) (void *arg)
 Type definition for task main functions. More...
 

Enumerations

enum  mmosal_task_priority {
  MMOSAL_TASK_PRI_IDLE , MMOSAL_TASK_PRI_MIN , MMOSAL_TASK_PRI_LOW , MMOSAL_TASK_PRI_NORM ,
  MMOSAL_TASK_PRI_HIGH
}
 Enumeration of task priorities (ordered lowest to highest). More...
 

Functions

struct mmosal_task * mmosal_task_create (mmosal_task_fn_t task_fn, void *argument, enum mmosal_task_priority priority, unsigned stack_size_u32, const char *name)
 Create a new task. More...
 
void mmosal_task_delete (struct mmosal_task *task)
 Delete the given task. More...
 
void mmosal_task_join (struct mmosal_task *task)
 Block until the given task has terminated. More...
 
struct mmosal_task * mmosal_task_get_active (void)
 Get the handle of the active task. More...
 
void mmosal_task_yield (void)
 Yield the active task.
 
void mmosal_task_sleep (uint32_t duration_ms)
 Sleep for a period of time, yielding during that time. More...
 
void mmosal_task_enter_critical (void)
 Enter critical section. More...
 
void mmosal_task_exit_critical (void)
 Exit critical section. More...
 
void mmosal_disable_interrupts (void)
 Disable interrupts. More...
 
void mmosal_enable_interrupts (void)
 Enable interrupts. More...
 
const char * mmosal_task_name (void)
 Get the name of the running task. More...
 
bool mmosal_task_wait_for_notification (uint32_t timeout_ms)
 Blocks the current task until a notification is received. More...
 
void mmosal_task_notify (struct mmosal_task *task)
 Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue. More...
 
void mmosal_task_notify_from_isr (struct mmosal_task *task)
 Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue. More...
 

Macro Definition Documentation

◆ MMOSAL_TASK_ENTER_CRITICAL

#define MMOSAL_TASK_ENTER_CRITICAL ( )
Value:
do { \
MMPORT_MEM_SYNC(); \
mmosal_task_enter_critical(); \
} while (0)

Enter critical section.

This may result in interrupts being disabled so critical sections must be kept short. Each entry to a critical section must be matched to a corresponding exit (MMOSAL_TASK_EXIT_CRITICAL()).

Definition at line 252 of file mmosal.h.

◆ MMOSAL_TASK_EXIT_CRITICAL

#define MMOSAL_TASK_EXIT_CRITICAL ( )
Value:
do { \
MMPORT_MEM_SYNC(); \
mmosal_task_exit_critical(); \
} while (0)

Exit critical section.

Used to exit a critical section previously entered with MMOSAL_TASK_ENTER_CRITICAL()).

Definition at line 263 of file mmosal.h.

Typedef Documentation

◆ mmosal_task_fn_t

typedef void(* mmosal_task_fn_t) (void *arg)

Type definition for task main functions.

Parameters
argOpaque argument passed in at task creation.

Definition at line 173 of file mmosal.h.

Enumeration Type Documentation

◆ mmosal_task_priority

Enumeration of task priorities (ordered lowest to highest).

Enumerator
MMOSAL_TASK_PRI_IDLE 

Idle task priority.

MMOSAL_TASK_PRI_MIN 

Minimum priority.

MMOSAL_TASK_PRI_LOW 

Low priority.

MMOSAL_TASK_PRI_NORM 

Normal priority.

MMOSAL_TASK_PRI_HIGH 

High priority.

Definition at line 176 of file mmosal.h.

Function Documentation

◆ mmosal_disable_interrupts()

void mmosal_disable_interrupts ( void  )

Disable interrupts.

Warning
This function should generally not be used. Use mmosal_task_enter_critical() instead.

◆ mmosal_enable_interrupts()

void mmosal_enable_interrupts ( void  )

Enable interrupts.

Warning
This function should generally not be used. Use mmosal_task_exit_critical() instead.

◆ mmosal_task_create()

struct mmosal_task * mmosal_task_create ( mmosal_task_fn_t  task_fn,
void *  argument,
enum mmosal_task_priority  priority,
unsigned  stack_size_u32,
const char *  name 
)

Create a new task.

Parameters
task_fnTask main function.
argumentArgument to pass to main function.
priorityTask priority.
stack_size_u32Size of stack to allocate for task (in units of 32 bit words).
nameName to give the task.
Returns
an opaque task handle, or NULL on failure.

◆ mmosal_task_delete()

void mmosal_task_delete ( struct mmosal_task *  task)

Delete the given task.

Parameters
taskHandle of the task to delete (or NULL to delete the current task).
Note
With FreeRTOS deleted tasks will not be cleaned up until the idle task runs.

◆ mmosal_task_enter_critical()

void mmosal_task_enter_critical ( void  )

Enter critical section.

This may result in interrupts being disabled so critical sections must be kept short. Each entry to a critical section must be matched to a corresponding exit (mmosal_task_exit_critical()).

Note
This function should not be invoked directly. Use MMOSAL_TASK_ENTER_CRITICAL().

◆ mmosal_task_exit_critical()

void mmosal_task_exit_critical ( void  )

Exit critical section.

Used to exit a critical section previously entered with mmosal_task_enter_critical()).

Note
This function should not be invoked directly. Use MMOSAL_TASK_EXIT_CRITICAL().

◆ mmosal_task_get_active()

struct mmosal_task * mmosal_task_get_active ( void  )

Get the handle of the active task.

Returns
the handle of the active task.

◆ mmosal_task_join()

void mmosal_task_join ( struct mmosal_task *  task)

Block until the given task has terminated.

Parameters
taskHandle of the task to wait for.
Note
With FreeRTOS deleted tasks will not be cleaned up until the idle task runs.
Deprecated:
Do not invoke this function because it is deprecated and will be removed from the mmosal API in a future release.

◆ mmosal_task_name()

const char * mmosal_task_name ( void  )

Get the name of the running task.

Returns
the name of the running task.

◆ mmosal_task_notify()

void mmosal_task_notify ( struct mmosal_task *  task)

Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue.

Warning
Must not be called from ISR context.
Parameters
taskHandle of the task to notify.
See also
mmosal_task_wait_for_notification()

◆ mmosal_task_notify_from_isr()

void mmosal_task_notify_from_isr ( struct mmosal_task *  task)

Notifies a waiting task (mmosal_task_wait_for_notification()) that it can continue.

Warning
Must only be called from ISR context.
Parameters
taskHandle of the task to notify.
See also
mmosal_task_wait_for_notification()

◆ mmosal_task_sleep()

void mmosal_task_sleep ( uint32_t  duration_ms)

Sleep for a period of time, yielding during that time.

Parameters
duration_msSleep duration, in milliseconds.

◆ mmosal_task_wait_for_notification()

bool mmosal_task_wait_for_notification ( uint32_t  timeout_ms)

Blocks the current task until a notification is received.

Notifications can be sent using mmosal_task_notify() or mmosal_task_notify_from_isr().

Parameters
timeout_msThe time to wait before giving up (or UINT32_MAX to wait forever).
Returns
true of a notification was received or false if it timed out.
See also
mmosal_task_notify()
mmosal_task_notify_from_isr()