📄 pos_nano.h
字号:
#define nosSemaCreate(i, o, n) (NOSSEMA_t) posSemaCreate(i);
#endif
#if DOX!=0 || POSCFG_FEATURE_SEMADESTROY != 0
/**
* Semaphore function.
* Frees a no more needed semaphore object.
* @param sema handle to the semaphore object.
* @note ::NOSCFG_FEATURE_SEMAPHORES must be defined to 1
* to have semaphore support compiled in.@n
* ::POSCFG_FEATURE_SEMADESTROY 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 nosSemaCreate
*/
#if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
NANOEXT void nosSemaDestroy(NOSSEMA_t sema);
#else
#define nosSemaDestroy(sema) posSemaDestroy((POSSEMA_t)(sema))
#endif
#endif
#if DOX
/**
* Semaphore function.
* This function signalizes a semaphore object, that means it increments
* the semaphore counter and sets tasks pending on the semaphore to
* running state, when the counter reaches a positive, nonzero value.
* @param sema handle to the semaphore object.
* @return zero on success.
* @note ::NOSCFG_FEATURE_SEMAPHORES must be defined to 1
* to have semaphore support compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosSemaGet, nosSemaWait, nosSemaCreate
*/
NANOEXT VAR_t nosSemaSignal(NOSSEMA_t sema);
#else
#define nosSemaSignal(sem) posSemaSignal((POSSEMA_t)(sem))
#endif
#if DOX
/**
* Semaphore function.
* This function tries to get the semaphore object. If the semaphore
* is in nonsignalized state (that means its counter is zero or less),
* this function blocks the task execution until the semaphore
* gets signaled.
* @param sema handle to the semaphore object.
* @return zero on success.
* @note ::NOSCFG_FEATURE_SEMAPHORES must be defined to 1
* to have semaphore support compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosSemaWait, nosSemaSignal, nosSemaCreate
*/
NANOEXT VAR_t nosSemaGet(NOSSEMA_t sema);
#else
#define nosSemaGet(sem) posSemaGet((POSSEMA_t)(sem))
#endif
#if DOX
/**
* Semaphore function.
* This function tries to get the semaphore object. If the semaphore
* is in nonsignalized state (that means its counter is zero or less),
* this function blocks the task execution until the semaphore
* gets signaled or a timeout happens.
* @param sema handle to the semaphore object.
* @param timeoutticks timeout in timer ticks
* (see ::HZ define and ::MS macro).
* If this parameter is set to zero, the function immediately
* returns. If this parameter is set to INFINITE, the
* function will never time out.
* @return zero on success. A positive value (1 or TRUE) is returned
* when the timeout was reached.
* @note ::NOSCFG_FEATURE_SEMAPHORES must be defined to 1
* to have semaphore support compiled in.@n
* ::POSCFG_FEATURE_SEMAWAIT 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 nosSemaGet, nosSemaSignal, nosSemaCreate, HZ, MS
*/
NANOEXT VAR_t nosSemaWait(NOSSEMA_t sema, UINT_t timeoutticks);
#else
#if POSCFG_FEATURE_SEMAWAIT
#define nosSemaWait(sem, to) posSemaWait((POSSEMA_t)(sem), to)
#endif
#endif
#endif /* POSCFG_FEATURE_SEMAPHORES */
/** @} */
/** @defgroup nanomutex Mutex Functions
* @ingroup absfunc
* For detailed information about using mutexes please see
* <a href="group__mutex.html#_details">detailed description of mutexes</a>
* @{
*/
#if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
/** Handle to a nano layer semaphore object. */
typedef POSMUTEX_t NOSMUTEX_t;
/**
* Mutex function.
* Allocates a new mutex object.
* @param options Currently unused. Please set this parameter to 0 (zero).
* @param name Name of the new mutex object to create. If the last
* character in the name is an asteriks (*), the operating
* system automatically assigns the mutex 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 mutex object. NULL is returned on error.
* @note ::NOSCFG_FEATURE_MUTEXES must be defined to 1
* to have mutex support compiled in. @n
* Even if the function posMutexDestroy would work also, it is
* required to call ::nosMutexDestroy. Only this function removes
* the mutex from the registry. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosMutexDestroy, nosMutexLock, nosMutexTryLock, nosMutexUnlock
*/
#if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
NANOEXT NOSMUTEX_t nosMutexCreate(UVAR_t options, const char *name);
#else
#define nosMutexCreate(opt, name) (NOSMUTEX_t) posMutexCreate()
#endif
#if DOX!=0 || POSCFG_FEATURE_MUTEXDESTROY != 0
/**
* Mutex function.
* Frees a no more needed mutex object.
* @param mutex handle to the mutex object.
* @note ::NOSCFG_FEATURE_MUTEXES must be defined to 1
* to have mutex support compiled in.@n
* ::POSCFG_FEATURE_MUTEXDESTROY 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 nosMutexCreate
*/
#if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
NANOEXT void nosMutexDestroy(NOSMUTEX_t mutex);
#else
#define nosMutexDestroy(mutex) posMutexDestroy((POSMUTEX_t)(mutex))
#endif
#endif
#if DOX!=0 || POSCFG_FEATURE_MUTEXTRYLOCK != 0
/**
* Mutex function.
* Tries to get the mutex lock. This function does not block when the
* mutex is not available, instead it returns a value showing that
* the mutex could not be locked.
* @param mutex handle to the mutex object.
* @return zero when the mutex lock could be set. Otherwise, when
* the mutex lock is yet helt by an other task, the function
* returns 1. A negative value is returned on error.
* @note ::NOSCFG_FEATURE_MUTEXES must be defined to 1
* to have mutex support compiled in.@n
* ::POSCFG_FEATURE_MUTEXTRYLOCK 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 nosMutexLock, nosMutexUnlock, nosMutexCreate
*/
#if DOX
NANOEXT VAR_t nosMutexTryLock(NOSMUTEX_t mutex);
#else
#define nosMutexTryLock(mutex) posMutexTryLock((POSMUTEX_t)(mutex))
#endif
#endif
/**
* Mutex function.
* This function locks a code section so that only one task can execute
* the code at a time. If an other task already has the lock, the task
* requesting the lock will be blocked until the mutex is unlocked again.
* Note that a ::nosMutexLock appears always in a pair with ::nosMutexUnlock.
* @param mutex handle to the mutex object.
* @return zero on success.
* @note ::NOSCFG_FEATURE_MUTEXES must be defined to 1
* to have mutex support compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosMutexTryLock, nosMutexUnlock, nosMutexCreate
*/
#if DOX
NANOEXT VAR_t nosMutexLock(NOSMUTEX_t mutex);
#else
#define nosMutexLock(mutex) posMutexLock((POSMUTEX_t)(mutex))
#endif
/**
* Mutex function.
* This function unlocks a section of code so that other tasks
* are able to execute it.
* @param mutex handle to the mutex object.
* @return zero on success.
* @note ::NOSCFG_FEATURE_MUTEXES must be defined to 1
* to have mutex support compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosMutexLock, nosMutexTryLock, nosMutexCreate
*/
#if DOX
NANOEXT VAR_t nosMutexUnlock(NOSMUTEX_t mutex);
#else
#define nosMutexUnlock(mutex) posMutexUnlock((POSMUTEX_t)(mutex))
#endif
#endif /* NOSCFG_FEATURE_MUTEXES */
/** @} */
/** @defgroup nanomsg Message Box Functions
* @ingroup absfunc
* For detailed information about using message boxes please see
* <a href="group__msg.html#_details">detailed description of message boxes</a>
* @{
*/
#if DOX!=0 || NOSCFG_FEATURE_MSGBOXES != 0
/**
* Message box function.
* Allocates a new message buffer. To increase the execution speed,
* it is recommended to set ::POSCFG_MSG_MEMORY to 1. Otherwise,
* ::nosMessageAlloc will need to call ::nosMemAlloc to allocate memory
* (and this is possibly slower than the pico]OS internal message allocator).
* @n Usually the sending task would allocate a new message buffer, fill
* in its data and send it via ::nosMessageSend to the receiving task.
* The receiving task is responsible for freeing the message buffer again.
* @param msgSize size of the requested message buffer in bytes.
* @return the pointer to the new buffer. NULL is returned if the
* system is low on memory or the requested msgSize is larger
* than ::POSCFG_MSG_BUFSIZE (only if ::POSCFG_MSG_MEMORY is
* set to 1).
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in.@n
* If ::POSCFG_MSG_MEMORY is set to 0, you also need to
* enable the nano layer memory manager by setting
* ::NOSCFG_FEATURE_MEMALLOC to 1.
* @sa nosMessageSend, nosMessageGet, nosMessageFree
*/
NANOEXT void* nosMessageAlloc(UINT_t msgSize);
/**
* Message box function. Frees a message buffer again.
* Usually the receiving task would call this function after
* it has processed a message to free the message buffer again.
* @param buf Pointer to the message buffer that is no more used.
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in.
* @sa nosMessageGet, nosMessageSend, nosMessageAlloc
*/
NANOEXT void nosMessageFree(void *buf);
/**
* Message box function. Sends a message to a task.
* @param buf Pointer to the message to send.
* The message buffer must have been allocated by
* calling ::nosMessageAlloc before.
* @param taskhandle handle to the task to send the message to.
* @return zero on success. When an error condition exist, a
* negative value is returned and the message buffer is freed.
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in.
* @sa nosMessageAlloc, nosMessageGet
*/
NANOEXT VAR_t nosMessageSend(void *buf, NOSTASK_t taskhandle);
/**
* Message box function. Gets a new message from the message box.
* If no message is available, the task blocks until a new message
* is received.
* @return Pointer to the received message. Note that the
* message memory must be freed again with ::nosMessageFree
* when the message buffer is no more used.
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in. @n
* Dependent of your configuration, this function can
* be defined as macro to decrease code size.
* @sa nosMessageFree, nosMessageAvailable,
* nosMessageWait, nosMessageSend
*/
#if DOX
NANOEXT void* nosMessageGet(void);
#else
#define nosMessageGet() posMessageGet()
#endif
#if DOX!=0 || POSCFG_FEATURE_MSGWAIT != 0
/**
* Message box function.
* Gets a new message from the message box.
* If no message is available, the task blocks until a new message
* is received or the timeout has been reached.
* @param timeoutticks timeout in timer ticks
* (see ::HZ define and ::MS macro).
* If this parameter is set to zero, the function immediately
* returns. If this parameter is set to INFINITE, the
* function will never time out.
* @return Pointer to the received message. Note that the
* message memory must be freed again with ::nosMessageFree
* when the message buffer is no more used.
* NULL is returned when no message was received
* within the specified time (=timeout).
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in.@n
* ::POSCFG_FEATURE_MSGWAIT 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 nosMessageFree, nosMessageGet, nosMessageAvailable,
* nosMessageSend, HZ, MS
*/
#if DOX
NANOEXT void* nosMessageWait(UINT_t timeoutticks);
#else
#define nosMessageWait(to) posMessageWait(to)
#endif
#endif
/**
* Message box function.
* Tests if a new message is available
* in the message box. This function can be used to prevent
* the task from blocking.
* @return 1 (=true) when a new message is available.
* Otherwise zero is returned. A negative value
* is returned on error.
* @note ::NOSCFG_FEATURE_MSGBOXES must be defined to 1
* to have message box support compiled in. @n
* Dependent of your configuration, th
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -