📄 pos_nano.h
字号:
* The CPU usage statistics is updated one time per second.
* @{
*/
/**
* Calculate and return the percentage of CPU usage.
* @return percentage of CPU usage (0 ... 100 %%)
* @note ::NOSCFG_FEATURE_CPUUSAGE must be defined to 1
* to have this function compiled in.
*/
UVAR_t nosCpuUsage(void);
#endif
/** @} */
/*---------------------------------------------------------------------------
* ABSTRACTED FUNCTIONS
*-------------------------------------------------------------------------*/
#ifdef _N_CORE_C
#define NANOEXT
#else
#define NANOEXT extern
#endif
/** @defgroup absfunc Abstracted Functions
* @ingroup userapin
* The nano layer supports most of all pico layer functions in an
* abstracted form. This is necessary to follow the layering scheme
* while all pico layer functions remain accessible.
* The general rule is to replace the prefix 'pos' by the new prefix 'nos'
* for the nano layer functions. But pay attention: Some nano layer functions
* have some more functionality as their pendant in the pico layer.
* @{
*/
/** @defgroup nanotask Task Control Functions
* @ingroup absfunc
* @{
*/
/** Handle to a nano layer task object. */
typedef POSTASK_t NOSTASK_t;
#if (DOX!=0) || (NOSCFG_FEATURE_TASKCREATE != 0)
/**
* Generic task function. Creates a new task.
* @param funcptr pointer to the function that shall be executed
* by the new task.
* @param funcarg optional argument passed to function funcptr.
* @param priority task priority. Must be in the range
* 0 .. ::POSCFG_MAX_PRIO_LEVEL - 1.
* The higher the number, the higher the priority.
* @param stacksize Size of the stack memory. If set to zero,
* a default stack size is assumed
* (see define ::NOSCFG_DEFAULT_STACKSIZE).
* @param name Name of the new task to create. If the last character
* in the name is an asteriks (*), the operating system
* automatically assigns the task a unique name (the
* registry feature must be enabled for this automatism).
* This parameter can be NULL if the nano layer registry
* feature is not used and will not be used in future.
* @return handle to the task. NULL is returned when the
* task could not be created.
* @note ::NOSCFG_FEATURE_TASKCREATE must be defined to 1
* to have this function compiled in.
* @sa nosTaskExit
*/
NANOEXT NOSTASK_t nosTaskCreate(POSTASKFUNC_t funcptr, void *funcarg,
VAR_t priority, UINT_t stacksize,
const char* name);
#if (DOX!=0) || (POSCFG_FEATURE_YIELD != 0)
/**
* Task function.
* This function can be called to give off processing time so other tasks
* ready to run will be scheduled (= cooparative multitasking).
* @note ::POSCFG_FEATURE_YIELD must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskSleep
*/
#if DOX
NANOEXT void nosTaskYield(void);
#else
#define nosTaskYield() posTaskYield()
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_SLEEP != 0)
/**
* Task function.
* Delay task execution for a couple of timer ticks.
* @param ticks delay time in timer ticks
* (see ::HZ define and ::MS macro)
* @note ::POSCFG_FEATURE_SLEEP must be defined to 1
* to have this function compiled in.@n
* It is not guaranteed that the task will proceed
* execution exactly when the time has elapsed.
* A higher priorized task or a task having the same
* priority may steal the processing time.
* Sleeping a very short time is inaccurate. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskYield, HZ, MS
*/
#if DOX
NANOEXT void nosTaskSleep(UINT_t ticks);
#else
#define nosTaskSleep(ticks) posTaskSleep(ticks)
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_EXIT != 0)
/**
* Task function.
* Terminate execution of a task.
* @note ::POSCFG_FEATURE_EXIT must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskCreate
*/
#if DOX
NANOEXT void nosTaskExit(void);
#else
#define nosTaskExit() posTaskExit()
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_GETTASK != 0)
/**
* Task function.
* Get the handle to the currently running task.
* @return the task handle.
* @note ::POSCFG_FEATURE_GETTASK must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskCreate, nosTaskSetPriority
*/
#if DOX
NANOEXT NOSTASK_t nosTaskGetCurrent(void);
#else
#define nosTaskGetCurrent() (NOSTASK_t)posTaskGetCurrent()
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_TASKUNUSED != 0)
/**
* Task function.
* Tests if a task is yet in use by the operating system.
* This function can be used to test if a task has been
* fully terminated (and the stack memory is no more in use).
* @param taskhandle handle to the task.
* @return 1 (=true) when the task is unused. If the task
* is still in use, zero is returned.
* A negative value is returned on error.
* @note ::POSCFG_FEATURE_TASKUNUSED must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskCreate, nosTaskExit
*/
#if DOX
NANOEXT VAR_t nosTaskUnused(NOSTASK_t taskhandle);
#else
#define nosTaskUnused(th) posTaskUnused((POSTASK_t)(th))
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_SETPRIORITY != 0)
/**
* Task function.
* Change the priority of a task. Note that in a non-roundrobin
* scheduling environment every priority level can only exist once.
* @param taskhandle handle to the task.
* @param priority new priority. Must be in the range
* 0 .. ::POSCFG_MAX_PRIO_LEVEL - 1.
* The higher the number, the higher the priority.
* @return zero on success.
* @note ::POSCFG_FEATURE_SETPRIORITY must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskGetPriority, nosTaskGetCurrent, nosTaskCreate
*/
#if DOX
NANOEXT VAR_t nosTaskSetPriority(NOSTASK_t taskhandle, VAR_t priority);
#else
#define nosTaskSetPriority(th, prio) posTaskSetPriority((POSTASK_t)(th),prio)
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_GETPRIORITY != 0)
/**
* Task function.
* Get the priority of a task.
* @param taskhandle handle to the task.
* @return the priority of the task. A negative value is returned on error.
* @note ::POSCFG_FEATURE_GETPRIORITY must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskSetPriority, nosTaskGetCurrent, nosTaskCreate
*/
#if DOX
NANOEXT VAR_t nosTaskGetPriority(NOSTASK_t taskhandle);
#else
#define nosTaskGetPriority(th) posTaskGetPriority((POSTASK_t)(th))
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_INHIBITSCHED != 0)
/**
* Task function.
* Locks the scheduler. When this function is called, no task switches
* will be done any more, until the counterpart function ::nosTaskSchedUnlock
* is called. This function is usefull for short critical sections that
* require exclusive access to variables. Note that interrupts still
* remain enabled.
* @note ::POSCFG_FEATURE_INHIBITSCHED must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskSchedUnlock
*/
#if DOX
NANOEXT void nosTaskSchedLock(void);
#else
#define nosTaskSchedLock() posTaskSchedLock()
#endif
/**
* Task function.
* Unlocks the scheduler. This function is called to leave a critical section.
* If a context switch request is pending, the context switch will happen
* directly after calling this function.
* @note ::POSCFG_FEATURE_INHIBITSCHED must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosTaskSchedLock
*/
#if DOX
NANOEXT void nosTaskSchedUnlock(void);
#else
#define nosTaskSchedUnlock() posTaskSchedUnlock()
#endif
#endif
#if (DOX!=0) || (POSCFG_TASKCB_USERSPACE > 0)
/**
* Task function.
* Returns a pointer to the user memory in the current task control block.
* @note ::POSCFG_TASKCB_USERSPACE must be defined to a nonzero value
* to have this function compiled in. ::POSCFG_TASKCB_USERSPACE
* is also used to set the size of the user memory (in bytes).@n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @return pointer to user memory space.
*/
#if DOX
NANOEXT void* nosTaskGetUserspace(void);
#else
#define nosTaskGetUserspace() posTaskGetUserspace()
#endif
#endif
#if (DOX!=0) || (POSCFG_FEATURE_IDLETASKHOOK != 0)
/** Idle task function pointer */
typedef POSIDLEFUNC_t NOSIDLEFUNC_t;
/**
* Task function.
* Install or remove an optional idle task hook function.
* The hook function is called every time the system is idle.
* It is possible to use this hook to implement your own idle task;
* in this case the function does not need to return to the system.
* You may insert a call to ::nosTaskYield into your idle task loop
* to get a better task performance.
* @param idlefunc function pointer to the new idle task handler.
* If this parameter is set to NULL, the idle
* task function hook is removed again.
* @return This function may return a pointer to the last hook
* function set. If so (pointer is not NULL), the previous
* hook function should be called from within your
* idle task hook. This enables chaining of hook functions.
* @note ::POSCFG_FEATURE_IDLETASKHOOK must be defined to 1
* to have this function compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
*/
#if DOX
NANOEXT NOSIDLEFUNC_t nosInstallIdleTaskHook(NOSIDLEFUNC_t idlefunc);
#else
#define nosInstallIdleTaskHook(ifunc) posInstallIdleTaskHook(ifunc)
#endif
#endif
#endif
/** @} */
/** @defgroup nanosema Semaphore Functions
* @ingroup absfunc
* For detailed information about using semaphores please see
* <a href="group__sema.html#_details">detailed description of semaphores</a>
* @{
*/
#if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
/** Handle to a nano layer semaphore object. */
typedef POSSEMA_t NOSSEMA_t;
/**
* Semaphore function.
* Allocates a new semaphore object.
* @param initcount Initial semaphore count (see detailed semaphore
* description in pico laye documentation).
* @param options Currently unused. Please set this parameter to 0 (zero).
* @param name Name of the new semaphore object to create. If the last
* character in the name is an asteriks (*), the operating
* system automatically assigns the semaphore a unique
* name (the registry feature must be enabled for this
* automatism). This parameter can be NULL if the nano
* layer registry feature is not used and will not be
* used in future.
* @return the pointer to the new semaphore object. NULL is returned on error.
* @note ::NOSCFG_FEATURE_SEMAPHORES must be defined to 1
* to have semaphore support compiled in. @n
* You must use ::nosSemaDestroy to destroy the semaphore again.@n
* Even if the function posSemaDestroy would work also, it is
* required to call ::nosSemaDestroy. Only this function removes
* the semaphore from the registry. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosSemaDestroy, nosSemaGet, nosSemaWait, nosSemaSignal
*/
#if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
NANOEXT NOSSEMA_t nosSemaCreate(INT_t initcount, UVAR_t options,
const char *name);
#else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -