NetBurner 3.5.0
PDF Version
 
NBRTOS Real Time Operating System

Topics

 NBRTOS Error Codes
 
 NBRTOS Task Status
 

Classes

class  TickTimeout
 TickTimeout objects are used to facilitate sequential function calls with timeout parameters that need to indexed from an initial start time, and to prevent TimeTick rollover errors. More...
 
struct  OS_SEM
 Semaphores are used to control access to shared resources or or to communicate between tasks in a multithreaded system or with interrupt service routines. Semaphores can be 0 or 1, or they can be counting semaphores that increment and decreement based on calls to Pend() and Post() functions. More...
 
struct  OS_MBOX
 Mailboxes single value storage locations used to communicate between tasks. More...
 
struct  OS_Q
 A message queue is an object that enables tasks and interrupt service routines to pend and post pointer sized messages. The pointer values typically point to some type of object or structure that contains the actual message or data. A queue functions as a fixed size First In First Out (FIFO) storage for 32-bit void pointers that can be used for communication between tasks. More...
 
struct  os_fifo_el
 OS_FIFO element definition. More...
 
struct  OS_FIFO
 
struct  OS_CRIT
 An OS_CRIT object is used to establish critical sections of code that can only be run by one task at a time. Tasks that try to claim a critical section which is currently claimed by another task will stop and wait for that task to release the critical section before continuing execution. More...
 
struct  OS_FLAGS
 OSFlags enables a function or task to pend on multiple flags or events. More...
 
class  OSLockObj
 A simple wrapper class that helps use OS locks effectively. More...
 
class  OSCriticalSectionObj
 A simple wrapper class that helps utilize OS_CRIT objects more effectively. More...
 
class  OSLockAndCritObj
 A simple wrapper class that helps utilize OS_CRIT objects to lock tasks and enter critical sections more effectively. More...
 
class  OSSpinCrit
 A simple wrapper class that uses an OS_CRIT object to try and claim a critical section, and will continue the attempt until it is able to do so. More...
 
class  USERCritObj
 User critial section object class. More...
 
class  NBRtosInitObj
 A simple class to derive from if you are creating tasks that are constructed at global scope and need to do RTOS initalization. More...
 

Macros

#define WAIT_FOREVER   0
 Parameter macro used for timeout parameters that have a 0 value and wait forever.
 
#define OSSimpleTaskCreatewName(x, p, n)
 Simpler form of creating a new task. Will automatically allocate the default task stack size.
 
#define OSSimpleTaskCreatewNameSRAM(x, p, n)
 
#define OSSimpleTaskCreateLambda(p, n, f)   LambdaTask2(p,n,[]( void * pv)f,__COUNTER__)
 This macro functions the same as OSTaskCreatewName().
 

Typedefs

typedef struct os_fifo_el OS_FIFO_EL
 OS_FIFO element definition.
 

Functions

void OSFlagSet (OS_FLAGS *flags, uint32_t bits_to_set)
 This function sets the corresponding bits asserted in bits_to_set of an OS_FLAGS object pointed to by *flags.
 
void OSFlagClear (OS_FLAGS *flags, uint32_t bits_to_clr)
 This function clears the bits asserted in bits_to_clr of an OS_FLAGS object pointed to by *flags..
 
uint8_t OSFlagPendAny (OS_FLAGS *flags, uint32_t bit_mask, uint16_t timeout)
 This function waits a number of time ticks specified by timeout until any of the flags indicated by bit_mask are set.
 
uint8_t OSFlagPendAnyNoWait (OS_FLAGS *flags, uint32_t bit_mask)
 This function immediately checks to see if any of the flag bits indicated by bit_mask are set; it does not wait.
 
uint8_t OSFlagPendAll (OS_FLAGS *flags, uint32_t bit_mask, uint16_t timeout)
 This function waits a number of time ticks specified by timeout until all the flags indicated by bit_mask are set.
 
uint8_t OSFlagPendAllNoWait (OS_FLAGS *flags, uint32_t bit_mask)
 This function immediately checks to see if all the flag bits indicated by bit_mask are set; it does not wait.
 
uint32_t OSFlagState (OS_FLAGS *flags)
 This function returns the current values of the flags stored in the OS_FLAGS object structure.
 
uint8_t OSTaskCreatewName (void(*task)(void *dptr), void *data, void *pstktop, void *pstkbot, uint8_t prio, const char *name)
 Create a new task.
 
