26#include <basictypes.h>
43#define OS_STAT_RDY 0x00
44#define OS_STAT_MBOX 0x01
45#define OS_STAT_SEM 0x02
47#define OS_STAT_FIFO 0x08
48#define OS_STAT_CRIT 0x10
49#define OS_STAT_DELAY 0x20
50#define OS_STAT_RES4 0x40
51#define OS_STAT_RES5 0x80
61#define OS_MBOX_FULL 20
64#define OS_PRIO_EXIST 40
65#define OS_PRIO_INVALID 41
69#define OS_NO_MORE_TCB 70
74typedef volatile uint32_t tick_t;
80extern volatile tick_t TimeTick;
83inline bool IsTickLater(uint32_t test_time)
85 return ((
int)(TimeTick - test_time) < 0);
89inline bool IsTickNowOrEarlier(uint32_t test_time)
91 return ((
int)(TimeTick - test_time) >= 0);
95inline bool Is2ndTickEarlier(uint32_t t1, uint32_t t2)
97 return (((
int)(t1 - t2)) > 0);
101inline bool Is2ndTickNowOrEarlier(uint32_t t1, uint32_t t2)
103 return (((
int)(t1 - t2)) >= 0);
107struct RawTickTimeout_t
111 inline bool expired()
const {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
112 inline bool expired()
volatile {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
113 inline operator bool()
const {
return !expired(); }
114 const RawTickTimeout_t &operator=(
const TickTimeout &rhs);
115 volatile RawTickTimeout_t &operator=(
const TickTimeout &rhs)
volatile;
117 inline bool operator<(
const RawTickTimeout_t &later)
121 if (!later.expiration)
123 return (((
int)(expiration - later.expiration)) <= 0);
126 inline bool operator<(tick_t later)
130 return (((
int)(expiration - later)) <= 0);
133 inline tick_t operator-(
const tick_t &tick) {
return expiration - tick; }
134 inline tick_t operator-(
const tick_t &tick)
const {
return expiration - tick; }
135 inline tick_t operator-(
const tick_t &tick)
volatile {
return expiration - tick; }
138inline bool operator==(
const RawTickTimeout_t &lhs,
const int &rhs)
140 return lhs.expiration == (tick_t)rhs;
143inline bool operator==(
const volatile RawTickTimeout_t &lhs,
const int &rhs)
145 return lhs.expiration == (tick_t)rhs;
155 RawTickTimeout_t raw;
157 void set(uint32_t timeout)
159 if (!timeout) { raw.expiration = 0; }
162 raw.expiration = TimeTick + (timeout & 0x7FFFFFFF);
166 if (timeout && !raw.expiration) { raw.expiration = 1; }
171 class uint32_nonboolean_t
176 uint32_nonboolean_t(uint32_t
val) : value(
val) {}
177 inline explicit operator bool() {
return (
bool)value; }
178 inline operator uint32_t() {
return value; }
198 inline uint32_t
val()
const
200 if (!raw.expiration) {
return raw.expiration; }
201 int ret = raw.expiration - TimeTick;
203 return (ret > 0) ? ret : 1;
212 inline bool expired()
const {
return raw.expired(); }
225 inline operator bool()
const {
return !
expired(); }
227 inline operator uint32_t()
const {
return val(); }
229 inline operator uint16_t()
const
231 uint32_t ret =
val();
232 return ret > 0xFFFF ? 0xFFFE : ret;
237 raw.expiration = rhs.raw.expiration;
247 return raw < later.raw;
249 inline bool operator<(tick_t later)
259 inline void SetUntil(uint32_t when) {raw.expiration = when; }
263 friend class RawTickTimeout_t;
266inline const RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
268 expiration = rhs.raw.expiration;
272inline volatile RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
volatile
274 expiration = rhs.raw.expiration;
283 volatile uint32_t OSTbl[TASK_TABLE_SIZE];
286 void Init()
volatile;
287 void Copy(
volatile task_bit_list &rhs)
289 for (
int i = 0; i < TASK_TABLE_SIZE; i++)
291 OSTbl[i] = rhs.OSTbl[i];
296 void set(
int set_num)
volatile;
297 void clr(
int clr_num)
volatile;
300 uint32_t gethigh()
volatile;
301 uint32_t get_high_and_clear()
volatile;
303 inline bool isSet(
int num)
volatile const {
return (OSTbl[num / 32] & (0x80000000 >> (num % 32))); }
311 task_bit_list tasks_waiting;
318 bool Wait_when(uint8_t StatReason,
TickTimeout &timeout);
320 inline bool Wait(uint8_t StatReason, uint32_t to_count)
323 return Wait_when(StatReason, to_when);
327 void MakeHighTaskWaitingReady(uint8_t StatReason);
329} __attribute__((packed));
333class OS_TCB :
public cpu_tcb
341 RawTickTimeout_t OSTCBDly_when;
343 const char *pOSTCBName;
347#ifdef NBRTOS_PRIO_PROMOTION
350 volatile OS_TCB *pPromotedTo;
351 volatile OS_TCB *pDisplacedBy;
352 OS_TASK_DLY_OBJ *pWaiting;
353 uint32_t displacedByOrigPrio;
355 void PromoteToCurPrio()
volatile;
356 void Demote()
volatile;
359 static volatile OS_TCB *GetCur();
362 unsigned long switchTimeTick;
363 unsigned long switchTimeFraction;
364 unsigned long runningTime;
365 unsigned long runningTimeFraction;
371 bool Init(uint8_t prio,
void *pActualTop,
void *pstk,
long *pbot,
const char *name);
384 volatile uint32_t OSSemCnt;
385 volatile uint32_t OSSemUsed;
398 inline OS_SEM(int32_t cnt = 0) : OS_TASK_DLY_OBJ() {
Init(cnt); }
475 inline uint32_t
Avail() { uint32_t v; USER_ENTER_CRITICAL(); v=OSSemCnt-OSSemUsed; USER_EXIT_CRITICAL();
return v;};
477} __attribute__((packed));
496 bool OSMboxDataAvail;
498 bool Claim(
void *&Result);
526 uint8_t
Init(
void *msg = NULL);
552 inline void *
Pend(uint32_t timeoutTicks, uint8_t &result){
TickTimeout tt(timeoutTicks);
return Pend(tt,result);};
581 return Pend(timeoutTicks, unused);
634 TEMPL_MBOX(
const T *msg) : m_mbox((void *)msg) {}
635 inline uint8_t Init(
const T *msg) {
return m_mbox.
Init((
void *)msg); }
636 inline uint8_t Post(
const T *msg) {
return m_mbox.
Post((
void *)msg); }
638 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks, result)); };
640 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_mbox.
PendNoWait(result)); };
642 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks)); };
644 inline T *PendNoWait() {
return static_cast<T *
>(m_mbox.
PendNoWait()); };
668struct OS_Q :
public OS_TASK_DLY_OBJ
677 bool Claim(
void *&Result);
695 inline OS_Q(
void **pQueueStorage, uint8_t size) : OS_TASK_DLY_OBJ() {
Init(pQueueStorage, size); }
705 uint8_t
Init(
void **pQueueStorage, uint8_t size);
771 inline void *
Pend(uint32_t timeoutTicks, uint8_t &result){
TickTimeout tt(timeoutTicks);
return Pend(tt,result);};
800 return Pend(timeoutTicks, unused);
853 TEMPL_Q(T **pQueueStorage, uint8_t size)
854 : m_q((void**)pQueueStorage,size) { }
855 uint8_t Init(T **pQueueStorage, uint8_t size) {
return m_q.
Init((
void **)pQueueStorage, size); }
856 uint8_t Post(T *item) {
return m_q.
Post((
void *)item); }
857 uint8_t PostFirst(T *item) {
return m_q.
PostFirst((
void *)item); };
858 uint8_t PostUnique(T *item) {
return m_q.
PostUnique((
void *)item); };
859 uint8_t PostUniqueFirst(T *item) {
return m_q.
PostUniqueFirst((
void *)item); };
861 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks, result)); };
863 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks)); };
865 inline T *PendNoWait() {
return static_cast<T *
>(m_q.
PendNoWait()); };
867 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_q.
PendNoWait(result)); };
990 return Pend(timeoutTicks, unused);
1045 TEMPL_FIFO() { m_fifo.
Init(); }
1046 uint8_t Init() {
return m_fifo.
Init(); }
1047 uint8_t Post(T *item) {
return m_fifo.
Post((
OS_FIFO_EL *)item); }
1050 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks, result)); };
1052 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks)); };
1054 inline T *PendNoWait() {
return static_cast<T *
>(m_fifo.
PendNoWait()); };
1056 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_fifo.
PendNoWait(result)); };
1058 inline OS_FIFO *GetRawFIFO() {
return &m_fifo; }
1068class BufferCriticalLock;
1069class fifo_buffer_storage;
1078 OS_TCB *OSCritOwnerTCB;
1079 uint32_t OSCritDepthCount;
1187 friend class BufferCriticalLock;
1188 friend class fifo_buffer_storage;
1206 if (enableFromISR) { OSCritOwnerTCB = (OS_TCB *)0xFFFFFFFF; }
1209 OSCritOwnerTCB = NULL;
1229} __attribute__((packed));
1233struct OS_FLAGS_WAIT;
1248 vuint32_t m_current_flags;
1249 void *m_pWaitinglist;
1251 void AddOFW(OS_FLAGS_WAIT *ofw);
1252 void RemoveOFW(OS_FLAGS_WAIT *ofw);
1276 void Set(uint32_t bits_to_set);
1426[[deprecated]]
inline void OSFlagCreate(
OS_FLAGS *pf)
1443 flags->
Set(bits_to_set);
1458 flags->
Clear(bits_to_clr);
1477 return flags->
PendAny(bit_mask, timeout);
1514 return flags->
PendAll(bit_mask, timeout);
1548 return flags->
State();
1557extern volatile OS_TCB *OSTCBPrioTbl[OS_MAX_PRIOS];
1560extern volatile task_bit_list OSTaskReadyList;
1561#ifdef NBRTOS_PRIO_PROMOTION
1562extern volatile task_bit_list OSInUsePrioList FAST_SYS_VAR;
1563extern volatile task_bit_list OSActivePrioList FAST_SYS_VAR;
1566extern OS_TCB OSTCBTbl[OS_MAX_TASKS];
1568extern OS_TCB *pOSActiveTCBList;
1571extern volatile uint32_t nPrioOfCurTask;
1572extern volatile uint32_t nPrioOfHighReady;
1573extern volatile OS_TCB *OSTCBCur;
1574extern volatile OS_TCB *OSTCBHighRdy;
1576extern OS_TCB *pOSTCBFreeList;
1578extern volatile uint32_t OSIntNesting;
1579extern volatile uint32_t OSLockNesting;
1580extern volatile uint32_t OSISRLevel32;
1582extern volatile bool OSRunning;
1585extern unsigned long OSTcbStructSize;
1587#ifdef NBRTOS_TASK_LOG
1588extern void (*pTaskLogger)(uint8_t nextPrio);
1600void OSInit(uint8_t maxtasks);
1602void OSCreateIdleTask();
1650#define OSSimpleTaskCreatewName(x, p, n) \
1652 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))); \
1653 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1656#define OSSimpleTaskCreatewNameSRAM(x, p, n) \
1658 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))) FAST_USER_STK; \
1659 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1663#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)
1680#define OSSimpleTaskCreateLambda(p,n,f) LambdaTask2(p,n,[]( void * pv)f,__COUNTER__)
1718 uint32_t to_when = to_count + TimeTick;
1719 if (!to_when) to_when++;
1727 void OSIntExit(
void);
1729 void OSTickISR(
void);
1730 void OSStartHighRdy(
void);
1731 void OSSetupVBR(
void);
1733 void OSTimeTick(
void);
1748OS_TCB *OSTCBGetFree(
void);
1836 return psem->
Post();
1855 return psem->
Pend(timeout);
1908 return pmbox->
Post(msg);
1924 return pmbox->
Pend(timeout, *err);
1956[[deprecated]]
inline uint8_t
OSQInit(
OS_Q *pq,
void **start, uint8_t size)
1976 return pq->
Post(msg);
2048[[deprecated]]
inline void *
OSQPend(
OS_Q *pq, uint16_t timeout, uint8_t *err)
2050 return pq->
Pend(timeout, *err);
2099 return pFifo->
Post(pToPost);
2130 return pFifo->
Pend(timeout);
2161 return pCrit->
Init();
2163[[deprecated]]
inline uint8_t OSCritLockAndEnter(
OS_CRIT *pCrit, uint16_t timeout)
2183 return pCrit->
Enter(timeout);
2217 return pCrit->
Leave();
2219[[deprecated]]
inline uint8_t OSCritLeaveAndUnlock(
OS_CRIT *pCrit)
2234void OSChangeTaskWhen(uint16_t task_prio, uint32_t to_when);
2248 uint32_t to_when = to_count + TimeTick;
2249 if (!to_when) to_when++;
2250 OSChangeTaskWhen(task_prio, to_when);
2258#if (defined NBRTOS_STACKOVERFLOW) || (defined NBRTOS_STACKUNDERFLOW)
2259void EnableOSStackProtector();
2260extern "C" void OSStackProtectCtxSw();
2261extern "C" void OSStackProtectIntCtxSw();
2262extern "C" void OSStackProtector();
2265#ifdef NBRTOS_STACKCHECK
2297#ifdef NBRTOS_TASKLIST
2307uint32_t GetCurrentTaskTime(uint32_t *
const TotalTicks);
2308void ShowTaskTimes(
void);
2309void ClearTaskTimes(
void);
2335} __attribute__((packed));
2377 ocrit.
Enter(timeout);
2385} __attribute__((packed));
2472 return OSCritOwnerTCB == OSTCBCur;
2489 static bool bAlreadInited;
2493 inline bool WasInitDone() {
return bAlreadInited; }
2502 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:2487
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:2347
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:2371
OSCriticalSectionObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call Enter() on the OS_CRIT object that is passe...
Definition: nbrtos.h:2357
~OSCriticalSectionObj()
Destructs the OSCriticalSectionObj object, and call Leave() on the OS_CRIT object that was passed int...
Definition: nbrtos.h:2384
A simple wrapper class that helps utilize OS_CRIT objects to lock tasks and enter critical sections m...
Definition: nbrtos.h:2398
~OSLockAndCritObj()
Call LeaveAndUnlock() on the OSCriticalSectionObj object, then destruct.
Definition: nbrtos.h:2414
OSLockAndCritObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call LockAndEnter() on the OS_CRIT object that i...
Definition: nbrtos.h:2408
A simple wrapper class that helps use OS locks effectively.
Definition: nbrtos.h:2324
OSLockObj()
Initialize the OSLockObj and calls OSLock().
Definition: nbrtos.h:2329
~OSLockObj()
Destructs the OSLockObj and calls OSUnlock().
Definition: nbrtos.h:2334
A simple wrapper class that uses an OS_CRIT object to try and claim a critical section,...
Definition: nbrtos.h:2429
~OSSpinCrit()
Call Leave() on the OS_CRIT object, and then destruct/.
Definition: nbrtos.h:2448
OSSpinCrit(OS_CRIT &ocrit)
Initialize the OSSpinCrit object, and then call EnterNoWait() repeatedly on the OS_CRIT object that i...
Definition: nbrtos.h:2439
TickTimeout objects are used to facilitate sequential function calls with timeout parameters that nee...
Definition: nbrtos.h:154
bool expired() const
Determine whether the timeout duration has elapsed.
Definition: nbrtos.h:212
TickTimeout(uint32_t timeout)
Create and initialize the Timeout.
Definition: nbrtos.h:188
void SetUntil(uint32_t when)
Set the TimeTick value to expire.
Definition: nbrtos.h:259
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:198
User critial section object class.
Definition: nbrtos.h:2456
NetBurner System Constants.
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:2246
uint8_t OSCritInit(OS_CRIT *pCrit)
This function initializes the critical section.
Definition: nbrtos.h:2159
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:1992
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:1816
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:1512
uint8_t OSMboxPost(OS_MBOX *pmbox, void *msg)
This function posts a message to a Mail box.
Definition: nbrtos.h:1906
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:1922
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:2012
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:2181
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:1475
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:2198
uint8_t OSCritLeave(OS_CRIT *pCrit)
This function releases the critical section.
Definition: nbrtos.h:2215
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:2032
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:2113
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:2097
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:1441
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:2128
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:1493
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:1974
uint8_t OSSemPendNoWait(OS_SEM *psem)
OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.
Definition: nbrtos.h:1870
uint8_t OSFifoInit(OS_FIFO *pFifo)
Initialize a FIFO, which is used to pass structures from one task to another.
Definition: nbrtos.h:2080
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:1546
#define WAIT_FOREVER
Parameter macro used for timeout parameters that have a 0 value and wait forever.
Definition: nbrtos.h:72
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:1853
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:1456
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:1956
void * OSMboxPendNoWait(OS_MBOX *pmbox, uint8_t *err)
OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.
Definition: nbrtos.h:1937
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:1530
bool OwnedByCurTask()
Check if critical section owned by the current task.
Definition: nbrtos.h:2470
void * OSQPendNoWait(OS_Q *pq, uint8_t *err)
OSQPendNoWait() is identical to the OSQPend() function but it does not wait.
Definition: nbrtos.h:2063
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:1716
OS_FIFO_EL * OSFifoPendNoWait(OS_FIFO *pFifo)
This function is identical to the OSFifoPen() function, but it does not wait.
Definition: nbrtos.h:2142
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:2048
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:1834
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:1888
#define OS_TIMEOUT
Timeout.
Definition: nbrtos.h:60
#define OS_CRIT_ERR
Critical section error.
Definition: nbrtos.h:68
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition: nbrtos.h:1077
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:1195
void SetUseFromISR(bool enableFromISR)
Set critical section UsedFromISR flag.
Definition: nbrtos.h:1204
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:1089
uint8_t Enter(uint32_t timeoutTicks=WAIT_FOREVER)
Request to Enter/Claim the critical section, with a time out parameter.
Definition: nbrtos.h:1147
uint32_t CurDepth()
Returns the critical section depth count.
Definition: nbrtos.h:1223
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:912
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:987
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:1005
OS_FIFO_EL * PendNoWait()
Attempts to pend a structure to the FIFO, but does not wait.
Definition: nbrtos.h:1029
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:961
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:1246
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:1405
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:1320
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:1377
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:1350
Mailboxes single value storage locations used to communicate between tasks.
Definition: nbrtos.h:494
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:596
void * PendNoWait()
Checks if a message is available in the mailbox and returns immediately.
Definition: nbrtos.h:619
OS_MBOX()
Create and initialize a mailbox object with no defalut message.
Definition: nbrtos.h:506
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:515
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:578
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:552
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:669
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:838
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:815
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:771
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:695
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:797
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition: nbrtos.h:383
uint8_t Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait timeout ticks for the value of the semaphore to be non zero.
Definition: nbrtos.h:431
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:398
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:475
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:442
OS_FIFO element definition.
Definition: nbrtos.h:877
puint8_t pAsBytePtr
Next OS_FIFO element data byte pointer.
Definition: nbrtos.h:886
struct os_fifo_el * pNextFifo_El
Pointer to next OS_FIFO element.
Definition: nbrtos.h:885