27#include <basictypes.h>
45#define OS_STAT_RDY 0x00
46#define OS_STAT_MBOX 0x01
47#define OS_STAT_SEM 0x02
49#define OS_STAT_FIFO 0x08
50#define OS_STAT_CRIT 0x10
51#define OS_STAT_DELAY 0x20
52#define OS_STAT_RES4 0x40
53#define OS_STAT_RES5 0x80
64#define OS_MBOX_FULL 20
67#define OS_PRIO_EXIST 40
68#define OS_PRIO_INVALID 41
72#define OS_NO_MORE_TCB 70
77typedef volatile uint32_t tick_t;
83extern volatile tick_t TimeTick;
86inline bool IsTickLater(uint32_t test_time)
88 return ((
int)(TimeTick - test_time) < 0);
92inline bool IsTickNowOrEarlier(uint32_t test_time)
94 return ((
int)(TimeTick - test_time) >= 0);
98inline bool Is2ndTickEarlier(uint32_t t1, uint32_t t2)
100 return (((
int)(t1 - t2)) > 0);
104inline bool Is2ndTickNowOrEarlier(uint32_t t1, uint32_t t2)
106 return (((
int)(t1 - t2)) >= 0);
110struct RawTickTimeout_t
114 inline bool expired()
const {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
115 inline bool expired()
volatile {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
116 inline operator bool()
const {
return !expired(); }
117 const RawTickTimeout_t &operator=(
const TickTimeout &rhs);
118 volatile RawTickTimeout_t &operator=(
const TickTimeout &rhs)
volatile;
120 inline bool operator<(
const RawTickTimeout_t &later)
124 if (!later.expiration)
126 return (((
int)(expiration - later.expiration)) <= 0);
129 inline bool operator<(tick_t later)
133 return (((
int)(expiration - later)) <= 0);
136 inline tick_t operator-(
const tick_t &tick) {
return expiration - tick; }
137 inline tick_t operator-(
const tick_t &tick)
const {
return expiration - tick; }
138 inline tick_t operator-(
const tick_t &tick)
volatile {
return expiration - tick; }
141inline bool operator==(
const RawTickTimeout_t &lhs,
const int &rhs)
143 return lhs.expiration == (tick_t)rhs;
146inline bool operator==(
const volatile RawTickTimeout_t &lhs,
const int &rhs)
148 return lhs.expiration == (tick_t)rhs;
158 RawTickTimeout_t raw;
160 void set(uint32_t timeout)
162 if (!timeout) { raw.expiration = 0; }
165 raw.expiration = TimeTick + (timeout & 0x7FFFFFFF);
169 if (timeout && !raw.expiration) { raw.expiration = 1; }
174 class uint32_nonboolean_t
179 uint32_nonboolean_t(uint32_t
val) : value(
val) {}
180 inline explicit operator bool() {
return (
bool)value; }
181 inline operator uint32_t() {
return value; }
201 inline uint32_t
val()
const
203 if (!raw.expiration) {
return raw.expiration; }
204 int ret = raw.expiration - TimeTick;
206 return (ret > 0) ? ret : 1;
215 inline bool expired()
const {
return raw.expired(); }
228 inline operator bool()
const {
return !
expired(); }
230 inline operator uint32_t()
const {
return val(); }
232 inline operator uint16_t()
const
234 uint32_t ret =
val();
235 return ret > 0xFFFF ? 0xFFFE : ret;
240 raw.expiration = rhs.raw.expiration;
250 return raw < later.raw;
252 inline bool operator<(tick_t later)
262 inline void SetUntil(uint32_t when) {raw.expiration = when; }
266 friend class RawTickTimeout_t;
269inline const RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
271 expiration = rhs.raw.expiration;
275inline volatile RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
volatile
277 expiration = rhs.raw.expiration;
289 void Init()
volatile;
290 void Copy(
volatile task_bit_list &rhs)
294 OSTbl[i] = rhs.OSTbl[i];
299 void set(
int set_num)
volatile;
300 void clr(
int clr_num)
volatile;
303 uint32_t gethigh()
volatile;
304 uint32_t get_high_and_clear()
volatile;
306 inline bool isSet(
int num)
volatile const {
return (OSTbl[num / 32] & (0x80000000 >> (num % 32))); }
314 task_bit_list tasks_waiting;
321 bool Wait_when(uint8_t StatReason,
TickTimeout &timeout);
323 inline bool Wait(uint8_t StatReason, uint32_t to_count)
326 return Wait_when(StatReason, to_when);
330 void MakeHighTaskWaitingReady(uint8_t StatReason);
332} __attribute__((packed));
336class OS_TCB :
public cpu_tcb
344 RawTickTimeout_t OSTCBDly_when;
346 const char *pOSTCBName;
350#ifdef NBRTOS_PRIO_PROMOTION
353 volatile OS_TCB *pPromotedTo;
354 volatile OS_TCB *pDisplacedBy;
355 OS_TASK_DLY_OBJ *pWaiting;
356 uint32_t displacedByOrigPrio;
358 void PromoteToCurPrio()
volatile;
359 void Demote()
volatile;
362 static volatile OS_TCB *GetCur();
365 unsigned long switchTimeTick;
366 unsigned long switchTimeFraction;
367 unsigned long runningTime;
368 unsigned long runningTimeFraction;
374 bool Init(uint8_t prio,
void *pActualTop,
void *pstk,
long *pbot,
const char *name);
387 volatile uint32_t OSSemCnt;
388 volatile uint32_t OSSemUsed;
401 inline OS_SEM(int32_t cnt = 0) : OS_TASK_DLY_OBJ() {
Init(cnt); }
478 inline uint32_t
Avail() { uint32_t v; USER_ENTER_CRITICAL(); v=OSSemCnt-OSSemUsed; USER_EXIT_CRITICAL();
return v;};
480} __attribute__((packed));
499 bool OSMboxDataAvail;
501 bool Claim(
void *&Result);
529 uint8_t
Init(
void *msg = NULL);
555 inline void *
Pend(uint32_t timeoutTicks, uint8_t &result){
TickTimeout tt(timeoutTicks);
return Pend(tt,result);};
584 return Pend(timeoutTicks, unused);
637 TEMPL_MBOX(
const T *msg) : m_mbox((void *)msg) {}
638 inline uint8_t Init(
const T *msg) {
return m_mbox.
Init((
void *)msg); }
639 inline uint8_t Post(
const T *msg) {
return m_mbox.
Post((
void *)msg); }
641 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks, result)); };
643 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_mbox.
PendNoWait(result)); };
645 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks)); };
647 inline T *PendNoWait() {
return static_cast<T *
>(m_mbox.
PendNoWait()); };
671struct OS_Q :
public OS_TASK_DLY_OBJ
680 bool Claim(
void *&Result);
698 inline OS_Q(
void **pQueueStorage, uint8_t size) : OS_TASK_DLY_OBJ() {
Init(pQueueStorage, size); }
708 uint8_t
Init(
void **pQueueStorage, uint8_t size);
774 inline void *
Pend(uint32_t timeoutTicks, uint8_t &result){
TickTimeout tt(timeoutTicks);
return Pend(tt,result);};
803 return Pend(timeoutTicks, unused);
860 TEMPL_Q(T **pQueueStorage, uint8_t size)
861 : m_q((
void**)pQueueStorage,size) { }
862 uint8_t Init(T **pQueueStorage, uint8_t size) {
return m_q.
Init((
void **)pQueueStorage, size); }
863 uint8_t Post(T *item) {
return m_q.
Post((
void *)item); }
864 uint8_t PostFirst(T *item) {
return m_q.
PostFirst((
void *)item); };
865 uint8_t PostUnique(T *item) {
return m_q.
PostUnique((
void *)item); };
866 uint8_t PostUniqueFirst(T *item) {
return m_q.
PostUniqueFirst((
void *)item); };
868 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks, result)); };
870 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks)); };
872 inline T *PendNoWait() {
return static_cast<T *
>(m_q.
PendNoWait()); };
874 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_q.
PendNoWait(result)); };
997 return Pend(timeoutTicks, unused);
1052 TEMPL_FIFO() { m_fifo.
Init(); }
1053 uint8_t Init() {
return m_fifo.
Init(); }
1054 uint8_t Post(T *item) {
return m_fifo.
Post((
OS_FIFO_EL *)item); }
1057 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks, result)); };
1059 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks)); };
1061 inline T *PendNoWait() {
return static_cast<T *
>(m_fifo.
PendNoWait()); };
1063 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_fifo.
PendNoWait(result)); };
1065 inline OS_FIFO *GetRawFIFO() {
return &m_fifo; }
1075class BufferCriticalLock;
1076class fifo_buffer_storage;
1085 OS_TCB *OSCritOwnerTCB;
1086 uint32_t OSCritDepthCount;
1089 OS_TCB *GetOwner() {
return (OS_TCB*)(((uint32_t)OSCritOwnerTCB)&~0x1ul); }
1090 void SetOwner(OS_TCB *newOwner)
1093 (OS_TCB*) (((uint32_t)newOwner) | (((uint32_t)OSCritOwnerTCB)&0x1));
1200 friend class BufferCriticalLock;
1201 friend class fifo_buffer_storage;
1221 OSCritOwnerTCB = (OS_TCB*)(((uint32_t)OSCritOwnerTCB)|0x1ul);
1225 OSCritOwnerTCB = (OS_TCB*)(((uint32_t)OSCritOwnerTCB)&~0x1ul);
1245} __attribute__((packed));
1249struct OS_FLAGS_WAIT;
1264 vuint32_t m_current_flags;
1265 void *m_pWaitinglist;
1267 void AddOFW(OS_FLAGS_WAIT *ofw);
1268 void RemoveOFW(OS_FLAGS_WAIT *ofw);
1292 void Set(uint32_t bits_to_set);
1442[[deprecated]]
inline void OSFlagCreate(
OS_FLAGS *pf)
1459 flags->
Set(bits_to_set);
1474 flags->
Clear(bits_to_clr);
1493 return flags->
PendAny(bit_mask, timeout);
1530 return flags->
PendAll(bit_mask, timeout);
1564 return flags->
State();
1576extern volatile task_bit_list OSTaskReadyList;
1577#ifdef NBRTOS_PRIO_PROMOTION
1578extern volatile task_bit_list OSInUsePrioList
FAST_SYS_VAR;
1579extern volatile task_bit_list OSActivePrioList
FAST_SYS_VAR;
1584extern OS_TCB *pOSActiveTCBList;
1587extern volatile uint32_t nPrioOfCurTask;
1588extern volatile uint32_t nPrioOfHighReady;
1589extern volatile OS_TCB *OSTCBCur;
1590extern volatile OS_TCB *OSTCBHighRdy;
1592extern OS_TCB *pOSTCBFreeList;
1594extern volatile uint32_t OSIntNesting;
1595extern volatile uint32_t OSLockNesting;
1596extern volatile uint32_t OSISRLevel32;
1598extern volatile bool OSRunning;
1601extern unsigned long OSTcbStructSize;
1603#ifdef NBRTOS_TASK_LOG
1604extern void (*pTaskLogger)(uint8_t nextPrio);
1616void OSInit(uint8_t maxtasks);
1618void OSCreateIdleTask();
1666#define OSSimpleTaskCreatewName(x, p, n) \
1668 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))); \
1669 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1672#define OSSimpleTaskCreatewNameSRAM(x, p, n) \
1674 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))) FAST_USER_STK; \
1675 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1679#define LambdaTask2(p,n,f,vn) static uint32_t func_##vn_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4)));OSTaskCreatewName(f, NULL, (void *)&func_##vn_Stk[USER_TASK_STK_SIZE], (void *)func_##vn_Stk, p, n)
1696#define OSSimpleTaskCreateLambda(p,n,f) LambdaTask2(p,n,[]( void * pv)f,__COUNTER__)
1734 uint32_t to_when = to_count + TimeTick;
1735 if (!to_when) to_when++;
1743 void OSIntExit(
void);
1745 void OSTickISR(
void);
1746 void OSStartHighRdy(
void);
1747 void OSSetupVBR(
void);
1749 void OSTimeTick(
void);
1764OS_TCB *OSTCBGetFree(
void);
1852 return psem->
Post();
1871 return psem->
Pend(timeout);
1924 return pmbox->
Post(msg);
1940 return pmbox->
Pend(timeout, *err);
1972[[deprecated]]
inline uint8_t
OSQInit(
OS_Q *pq,
void **start, uint8_t size)
1992 return pq->
Post(msg);
2064[[deprecated]]
inline void *
OSQPend(
OS_Q *pq, uint16_t timeout, uint8_t *err)
2066 return pq->
Pend(timeout, *err);
2115 return pFifo->
Post(pToPost);
2146 return pFifo->
Pend(timeout);
2177 return pCrit->
Init();
2179[[deprecated]]
inline uint8_t OSCritLockAndEnter(
OS_CRIT *pCrit, uint16_t timeout)
2199 return pCrit->
Enter(timeout);
2233 return pCrit->
Leave();
2235[[deprecated]]
inline uint8_t OSCritLeaveAndUnlock(
OS_CRIT *pCrit)
2250void OSChangeTaskWhen(uint16_t task_prio, uint32_t to_when);
2264 uint32_t to_when = to_count + TimeTick;
2265 if (!to_when) to_when++;
2266 OSChangeTaskWhen(task_prio, to_when);
2274#if (defined NBRTOS_STACKOVERFLOW) || (defined NBRTOS_STACKUNDERFLOW)
2275void EnableOSStackProtector();
2276extern "C" void OSStackProtectCtxSw();
2277extern "C" void OSStackProtectIntCtxSw();
2278extern "C" void OSStackProtector();
2281#ifdef NBRTOS_STACKCHECK
2313#ifdef NBRTOS_TASKLIST
2323uint32_t GetCurrentTaskTime(uint32_t *
const TotalTicks);
2324void ShowTaskTimes(
void);
2325void ClearTaskTimes(
void);
2351} __attribute__((packed));
2393 ocrit.
Enter(timeout);
2401} __attribute__((packed));
2488 return OSCritOwnerTCB == OSTCBCur;
2505 static bool bAlreadInited;
2509 inline bool WasInitDone() {
return bAlreadInited; }
2518 static void InitWholeSet();
A simple class to derive from if you are creating tasks that are constructed at global scope and need...
Definition nbrtos.h:2503
virtual void Notify()=0
This will be called when the RTOS has been setup in initalization.
A simple wrapper class that helps utilize OS_CRIT objects more effectively.
Definition nbrtos.h:2363
OSCriticalSectionObj(OS_CRIT &ocrit, bool NoWait, TickTimeout &timeout)
Initialize the OSCriticalSectionObj object, and then call Enter() on the OS_CRIT object that is passe...
Definition nbrtos.h:2387
OSCriticalSectionObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call Enter() on the OS_CRIT object that is passe...
Definition nbrtos.h:2373
~OSCriticalSectionObj()
Destructs the OSCriticalSectionObj object, and call Leave() on the OS_CRIT object that was passed int...
Definition nbrtos.h:2400
A simple wrapper class that helps utilize OS_CRIT objects to lock tasks and enter critical sections m...
Definition nbrtos.h:2414
~OSLockAndCritObj()
Call LeaveAndUnlock() on the OSCriticalSectionObj object, then destruct.
Definition nbrtos.h:2430
OSLockAndCritObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call LockAndEnter() on the OS_CRIT object that i...
Definition nbrtos.h:2424
A simple wrapper class that helps use OS locks effectively.
Definition nbrtos.h:2340
OSLockObj()
Initialize the OSLockObj and calls OSLock().
Definition nbrtos.h:2345
~OSLockObj()
Destructs the OSLockObj and calls OSUnlock().
Definition nbrtos.h:2350
A simple wrapper class that uses an OS_CRIT object to try and claim a critical section,...
Definition nbrtos.h:2445
~OSSpinCrit()
Call Leave() on the OS_CRIT object, and then destruct/.
Definition nbrtos.h:2464
OSSpinCrit(OS_CRIT &ocrit)
Initialize the OSSpinCrit object, and then call EnterNoWait() repeatedly on the OS_CRIT object that i...
Definition nbrtos.h:2455
TickTimeout objects are used to facilitate sequential function calls with timeout parameters that nee...
Definition nbrtos.h:157
bool expired() const
Determine whether the timeout duration has elapsed.
Definition nbrtos.h:215
TickTimeout(uint32_t timeout)
Create and initialize the Timeout.
Definition nbrtos.h:191
void SetUntil(uint32_t when)
Set the TimeTick value to expire.
Definition nbrtos.h:262
friend void OSTimeWaitUntil(uint32_t systemTickValue)
Delay the task until the specified value of the system timer tick. The number of system ticks per sec...
uint32_t val() const
Get the timeout duration to be passed to a function utilizing timeout ticks.
Definition nbrtos.h:201
User critial section object class.
Definition nbrtos.h:2472
#define OS_MAX_TASKS
Max number of system tasks.
Definition nbrtos/include/constants.h:67
#define OS_MAX_PRIOS
Maximum number of system priorities.
Definition nbrtos/include/constants.h:69
void OSUnlock(void)
This function unlocks the OS.
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.
Definition nbrtos.h:2262
uint8_t OSCritInit(OS_CRIT *pCrit)
This function initializes the critical section.
Definition nbrtos.h:2175
struct os_fifo_el OS_FIFO_EL
OS_FIFO element definition.
uint8_t OSChangePrio(uint32_t newp)
Set the priority of the calling task.
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.
Definition nbrtos.h:2008
void OSSetName(const char *cp)
Set the name of the calling task.
void OSDumpTasks(void)
Dump the state and call stack for every task to stdout. This function is useful for debugging.
uint8_t OSSemInit(OS_SEM *psem, long value)
Initializes a semaphore.
Definition nbrtos.h:1832
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_...
Definition nbrtos.h:1528
uint8_t OSMboxPost(OS_MBOX *pmbox, void *msg)
This function posts a message to a Mail box.
Definition nbrtos.h:1922
void * OSMboxPend(OS_MBOX *pmbox, uint16_t timeout, uint8_t *err)
Wait timeout ticks for some other task to post to the Mailbox.
Definition nbrtos.h:1938
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 fu...
Definition nbrtos.h:2028
void OSStartTaskDumper(uint8_t prio, uint32_t reportInterval)
This function creates a task that calls OSDumpTasks() at the specified system time tick interval....
uint8_t OSCritEnter(OS_CRIT *pCrit, uint16_t timeout)
This function tries to enter or claim the critical section.
Definition nbrtos.h:2197
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 b...
Definition nbrtos.h:1491
void OSTaskDelete(void)
This function deletes the current calling task, but we do not recommend the use of this function beca...
uint8_t OSCritEnterNoWait(OS_CRIT *pCrit)
This function tries to enter or claim the critical section.
Definition nbrtos.h:2214
uint8_t OSCritLeave(OS_CRIT *pCrit)
This function releases the critical section.
Definition nbrtos.h:2231
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 T...
Definition nbrtos.h:2048
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 FIF...
Definition nbrtos.h:2129
void ShowTaskList(void)
This functions dumps the current RTOS task states to stdio.
uint8_t OSFifoPost(OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
This function posts to a FIFO.
Definition nbrtos.h:2113
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...
Definition nbrtos.h:1457
uint8_t OSTaskID(void)
Returns the current task's priority.
OS_FIFO_EL * OSFifoPend(OS_FIFO *pFifo, uint16_t timeout)
This function pends on a FIFO.
Definition nbrtos.h:2144
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 doe...
Definition nbrtos.h:1509
uint8_t OSTaskCreatewName(void(*task)(void *dptr), void *data, void *pstktop, void *pstkbot, uint8_t prio, const char *name)
Create a new task.
uint8_t OSQPost(OS_Q *pq, void *msg)
This function posts a message to a Queue.
Definition nbrtos.h:1990
uint8_t OSSemPendNoWait(OS_SEM *psem)
OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.
Definition nbrtos.h:1886
uint8_t OSFifoInit(OS_FIFO *pFifo)
Initialize a FIFO, which is used to pass structures from one task to another.
Definition nbrtos.h:2096
void OSTimeWaitUntil(uint32_t systemTickValue)
Delay the task until the specified value of the system timer tick. The number of system ticks per sec...
void OSDumpTCBStacks(void)
This function dumps information about the UCOS stacks and tasks to stdout. This function is useful fo...
void OSLock(void)
Calling the OSLock function will prevent the OS from changing tasks.
const char * OSTaskName()
Returns the current task's name.
uint32_t OSFlagState(OS_FLAGS *flags)
This function returns the current values of the flags stored in the OS_FLAGS object structure.
Definition nbrtos.h:1562
#define WAIT_FOREVER
Parameter macro used for timeout parameters that have a 0 value and wait forever.
Definition nbrtos.h:75
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) w...
Definition nbrtos.h:1869
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....
Definition nbrtos.h:1472
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 ...
Definition nbrtos.h:1972
void * OSMboxPendNoWait(OS_MBOX *pmbox, uint8_t *err)
OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.
Definition nbrtos.h:1953
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 n...
Definition nbrtos.h:1546
bool OwnedByCurTask()
Check if critical section owned by the current task.
Definition nbrtos.h:2486
void * OSQPendNoWait(OS_Q *pq, uint8_t *err)
OSQPendNoWait() is identical to the OSQPend() function but it does not wait.
Definition nbrtos.h:2079
void OSTimeDly(uint32_t to_count)
Delay the task until the specified value of the system timer ticks. The number of system ticks per se...
Definition nbrtos.h:1732
OS_FIFO_EL * OSFifoPendNoWait(OS_FIFO *pFifo)
This function is identical to the OSFifoPen() function, but it does not wait.
Definition nbrtos.h:2158
void * OSQPend(OS_Q *pq, uint16_t timeout, uint8_t *err)
Wait timeout ticks for another task to post to the queue.
Definition nbrtos.h:2064
uint8_t OSSemPost(OS_SEM *psem)
Increases the value of the semaphore by one. Note: If any higher priority tasks were waiting on the s...
Definition nbrtos.h:1850
void OSDumpStack(void)
Dump the task stack to the stdout.
uint8_t OSMboxInit(OS_MBOX *pmbox, void *msg)
This function is used to initialize an OS_MBOX structure.
Definition nbrtos.h:1904
#define OS_TIMEOUT
Timeout.
Definition nbrtos.h:63
#define OS_CRIT_ERR
Critical section error.
Definition nbrtos.h:71
NetBurner System Constants.
#define FAST_SYS_VAR
Definition nbrtos/include/constants.h:278
#define TASK_TABLE_SIZE
Definition nbrtos/include/constants.h:205
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition nbrtos.h:1084
uint8_t LockAndEnter(uint32_t timeoutTicks=WAIT_FOREVER)
Locks the current task to prevent task switching and claims the critical section.
uint8_t LeaveAndUnlock()
Leave/release the critical section and unlock the task.
uint8_t Init()
Initialize an OS_CRIT object to its default state.
uint8_t Enter(TickTimeout &t)
Request to Enter/Claim the critical section.
bool UsedFromISR()
Check if critical section UsedFromISR flag is set.
Definition nbrtos.h:1208
void SetUseFromISR(bool enableFromISR)
Set critical section UsedFromISR flag.
Definition nbrtos.h:1217
friend void ForceReboot(bool fromIRQ)
Forces the system hardware to perform a soft reset.
OS_CRIT()
Create and initialize an OS_CRIT object.
Definition nbrtos.h:1102
uint8_t Enter(uint32_t timeoutTicks=WAIT_FOREVER)
Request to Enter/Claim the critical section, with a time out parameter.
Definition nbrtos.h:1160
uint32_t CurDepth()
Returns the critical section depth count.
Definition nbrtos.h:1239
uint8_t EnterNoWait()
Request to Enter/Claim the critical section. Does not wait if a critical section is not available.
uint8_t Leave()
Release the critical section.
OS_FIFO()
Create and initialize a FIFO object.
Definition nbrtos.h:919
uint8_t Init()
Sets the FIFO object to its initial state.
OS_FIFO_EL * PendNoWait(uint8_t &result)
Attempts to pend a structure to the FIFO, but does not wait.
uint8_t PostFirst(OS_FIFO_EL *pToPost)
Post a message to the head of the FIFO.
OS_FIFO_EL * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Pend on a FIFO for the specified number of system TimeTicks.
Definition nbrtos.h:994
OS_FIFO_EL * Pend(TickTimeout &t, uint8_t &result)
Wait the specified number of TickTimeout ticks for some other task to post to the FIFO.
OS_FIFO_EL * PendUntil(uint32_t timeoutTime, uint8_t &result)
Wait the specified TimeTicks value for some other task to post to the FIFO.
Definition nbrtos.h:1012
OS_FIFO_EL * PendNoWait()
Attempts to pend a structure to the FIFO, but does not wait.
Definition nbrtos.h:1036
OS_FIFO_EL * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait the specified number of time ticks for some other task to post to the FIFO.
Definition nbrtos.h:968
uint8_t Post(OS_FIFO_EL *pToPost)
Post a message to the next available location in the FIFO.
OSFlags enables a function or task to pend on multiple flags or events.
Definition nbrtos.h:1262
uint8_t PendAll(uint32_t bit_mask, TickTimeout &timeout)
Wait the specified number of TickTimeout time ticks until all the specified flags are set.
uint8_t PendAnyNoWait(uint32_t bit_mask)
Check for the specified flags and return immediately.
void Write(uint32_t bits_to_force)
Set the flag bits to match the specified value.
void Init()
Initialize an OS_FLAG object to its default value.
OS_FLAGS()
Create and initialize an OS_FLAG object.
uint8_t PendAllUntil(uint32_t bit_mask, uint32_t end_time)
Wait until the specified system TimeTicks value for all of the flags in the bit mask to be set.
Definition nbrtos.h:1421
uint8_t PendAny(uint32_t bit_mask, uint16_t timeout=WAIT_FOREVER)
Wait the specified number of system TimeTicks for any of the flags in the bit mask to be set.
Definition nbrtos.h:1336
uint32_t State()
Returns the current values of the flags stored in the OS_FLAGS object.
void Set(uint32_t bits_to_set)
Sets the specified flag bits.
uint8_t PendAll(uint32_t bit_mask, uint16_t timeout=WAIT_FOREVER)
Wait the specified number of system time ticks until all the specified flags are set.
Definition nbrtos.h:1393
uint8_t PendAllNoWait(uint32_t bit_mask)
Wait the specified number of system time ticks until all the specified flags are set.
void Clear(uint32_t bits_to_clr)
Clear the specified flag bits.
uint8_t PendAny(uint32_t bit_mask, TickTimeout &timeout)
Wait the specified number of TickTimeout time ticks for any of the flags in the bit mask to be set.
uint8_t PendAnyUntil(uint32_t bit_mask, uint32_t end_time)
Wait until the specified system TimeTicks value for any of the flags in the bit mask to be set.
Definition nbrtos.h:1366
Mailboxes single value storage locations used to communicate between tasks.
Definition nbrtos.h:497
void * PendUntil(uint32_t timeoutTime, uint8_t &result)
Wait the specified number of TimeTicks for some other task to post to the mailbox.
Definition nbrtos.h:599
void * PendNoWait()
Checks if a message is available in the mailbox and returns immediately.
Definition nbrtos.h:622
OS_MBOX()
Create and initialize a mailbox object with no defalut message.
Definition nbrtos.h:509
uint8_t Init(void *msg=NULL)
Sets the mailbox object to its initial state.
uint8_t Post(void *msg)
Post a message to the mailbox.
OS_MBOX(void *msg)
Create and initialize a mailbox object with the specified message.
Definition nbrtos.h:518
void * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait the specified number of time ticks for some other task to post to the mailbox.
Definition nbrtos.h:581
void * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait the specified number of time ticks for some other task to post to the mailbox.
Definition nbrtos.h:555
void * PendNoWait(uint8_t &result)
Checks if a message is available in the mailbox and returns immediately.
void * Pend(TickTimeout &t, uint8_t &result)
Wait the specified number of TickTimeout ticks for some other task to post to the mailbox.
A message queue is an object that enables tasks and interrupt service routines to pend and post point...
Definition nbrtos.h:672
uint8_t PostFirst(void *pItem)
Post a message to the head of the queue.
void * PendNoWait()
Checks if a message is available in the queue and returns immediately.
Definition nbrtos.h:841
void * PendUntil(uint32_t timeoutTime, uint8_t &result)
Wait the specified TimeTicks value for some other task to post to the queue.
Definition nbrtos.h:818
uint8_t PostUnique(void *pItem)
Post the specified message to the next available location in the queue, but only if the message is un...
uint8_t Post(void *pItem)
Post a message to the next available location in the queue.
void * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait the specified number of time ticks for some other task to post to the queue.
Definition nbrtos.h:774
void * Pend(TickTimeout &t, uint8_t &result)
Wait the specified number of TickTimeout ticks for some other task to post to the queue.
void * PendNoWait(uint8_t &result)
Checks if a message is available in the queue and returns immediately.
OS_Q(void **pQueueStorage, uint8_t size)
Create and initialize a queue object.
Definition nbrtos.h:698
uint8_t PostUniqueFirst(void *msg)
Post the specified message to the first location in the queue, but only if the message is unique and ...
uint8_t Init(void **pQueueStorage, uint8_t size)
Set the queue object to its initial state.
void * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait the specified number of time ticks for some other task to post to the queue.
Definition nbrtos.h:800
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition nbrtos.h:386
uint8_t Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait timeout ticks for the value of the semaphore to be non zero.
Definition nbrtos.h:434
uint8_t Init(int32_t cnt=0)
Initialize the semaphore object count value.
OS_SEM(int32_t cnt=0)
Create and initialize a semaphore.
Definition nbrtos.h:401
uint8_t Pend(TickTimeout &t)
Wait for the specified number of system time ticks for a task to post to the semaphore.
uint8_t PendNoWait()
Pend on a semaphore with no waiting period.
uint32_t Avail()
Returns the number of semaphore counts availble.
Definition nbrtos.h:478
uint8_t Post()
Posts to the semaphore, increasing it's value by 1.
uint8_t PendUntil(uint32_t timeout_time)
Wait until the specified timeout time for a task to post to the semaphore.
Definition nbrtos.h:445
A convenience wrapper around OS_Q.
Definition nbrtos.h:854
OS_FIFO element definition.
Definition nbrtos.h:884
puint8_t pAsBytePtr
Next OS_FIFO element data byte pointer.
Definition nbrtos.h:893
struct os_fifo_el * pNextFifo_El
Pointer to next OS_FIFO element.
Definition nbrtos.h:892