void OSTimeWaitUntil (uint32_t systemTickValue)
 Delay the task until the specified value of the system timer tick. The number of system ticks per second is defined by the constant: TICKS_PER_SECOND in <nburn_install>/nbrtos/include/constants.h. The default value is 20 ticks per second.
 
void OSTimeDly (uint32_t to_count)
 Delay the task until the specified value of the system timer ticks. The number of system ticks per second is defined by the constant: TICKS_PER_SECOND in <nburn_install>/nbrtos/include/constants.h. The default value is 20 ticks per second.
 
void OSTaskDelete (void)
 This function deletes the current calling task, but we do not recommend the use of this function because it can cause memory leaks.
 
uint8_t OSChangePrio (uint32_t newp)
 Set the priority of the calling task.
 
void OSSetName (const char *cp)
 Set the name of the calling task.
 
void OSLock (void)
 Calling the OSLock function will prevent the OS from changing tasks.
 
void OSUnlock (void)
 This function unlocks the OS.
 
uint8_t OSSemInit (OS_SEM *psem, long value)
 Initializes a semaphore.
 
uint8_t OSSemPost (OS_SEM *psem)
 Increases the value of the semaphore by one. Note: If any higher priority tasks were waiting on the semaphore - it releases them.
 
uint8_t OSSemPend (OS_SEM *psem, uint16_t timeout)
 Wait timeout ticks for the value of the semaphore to be non zero. Note: A timeout value of 0 (zero) waits forever.
 
uint8_t OSSemPendNoWait (OS_SEM *psem)
 OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.
 
uint8_t OSMboxInit (OS_MBOX *pmbox, void *msg)
 This function is used to initialize an OS_MBOX structure.
 
uint8_t OSMboxPost (OS_MBOX *pmbox, void *msg)
 This function posts a message to a Mail box.
 
void * OSMboxPend (OS_MBOX *pmbox, uint16_t timeout, uint8_t *err)
 Wait timeout ticks for some other task to post to the Mailbox.
 
void * OSMboxPendNoWait (OS_MBOX *pmbox, uint8_t *err)
 OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.
 
uint8_t OSQInit (OS_Q *pq, void **start, uint8_t size)
 A queue functions as a fixed size FIFO for communication between tasks. This function initializes an OS_Q structure.
 
uint8_t OSQPost (OS_Q *pq, void *msg)
 This function posts a message to a Queue.
 
uint8_t OSQPostFirst (OS_Q *pq, void *msg)
 This function posts a message like OSQPost, but posts the message at the head of the queue.
 
uint8_t OSQPostUnique (OS_Q *pq, void *msg)
 This function posts a message like OSQPost, but only if the message isn't already in the queue The function performs a brute force check to see if the message is already in the queue.
 
uint8_t OSQPostUniqueFirst (OS_Q *pq, void *msg)
 This function posts a message like OSQPostFirst, but only if the message isn't already in the queue The function performs a brute force check to see if the message is already in the queue.
 
void * OSQPend (OS_Q *pq, uint16_t timeout, uint8_t *err)
 Wait timeout ticks for another task to post to the queue.
 
void * OSQPendNoWait (OS_Q *pq, uint8_t *err)
 OSQPendNoWait() is identical to the OSQPend() function but it does not wait.
 
uint8_t OSFifoInit (OS_FIFO *pFifo)
 Initialize a FIFO, which is used to pass structures from one task to another.
 
