![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform various Operating systems operations. More...
This section describes the M2MB APIs to perform various Operating systems operations.
#define M2MB_OS_ENTER_CRITICAL | ( | ) | do { __asm("cpsid i"); } while(0) |
#define M2MB_OS_EXIT_CRITICAL | ( | ) | do { __asm("cpsie i"); } while(0) |
typedef HANDLE M2MB_OS_TASK_ATTR_HANDLE |
typedef HANDLE M2MB_OS_TASK_HANDLE |
enum M2MB_OS_MEMINFO_E |
enum M2MB_OS_TASK_STATE_E |
Allocates bytes of memory and init space with 0.
This function provides service to reserve memory space to the caller and initialize it to 0
[in] | count | Number of blocks of memory to be allocated |
[in] | size | size in byte of memory to be allocated and initialize |
Example
M2MB_OS_RESULT_E m2mb_os_free | ( | void * | pMem | ) |
Free allocated memory.
This function provides service to free already allocated memory space
[in] | pMem | pointer to memory where to release previous allocation |
Example
M2MB_OS_RESULT_E m2mb_os_get_errno | ( | UINT32 * | pCategory, |
INT32 * | pErrno | ||
) |
Allow to get Errno saved in a relative task environment.
This service allows to get last error number task safe, with the specified type of category for the error. It checks the error in the environment task in which the function is called, so to check the error, call it with this in mind
[out] | pCategory | pointer for environment category the error is relative |
[out] | pErrno | pointer to the variable where to set the error |
Example
FLOAT32 m2mb_os_getSysTickDuration_ms | ( | void | ) |
Get the duration of system tick in ms.
This service returns the value of the duration in ms of tick used inside the system
Example
UINT32 m2mb_os_getSysTicks | ( | void | ) |
Get system time in ticks.
This service returns the contents of the internal system clock. Each timer- tick increases the internal system clock by one. The system clock is set to zero during initialization and can be changed to a specific value by the service m2mb_os_setSysTicks.
Example
M2MB_OS_RESULT_E m2mb_os_init | ( | void | ) |
Initialization of OS.
Init of operating systems. Should be called as initialization process, before calling any other function of OS Simple init function which will setup the OS environment for next usage
Example
Enable and disable interrupts (ISRs)
This service enables or disables interrupts as specified by the input parameter newIsrState. If this service is called from an application task, the interrupt isrState remains part of that thread’s context. For example, if the thread calls this routine to disable interrupts and then suspends, when it is resumed, interrupts are disabled again.
[in] | newIsrState | value to be set for ISR |
Example
void* m2mb_os_malloc | ( | UINT32 | size | ) |
Allocates bytes of memory.
This function provides service to reserve memory space to the caller
[in] | size | size in byte of memory to be allocated |
pointer to 10 UINT32 UINT32 *pUint; pUint = ( UINT32 * )m2mb_os_malloc( 10 * sizeof(UINT32) ); if ( pUint == NULL ) exit(...)
void* m2mb_os_realloc | ( | void * | ptr, |
UINT32 | size | ||
) |
M2MB_OS_RESULT_E m2mb_os_setSysTicks | ( | UINT32 | newTick | ) |
Set start system time in ticks.
This service sets the internal system clock to the specified value. Each timer-tick increases the internal system clock by one.
[in] | newTick | New value to be set in system clock |
Example
M2MB_OS_RESULT_E m2mb_os_taskCooperate | ( | void | ) |
Make task to cooperate by releasing scheduler control.
This service give control to scheduler if other tasks are ready-to-run at the same or higher priority. This is a method to allow other tasks at the same priority to be executed. Think about while1 tasks...
Example
M2MB_OS_RESULT_E m2mb_os_taskCreate | ( | M2MB_OS_TASK_HANDLE * | pTaskHandle, |
M2MB_OS_TASK_ATTR_HANDLE * | pTaskAttr, | ||
ENTRY_FN | entryFn, | ||
void * | pArg | ||
) |
Create application task.
This service creates an application task that starts execution at the specified task entry function. The stack, priority, preemption-threshold, time-slice, and initial execution state of the task are among the attributes specified by the input parameters in pTaskAttr. If stack is not provided, it will be allocated by the system and removed after task deletion. If stack size is not provided, the minimum stack size M2MB_OS_MIN_STACK_SIZE will be allocated.
[in] | pTaskHandle | pointer to Handle of the task to be used for future calling the specific task |
[in] | pTaskAttr | handle Attribute and options of the task to be created |
[in] | entryFn | Function which will be the start for the task |
[in] | pArg | pointer - argument of the entry function of the task |
M2MB_OS_RESULT_E m2mb_os_taskDelete | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Task delete.
This service deletes the specified application task. Since the specified task must be in a terminated or completed state, this service cannot be called from a task attempting to delete itself.
[in,out] | taskHandle | handle of the task to be deleted: after release it is set to M2MB_OS_TASK_INVALID |
Allowed From Tasks and timers Preemption Possible No
Example
M2MB_OS_TASK_HANDLE m2mb_os_taskGetId | ( | void | ) |
Retrieves handle to the currently executing task.
The function return the handle of the currently executing task This Function is used to get task handle of the currently executing task
Example
M2MB_OS_RESULT_E m2mb_os_taskGetItem | ( | M2MB_OS_TASK_HANDLE | taskHandle, |
M2MB_OS_TASK_SEL_CMD_E | selCmd, | ||
MEM_W * | pOut, | ||
void * | pIn | ||
) |
Get specific task properties.
This function retrieves special information of the specified task Selecting cmd, a parameter to be retrieved can be set To be used when a task is already created: its right usage is under application responsibility
[in] | taskHandle | Task handle identifies the task to get parameter from |
[in] | selCmd | Select parameter to be retrieved (see M2MB_OS_TASK_SEL_CMD_E) |
[out] | pOut | pointer Output parameter got: its meaning depends on selCmd used See examples |
[in] | pIn | pointer to Parameter to be specified, if any, to get right output See examples If the parameter is not needed, use NULL |
Example
M2MB_OS_RESULT_E m2mb_os_taskRestart | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Task restart.
This service resets the specified task to execute at the entry point defined during task creation. The task must be in either a M2MB_OS_TASK_STATE_COMPLETED or M2MB_OS_TASK_STATE_TERMINATED state for it to be restarted It is in: M2MB_OS_TASK_STATE_COMPLETED when reached the
[in] | taskHandle | handle of the task to be restarted |
Example
M2MB_OS_RESULT_E m2mb_os_taskResume | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Resume suspended application task.
This service resumes or prepares for execution a task that was previously suspended by a m2mb_os_taskSuspend call. In addition, this service resumes tasks that were created without an automatic start.
[in] | taskHandle | handle of the task to resume |
Example
M2MB_OS_RESULT_E m2mb_os_taskSetAttrItem | ( | M2MB_OS_TASK_ATTR_HANDLE * | pTaskAttrHandle, |
UINT8 | nCmds, | ||
... | |||
) |
Set specific attribute for task creation.
Attribute defined can be used to create the task
[in,out] | pTaskAttrHandle | Pointer to M2MB_OS_TASK_ATTR_HANDLE handle to be set |
[in] | nCmds | Number of commands to be issued at once |
[in] | ... | variable inputs, N cmds (see M2MB_OS_TASK_SEL_CMD_E) followed by N arguments for their respective issued commands. CMDS(...) and CMDS_ARGS(...) macro can be used to better insert cmd and parameters and to better control right insertion |
Allowed From Initialization, tasks, timers, and ISRs Preemption Possible Yes
Example
M2MB_OS_RESULT_E m2mb_os_taskSetItem | ( | M2MB_OS_TASK_HANDLE | taskHandle, |
M2MB_OS_TASK_SEL_CMD_E | selCmd, | ||
void * | pIn | ||
) |
Set specific task properties.
This function sets value for a specified parameter of the specified task Selecting cmd, a parameter to be set can be selected To be used when a task is already created: it is under application responsibility
[in] | taskHandle | Task handle identifies the task to set parameter to |
[in] | selCmd | Select parameter to be set (see M2MB_OS_TASK_SEL_CMD_E) |
[in] | pIn | Pointer as value of parameter is to be set to the specified parameter |
Example
M2MB_OS_RESULT_E m2mb_os_taskSuspend | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Suspend application task.
This service suspends the specified application task. A task may call this service to suspend itself. After being suspended, the task must be resumed by m2mb_os_taskResume to execute again.
[in] | taskHandle | handle of the task to suspend |
If the specified task is already suspended for another reason, this suspension is held internally until the prior suspension is lifted. When that happens, this unconditional suspension of the specified task is performed. Further unconditional suspension requests have no effect.
Example
M2MB_OS_RESULT_E m2mb_os_taskTerminate | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Terminates application task.
This service terminates the specified application task regardless of whether the task is suspended or not. A task may call this service to terminate itself. After being terminated, the task must be restarted through m2mb_os_taskRestart for it to execute again.
[in] | taskHandle | handle of the task to terminate |
Example
M2MB_OS_RESULT_E m2mb_os_taskWaitAbort | ( | M2MB_OS_TASK_HANDLE | taskHandle | ) |
Abort suspension of a specified task.
This service aborts sleep or any other object suspension of the specified task. If the wait is aborted, a M2MB_OS_WAIT_ABORTED value is returned from the service that the task was waiting on. This service does not release explicit suspension that is made by the m2mb_os_taskSuspend service.
[in] | taskHandle | Handle of the task |
Example of use:
int m2mb_thread_fp_enable | ( | void | ) |
Sets the thread floating point unit flag.
By default, FPU support is disabled for each thread. If context of the FPU registers need to be saved, this API call must be made from the context of the application thread before the FPU usage.
Example