uint8_t OSFifoPost (OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
 This function posts to a FIFO.
 
uint8_t OSFifoPostFirst (OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
 This function is identical to OSFifoPost(), but the element posted is put at the beginning of the FIFO list.
 
OS_FIFO_ELOSFifoPend (OS_FIFO *pFifo, uint16_t timeout)
 This function pends on a FIFO.
 
OS_FIFO_ELOSFifoPendNoWait (OS_FIFO *pFifo)
 This function is identical to the OSFifoPen() function, but it does not wait.
 
uint8_t OSCritInit (OS_CRIT *pCrit)
 This function initializes the critical section.
 
uint8_t OSCritEnter (OS_CRIT *pCrit, uint16_t timeout)
 This function tries to enter or claim the critical section.
 
uint8_t OSCritEnterNoWait (OS_CRIT *pCrit)
 This function tries to enter or claim the critical section.
 
uint8_t OSCritLeave (OS_CRIT *pCrit)
 This function releases the critical section.
 
uint8_t OSTaskID (void)
 Returns the current task's priority.
 
const char * OSTaskName ()
 Returns the current task's name.
 
void OSChangeTaskDly (uint16_t task_prio, uint32_t to_count)
 This function allows the User to modify the timeout delay for a task that is waiting.
 
void OSDumpStack (void)
 Dump the task stack to the stdout.
 
void OSDumpTCBStacks (void)
 This function dumps information about the UCOS stacks and tasks to stdout. This function is useful for debugging.
 
void OSDumpTasks (void)
 Dump the state and call stack for every task to stdout. This function is useful for debugging.
 
void OSStartTaskDumper (uint8_t prio, uint32_t reportInterval)
 This function creates a task that calls OSDumpTasks() at the specified system time tick interval. The task is intended for use when debugging run status of multiple tasks.
 
void ShowTaskList (void)
 This functions dumps the current RTOS task states to stdio.
 
bool OS_CRIT::OwnedByCurTask ()
 Check if critical section owned by the current task.
 

Detailed Description

#include< nbrtos.h >

The NetBurner Real-Time OS

Macro Definition Documentation

◆ OSSimpleTaskCreateLambda

#define OSSimpleTaskCreateLambda ( p,
n,
f )   LambdaTask2(p,n,[]( void * pv)f,__COUNTER__)

#include <nbrtos.h>

This macro functions the same as OSTaskCreatewName().

Parameters
pThe priority for this new task (OS_MAX_PRIOS is lowest priority and 1 is highest). Look in <nburn_install>/nbrtos/include/constants.h to see which priorities are used by the OS.
nThe optional name of the task.
fThe function to run as the task.

Example:

OSSimpleTaskCreateLambda(MAIN_PRIO-1,"MyLambdaTask",{ Code to run goes here });
#define MAIN_PRIO
Recommend UserMain priority.
Definition nbrtos/include/constants.h:97
#define OSSimpleTaskCreateLambda(p, n, f)
This macro functions the same as OSTaskCreatewName().
Definition nbrtos.h:1683
See also
OSTaskCreatewName(), OSSimpleTaskCreatewName()

◆ OSSimpleTaskCreatewName

#define OSSimpleTaskCreatewName ( x,
p,
n )

#include <nbrtos.h>

Value:
{ \
static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))); \
OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
}
#define USER_TASK_STK_SIZE
Definition nbrtos/include/constants.h:131

Simpler form of creating a new task. Will automatically allocate the default task stack size.

Parameters
xThe address of the function where this task will start executing.
pThe priority for this new task (OS_MAX_PRIOS is lowest priority and 1 is highest). Look in <nburn_install>/nbrtos/include/constants.h to see which priorities are used by the OS.
nThe optional name of the task.
See also
OSTaskCreatewName(), OSTaskDelete(), OSChangePrio()

◆ OSSimpleTaskCreatewNameSRAM

#define OSSimpleTaskCreatewNameSRAM ( x,
p,
n )

#include <nbrtos.h>

Value:
{ \
static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))) FAST_USER_STK; \
OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
}
uint8_t OSTaskCreatewName(void(*task)(void *dptr), void *data, void *pstktop, void *pstkbot, uint8_t prio, const char *name)
Create a new task.
#define FAST_USER_STK
Definition nbrtos/include/constants.h:297

Typedef Documentation

◆ OS_FIFO_EL

typedef struct os_fifo_el OS_FIFO_EL

#include <nbrtos.h>

OS_FIFO element definition.

This struture is a union of a pointer to the next OS_FIFO and a byte pointer to the same data.

Function Documentation

◆ OSChangePrio()

uint8_t OSChangePrio ( uint32_t newp)

#include <nbrtos.h>

Set the priority of the calling task.

Note
There can only be one task at each priority level. Task priorities can range from 1 to OS_MAX_PRIOS, where OS_MAX_PRIOS is the lowest priority level and 1 is highest priority level. Priorities 1-4 and the NetBurner system priority levels are reserved as described below. The recommended user priority levels for your application are in the range of 46 to OS_MAX_PRIOS-1. This avoids any conflicts with network communications.

System priorities are defined in <nburn_install>/nbrtos/include/constants.h for all platforms.

Parameters
newpThe new priority of the calling task
Return values
OS_NO_ERRIf successful
OS_PRIO_EXISTIf the requested priority already exists
See also
NBRTOS Error Codes, OSTaskCreatewName()

◆ OSChangeTaskDly()

void OSChangeTaskDly ( uint16_t task_prio,
uint32_t to_count )
inline

#include <nbrtos.h>

This function allows the User to modify the timeout delay for a task that is waiting.

Warning
Use of this function is discouraged.
Parameters
task_prioThe task's priority
to_countThe new number of ticks to delay
See also
OSTimeDly()

◆ OSCritEnter()

uint8_t OSCritEnter ( OS_CRIT * pCrit,
uint16_t timeout )
inline

#include <nbrtos.h>

This function tries to enter or claim the critical section.

Parameters
pCritA pointer to the critical section.
timeoutHow many time ticks do we want to wait for this critical section? Note: A timeout of 0 (zero) waits forever.
Returns
OS_NO_ERR - If we were successful in claiming the critical section, or if our task owns it
OS_TIMEOUT - If we were unable to claim the section
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_CRIT for current usage.

◆ OSCritEnterNoWait()

uint8_t OSCritEnterNoWait ( OS_CRIT * pCrit)
inline

#include <nbrtos.h>

This function tries to enter or claim the critical section.

Parameters
pCritA pointer to the critical section.
Returns
OS_NO_ERR - If we were successful in claiming the critical section, or if our task owns it
OS_TIMEOUT - If we were unable to claim the section
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_CRIT for current usage.

◆ OSCritInit()

uint8_t OSCritInit ( OS_CRIT * pCrit)
inline

#include <nbrtos.h>

This function initializes the critical section.

Parameters
pCritA pointer to the critical section.
Returns
OS_NO_ERR - If successful
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_CRIT for current usage.

◆ OSCritLeave()

uint8_t OSCritLeave ( OS_CRIT * pCrit)
inline

#include <nbrtos.h>

This function releases the critical section.

Parameters
pCritA pointer to the critical section we want to leave/release.
Returns
OS_NO_ERR - If we were successful in releasing the critical section
OS_CRIT_ERR - If we are trying to release a critical section that we do not own
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_CRIT for current usage.

◆ OSDumpTasks()

void OSDumpTasks ( void )

#include <nbrtos.h>

Dump the state and call stack for every task to stdout. This function is useful for debugging.

Note
This function can only be called if NBRTOS_STACKCHECK is defined in predef.h.
See also
OSDumpTCBStacks()

◆ OSDumpTCBStacks()

void OSDumpTCBStacks ( void )

#include <nbrtos.h>

This function dumps information about the UCOS stacks and tasks to stdout. This function is useful for debugging.

Note
This function can only be called if NBRTOS_STACKCHECK is defined in predef.h.
See also
OSDumpTasks()

◆ OSFifoInit()

uint8_t OSFifoInit ( OS_FIFO * pFifo)
inline

#include <nbrtos.h>

Initialize a FIFO, which is used to pass structures from one task to another.

Parameters
pFifoA pointer to an OS_FIFO structure.
Returns
OS_NO_ERR - If successful
OS_CRIT_ERR - If pFifo is NULL
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_FIFO for current usage.

◆ OSFifoPend()

OS_FIFO_EL * OSFifoPend ( OS_FIFO * pFifo,
uint16_t timeout )
inline

#include <nbrtos.h>

This function pends on a FIFO.

Parameters
pFifoA pointer to an OS_FIFO structure.
timeoutThe number of ticks to wait on the FIFO.
Returns
A pointer to the posted structure if successful, or NULL if it timed out.
Deprecated
This function is now deprecated. Please see OS_FIFO for current usage.

◆ OSFifoPendNoWait()

OS_FIFO_EL * OSFifoPendNoWait ( OS_FIFO * pFifo)
inline

#include <nbrtos.h>

This function is identical to the OSFifoPen() function, but it does not wait.

Parameters
pFifoA pointer to an OS_FIFO structure.
Returns
A pointer to the posted structure if successful, or NULL if it timed out.

◆ OSFifoPost()

uint8_t OSFifoPost ( OS_FIFO * pFifo,
OS_FIFO_EL * pToPost )
inline

#include <nbrtos.h>

This function posts to a FIFO.

Parameters
pFifoA pointer to an OS_FIFO structure.
pToPostA pointer to the user's structure cast as an OS_FIFO_EL to be posted to the FIFO.
Returns
OS_NO_ERR - If successful
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_FIFO for current usage.

◆ OSFifoPostFirst()

uint8_t OSFifoPostFirst ( OS_FIFO * pFifo,
OS_FIFO_EL * pToPost )
inline

#include <nbrtos.h>

This function is identical to OSFifoPost(), but the element posted is put at the beginning of the FIFO list.

Parameters
pFifoA pointer to an OS_FIFO structure.
pToPostA pointer to the user's structure cast as an OS_FIFO_EL to be posted to the FIFO.
Returns
OS_NO_ERR - If successful
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_FIFO for current usage.

◆ OSFlagClear()

void OSFlagClear ( OS_FLAGS * flags,
uint32_t bits_to_clr )
inline

#include <nbrtos.h>

This function clears the bits asserted in bits_to_clr of an OS_FLAGS object pointed to by *flags..

Parameters
flagsA pointer to the OS_FLAGS object to be configured.
bits_to_clrA bit or set of bits to be cleared.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagPendAll()

uint8_t OSFlagPendAll ( OS_FLAGS * flags,
uint32_t bit_mask,
uint16_t timeout )
inline

#include <nbrtos.h>

This function waits a number of time ticks specified by timeout until all the flags indicated by bit_mask are set.

Parameters
flagsA pointer to the OS_FLAGS object with the desired flag bits.
bit_maskA bit or set of bits to wait on.
timeoutNumber of time ticks to wait for all specified flag bits to be set.
Return values
OS_NO_ERRIf the flags condition is satisfied
OS_TIMEOUTIf the timeout expired
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagPendAllNoWait()

uint8_t OSFlagPendAllNoWait ( OS_FLAGS * flags,
uint32_t bit_mask )
inline

#include <nbrtos.h>

This function immediately checks to see if all the flag bits indicated by bit_mask are set; it does not wait.

Parameters
flagsA pointer to the OS_FLAGS object with the desired flag bits.
bit_maskA bit or set of bits to wait on.
Return values
OS_NO_ERRAll flags indicated by bit_mask are set.
OS_TIMEOUTNot all of the flags indicated by bit_mask are set.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagPendAny()

uint8_t OSFlagPendAny ( OS_FLAGS * flags,
uint32_t bit_mask,
uint16_t timeout )
inline

#include <nbrtos.h>

This function waits a number of time ticks specified by timeout until any of the flags indicated by bit_mask are set.

Parameters
flagsA pointer to the OS_FLAGS object with the desired flag bits.
bit_maskA bit or set of bits to wait on.
timeoutNumber of time ticks to wait for all specified flag bits to be set.
Return values
OS_NO_ERRAt least one of the flag bits are set before timeout expires.
OS_TIMEOUTNone of the flag bits are set before timeout expires.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagPendAnyNoWait()

uint8_t OSFlagPendAnyNoWait ( OS_FLAGS * flags,
uint32_t bit_mask )
inline

#include <nbrtos.h>

This function immediately checks to see if any of the flag bits indicated by bit_mask are set; it does not wait.

Parameters
flagsA pointer to the OS_FLAGS object with the desired flag bits.
bit_maskA bit or set of bits to wait on.
Return values
OS_NO_ERRAt least one of the flags indicated by bit_mask are set.
OS_TIMEOUTNone of the flags indicated by bit_mask are set.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagSet()

void OSFlagSet ( OS_FLAGS * flags,
uint32_t bits_to_set )
inline

#include <nbrtos.h>

This function sets the corresponding bits asserted in bits_to_set of an OS_FLAGS object pointed to by *flags.

Parameters
flagsA pointer to the OS_FLAGS object to be configured.
bits_to_setA bit or set of bits to be set.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSFlagState()

uint32_t OSFlagState ( OS_FLAGS * flags)
inline

#include <nbrtos.h>

This function returns the current values of the flags stored in the OS_FLAGS object structure.

Parameters
flagsA pointer to the OS_FLAGS object whose flag states are to be returned.
Returns
The state of the OS_FLAGS object.
Deprecated
This function is now deprecated. Please see OS_FLAGS for current usage.

◆ OSLock()

void OSLock ( void )

#include <nbrtos.h>

Calling the OSLock function will prevent the OS from changing tasks.

This is used to protect critical variables that must be accessed one task at a time. Use the OSUnlock function to release your lock. Important: You must call OSUnlock() once for each call to OSLock.

Warning: Do not keep a task locked for a long period of time, or the performance of the network subsystem will degrade, and eventually loose packets. For example, use of I/O is not recommended inside an OSLock protected block.

See also
OSUnlock(), OSLockObj()

◆ OSMboxInit()

uint8_t OSMboxInit ( OS_MBOX * pmbox,
void * msg )
inline

#include <nbrtos.h>

This function is used to initialize an OS_MBOX structure.

Parameters
pmboxA pointer to the OS_MBOX structure to initialize.
msgThe initial mail box message (NULL) for none.
Returns
OS_NO_ERR - If successful
OS_CRIT_ERR - If pmbox is NULL
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_MBOX for current usage.

◆ OSMboxPend()

void * OSMboxPend ( OS_MBOX * pmbox,
uint16_t timeout,
uint8_t * err )
inline

#include <nbrtos.h>

Wait timeout ticks for some other task to post to the Mailbox.

Parameters
pmboxA pointer to the OS_MBOX structure.
timeoutThe number of time ticks to wait.
[out]errA variable to receive the result code (OS_NO_ERR if successful or OS_TIMEOUT if it fails).
Returns
The posted message if successful, or NULL if timed out.
Deprecated
This function is now deprecated. Please see OS_MBOX for current usage.

◆ OSMboxPendNoWait()

void * OSMboxPendNoWait ( OS_MBOX * pmbox,
uint8_t * err )
inline

#include <nbrtos.h>

OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.

Parameters
pmboxA pointer to the OS_MBOX structure.
errA variable to receive the result code (OS_NO_ERR if successful or OS_TIMEOUT if it fails).
Returns
The posted message if successful, or NULL if it fails.
Deprecated
This function is now deprecated. Please see OS_MBOX for current usage.

◆ OSMboxPost()

uint8_t OSMboxPost ( OS_MBOX * pmbox,
void * msg )
inline

#include <nbrtos.h>

This function posts a message to a Mail box.

Parameters
pmboxA pointer to the OS_MBOX structure.
msgThe message to post.
Returns
OS_NO_ERR - If successful
OS_MBOX_FULL - If the mailbox is full
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_MBOX for current usage.

◆ OSQInit()

uint8_t OSQInit ( OS_Q * pq,
void ** start,
uint8_t size )
inline

#include <nbrtos.h>

A queue functions as a fixed size FIFO for communication between tasks. This function initializes an OS_Q structure.

Parameters
pqA pointer to the OS_Q structure.
startA pointer to an array of (void *) pointers to hold queue messages.
sizeThe number of pointers in the Q data storage area.
Returns
OS_NO_ERR - If Successful
OS_CRIT_ERR - If start or pq is NULL
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPend()

void * OSQPend ( OS_Q * pq,
uint16_t timeout,
uint8_t * err )
inline

#include <nbrtos.h>

Wait timeout ticks for another task to post to the queue.

Parameters
pqA pointer to the OS_Q structure.
timeoutThe number of ticks to wait.
[out]errA variable to receive the result code, either OS_NO_ERR on receiving a posted message, or OS_TIMEOUT on a timeout.
Returns
The posted message, or NULL if the function failed
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPendNoWait()

void * OSQPendNoWait ( OS_Q * pq,
uint8_t * err )
inline

#include <nbrtos.h>

OSQPendNoWait() is identical to the OSQPend() function but it does not wait.

Parameters
pqA pointer to the OS_Q structure.
[out]errA variable to receive the result code, either OS_NO_ERR on receiving a posted message, or OS_TIMEOUT on a timeout.
Returns
The posted message, or NULL if the function failed
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPost()

uint8_t OSQPost ( OS_Q * pq,
void * msg )
inline

#include <nbrtos.h>

This function posts a message to a Queue.

Parameters
pqA pointer to the OS_Q structure.
msgThe message to be posted to the queue.
Returns
OS_NO_ERR - If Successful
OS_Q_FULL - If the queue is full and has no more room
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPostFirst()

uint8_t OSQPostFirst ( OS_Q * pq,
void * msg )
inline

#include <nbrtos.h>

This function posts a message like OSQPost, but posts the message at the head of the queue.

Parameters
pqA pointer to the OS_Q structure.
msgThe message to post at the head of the queue.
Returns
OS_NO_ERR - If Successful
OS_Q_FULL - If the queue is full and has no more room
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPostUnique()

uint8_t OSQPostUnique ( OS_Q * pq,
void * msg )
inline

#include <nbrtos.h>

This function posts a message like OSQPost, but only if the message isn't already in the queue The function performs a brute force check to see if the message is already in the queue.

Parameters
pqA pointer to the OS_Q structure.
msgThe message to post at the head of the queue.
Returns
OS_NO_ERR - If Successful
OS_Q_FULL - If the queue is full and has no more room
OS_Q_EXISTS - If the message already exists in the queue
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSQPostUniqueFirst()

uint8_t OSQPostUniqueFirst ( OS_Q * pq,
void * msg )
inline

#include <nbrtos.h>

This function posts a message like OSQPostFirst, but only if the message isn't already in the queue The function performs a brute force check to see if the message is already in the queue.

Parameters
pqA pointer to the OS_Q structure.
msgThe message to post at the head of the queue.
Returns
OS_NO_ERR - If Successful
OS_Q_FULL - If the queue is full and has no more room
OS_Q_EXISTS - If the message already exists in the queue
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_Q for current usage.

◆ OSSemInit()

uint8_t OSSemInit ( OS_SEM * psem,
long value )
inline

#include <nbrtos.h>

Initializes a semaphore.

Parameters
psemA pointer to the OS_SEM structure to initialize.
valueThe initial count value for the semaphore.
Returns
OS_NO_ERR - If successful
OS_SEM_ERR - If value is < 0 (zero), it cannot initialize
OS_CRIT_ERR - If psem is NULL
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_SEM for current usage.

◆ OSSemPend()

uint8_t OSSemPend ( OS_SEM * psem,
uint16_t timeout )
inline

#include <nbrtos.h>

Wait timeout ticks for the value of the semaphore to be non zero. Note: A timeout value of 0 (zero) waits forever.

Parameters
psemA pointer to the OS_SEM structure.
timeoutThe number of time ticks to wait
Returns
OS_NO_ERR - If successful
OS_TIMEOUT - If the function timed out or if the NoWait function failed
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_SEM for current usage.

◆ OSSemPendNoWait()

uint8_t OSSemPendNoWait ( OS_SEM * psem)
inline

#include <nbrtos.h>

OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.

Parameters
psemA pointer to the OS_SEM structure
Returns
OS_NO_ERR - If successful
OS_TIMEOUT - If it fails
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_SEM for current usage.

◆ OSSemPost()

uint8_t OSSemPost ( OS_SEM * psem)
inline

#include <nbrtos.h>

Increases the value of the semaphore by one. Note: If any higher priority tasks were waiting on the semaphore - it releases them.

Parameters
psemA pointer to the OS_SEM structure.
Returns
OS_NO_ERR - If successful
OS_SEM_OVF - If the value of the semaphore overflows
See also
NBRTOS Error Codes
Deprecated
This function is now deprecated. Please see OS_SEM for current usage.

◆ OSSetName()

void OSSetName ( const char * cp)

#include <nbrtos.h>

Set the name of the calling task.

Parameters
cpCharacter pointer to new task name

◆ OSStartTaskDumper()

void OSStartTaskDumper ( uint8_t prio,
uint32_t reportInterval )

#include <nbrtos.h>

This function creates a task that calls OSDumpTasks() at the specified system time tick interval. The task is intended for use when debugging run status of multiple tasks.

Note
This function can only be called if NBRTOS_STACKCHECK is defined in predef.h.
See also
OSDumpTasks()

◆ OSTaskCreatewName()

uint8_t OSTaskCreatewName ( void(*)(void *dptr) task,
void * data,
void * pstktop,
void * pstkbot,
uint8_t prio,
const char * name )

#include <nbrtos.h>

Create a new task.

You must allocate storage for the task stack that this new task will use, and it must be 4 byte aligned.

Task priorities can range from 1 to OS_MAX_PRIOS, where OS_MAX_PRIOS is the lowest priority level and 1 is highest priority level. The recommended user priority levels for your application are in the range of 46 to OS_MAX_PRIOS-1. This avoids any conflicts with network communications. The maximum number of tasks your application can run is defined by OS_MAX_TASKS. Both OS_MAX_PRIOS and OS_MAX_TASKS are defined in "\nburn\nbrtos\include\constants.h".

Note
The system can have only one task at each priority
It is good practice to check the function return value to ensure the task was created successfully.
Parameters
taskThe address of the function where this task will start executing.
dataThe data to pass to the task function.
pstktopThe highest address of the stack space.
pstkbotThe lowest address of the stack space.
prioThe priority for this new task (OS_MAX_PRIOS is lowest priority and 1 is highest). Look in <nburn_install>/nbrtos/include/constants.h to see which priorities are used by the OS.
nameThe name of the task
Return values
OS_NO_ERRIf successful
OS_PRIO_EXISTIf the requested priority already exists, NBRTOS Error Codes
See also
OSTaskDelete(), OSChangePrio(), NBRTOS Error Codes

◆ OSTaskDelete()

void OSTaskDelete ( void )

#include <nbrtos.h>

This function deletes the current calling task, but we do not recommend the use of this function because it can cause memory leaks.

The preferred method for terminating a task is to set a flag or semaphore that the task is listening for. The flag can then be set by an outside task, which enables the task to be deleted to free any resources and terminate gracefully by simply returning.

See also
OSTaskCreatewName(), OSChangePrio()

◆ OSTimeDly()

void OSTimeDly ( uint32_t to_count)
inline

#include <nbrtos.h>

Delay the task until the specified value of the system timer ticks. The number of system ticks per second is defined by the constant: TICKS_PER_SECOND in <nburn_install>/nbrtos/include/constants.h. The default value is 20 ticks per second.

Note
The TICKS_PER_SECOND macro is a great way to make code more readable, and will also adjust if the default of 20 ticks/second is changed.
Parameters
to_countThe number of system ticks to delay.
See also
OSChangeTaskDly(), OSTimeWaitUntil()

◆ OSTimeWaitUntil()

void OSTimeWaitUntil ( uint32_t systemTickValue)

#include <nbrtos.h>

Delay the task until the specified value of the system timer tick. The number of system ticks per second is defined by the constant: TICKS_PER_SECOND in <nburn_install>/nbrtos/include/constants.h. The default value is 20 ticks per second.

Parameters
systemTickValueThe system time tick value to wait for
uint32_t Now = TimeTick;
while(1)
{
Now += 60 * TICKS_PER_SECOND;
// Do whatever every 60 seconds, no mater how long this takes to run the interval will have a consistant spacing
}
#define TICKS_PER_SECOND
System clock ticks per second.
Definition nbrtos/include/constants.h:41
void OSTimeWaitUntil(uint32_t systemTickValue)
Delay the task until the specified value of the system timer tick. The number of system ticks per sec...
See also
OSChangeTaskDly(), OSTimeDly()

◆ OSUnlock()

void OSUnlock ( void )

#include <nbrtos.h>

This function unlocks the OS.

Important: You must call OSUnlock() once for each call to OSLock().

See also
OSLock(), OSLockObj()

◆ OwnedByCurTask()

bool OS_CRIT::OwnedByCurTask ( )
inline

#include <nbrtos.h>

Check if critical section owned by the current task.

Check if current task owns the critical section.

Return values
trueif owned
falseif not owned

◆ ShowTaskList()

void ShowTaskList ( void )

#include <nbrtos.h>

This functions dumps the current RTOS task states to stdio.

The output takes on multiple lines of the following format for each logged state:



at t= [T] [Message]

Followed by a tally of the number of task states logged since system start:



Total messages: [N]

[T] represents the number of ticks in hexadecimal since system start; [N] represents the number of task state messages in decimal logged since system start; [Message] represents one of the output messages listed in the below table.

Message Description
Wait for Semaphore Task is asleep and pending for semaphore
Wake from Semaphore Task gets a semaphore and wakes up
Task locked Task becomes locked
Task lock++ Task gets an added nested lock
Task lock– Task get a nested lock unlocked
Task unlocked Task becomes completely unlocked
Task priority changed The task's priority level is changed
Unknown flag [F] The flag value defining the task's state is undefined
Switched to Task [P] Task priority [P] (in decimal) gets control
Switched to Task [P] PC=[X] Task priority [P] gets control with the program counter containing the address [X] (in hexadecimal) of the instruction being executed


Note: Usage of this function is valid only when defining NBRTOS_TASKLIST in debug mode. In order to enable this macro definition, it must be uncommented in \Nburn\include\predef.h, followed by rebuilding the system files to incorporate the modification. Attempting to load a compiled non-debug application image with the macro defined will cause a trap error.