23 #include <constants.h> 26 #include <basictypes.h> 27 #include <nbrtoscpu.h> 42 #define OS_STAT_RDY 0x00 43 #define OS_STAT_MBOX 0x01 44 #define OS_STAT_SEM 0x02 45 #define OS_STAT_Q 0x04 46 #define OS_STAT_FIFO 0x08 47 #define OS_STAT_CRIT 0x10 48 #define OS_STAT_DELAY 0x20 49 #define OS_STAT_RES4 0x40 50 #define OS_STAT_RES5 0x80 60 #define OS_MBOX_FULL 20 62 #define OS_Q_EXISTS 31 63 #define OS_PRIO_EXIST 40 64 #define OS_PRIO_INVALID 41 67 #define OS_CRIT_ERR 60 68 #define OS_NO_MORE_TCB 70 // No TCBs free to create task 71 #define WAIT_FOREVER 0 73 typedef volatile uint32_t tick_t; 78 extern vuint32_t Secs;
79 extern volatile tick_t TimeTick;
82 struct RawTickTimeout_t
86 inline bool expired()
const {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
87 inline bool expired()
volatile {
return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
88 inline operator bool()
const {
return !expired(); }
89 const RawTickTimeout_t &operator=(
const TickTimeout &rhs);
90 volatile RawTickTimeout_t &operator=(
const TickTimeout &rhs)
volatile;
92 inline tick_t operator-(
const tick_t &tick) {
return expiration - tick; }
93 inline tick_t operator-(
const tick_t &tick)
const {
return expiration - tick; }
94 inline tick_t operator-(
const tick_t &tick)
volatile {
return expiration - tick; }
97 inline bool operator==(
const RawTickTimeout_t &lhs,
const int &rhs)
99 return lhs.expiration == (tick_t)rhs;
101 inline bool operator==(
const volatile RawTickTimeout_t &lhs,
const int &rhs)
103 return lhs.expiration == (tick_t)rhs;
114 RawTickTimeout_t raw;
116 void set(uint32_t timeout)
118 if (!timeout) { raw.expiration = 0; }
121 raw.expiration = TimeTick + (timeout & 0x7FFFFFFF);
125 if (timeout && !raw.expiration) { raw.expiration = 1; }
130 class uint32_nonboolean_t
135 uint32_nonboolean_t(uint32_t
val) : value(
val) {}
136 inline explicit operator bool() {
return (
bool)value; }
137 inline operator uint32_t() {
return value; }
153 inline uint32_t
val()
const 155 if (!raw.expiration) {
return raw.expiration; }
156 int ret = raw.expiration - TimeTick;
158 return (ret > 0) ? ret : 1;
167 inline bool expired()
const {
return raw.expired(); }
179 inline operator bool()
const {
return !
expired(); }
181 inline operator uint32_t()
const {
return val(); }
182 inline operator uint16_t()
const 184 uint32_t ret =
val();
185 return ret > 0xFFFF ? 0xFFFE : ret;
190 raw.expiration = rhs.raw.expiration;
199 friend void OSTimeWaitUntil(uint32_t systemTickValue);
200 friend class RawTickTimeout_t;
203 inline const RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
205 expiration = rhs.raw.expiration;
208 inline volatile RawTickTimeout_t &RawTickTimeout_t::operator=(
const TickTimeout &rhs)
volatile 210 expiration = rhs.raw.expiration;
219 volatile uint32_t OSTbl[TASK_TABLE_SIZE];
222 void Init()
volatile;
223 void Copy(
volatile task_bit_list &rhs)
225 for (
int i = 0; i < TASK_TABLE_SIZE; i++)
227 OSTbl[i] = rhs.OSTbl[i];
232 void set(
int set_num)
volatile;
233 void clr(
int clr_num)
volatile;
236 uint32_t gethigh()
volatile;
237 uint32_t get_high_and_clear()
volatile;
239 inline bool isSet(
int num)
volatile const {
return (OSTbl[num / 32] & (0x80000000 >> (num % 32))); }
245 class OS_TASK_DLY_OBJ
247 task_bit_list tasks_waiting;
254 bool Wait_when(uint8_t StatReason,
TickTimeout &timeout);
256 inline bool Wait(uint8_t StatReason, uint32_t to_count)
259 return Wait_when(StatReason, to_when);
263 void MakeHighTaskWaitingReady(uint8_t StatReason);
265 } __attribute__((packed));
269 class OS_TCB :
public cpu_tcb
277 RawTickTimeout_t OSTCBDly_when;
279 const char *pOSTCBName;
283 #ifdef NBRTOS_PRIO_PROMOTION 286 volatile OS_TCB *pPromotedTo;
287 volatile OS_TCB *pDisplacedBy;
288 OS_TASK_DLY_OBJ *pWaiting;
289 uint32_t displacedByOrigPrio;
291 void PromoteToCurPrio()
volatile;
292 void Demote()
volatile;
295 static volatile OS_TCB *GetCur();
298 unsigned long switchTimeTick;
299 unsigned long switchTimeFraction;
300 unsigned long runningTime;
301 unsigned long runningTimeFraction;
307 bool Init(uint8_t prio,
void *pActualTop,
void *pstk,
long *pbot,
const char *name);
320 volatile uint32_t OSSemCnt;
321 volatile uint32_t OSSemUsed;
332 inline OS_SEM(int32_t cnt = 0) : OS_TASK_DLY_OBJ() {
Init(cnt); }
345 uint8_t
Init(int32_t cnt = 0);
385 } __attribute__((packed));
394 uint32_t OSMboxDataAvail;
396 bool Claim(
void *&Result);
432 uint8_t
Post(
void *msg);
450 void *
Pend(uint32_t timeoutTicks, uint8_t &result);
485 return Pend(timeoutTicks, unused);
514 TEMPL_MBOX(
const T *msg) : m_mbox((void *)msg) {}
515 inline uint8_t Init(
const T *msg) {
return m_mbox.
Init((
void *)msg); }
516 inline uint8_t Post(
const T *msg) {
return m_mbox.
Post((
void *)msg); }
518 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks, result)); };
520 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_mbox.
PendNoWait(result)); };
522 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_mbox.
Pend(timeoutTicks)); };
524 inline T *PendNoWait() {
return static_cast<T *
>(m_mbox.
PendNoWait()); };
531 struct OS_Q :
public OS_TASK_DLY_OBJ
540 bool Claim(
void *&Result);
546 inline OS_Q() : OS_TASK_DLY_OBJ() {}
554 inline OS_Q(
void **pQueueStorage, uint8_t size) : OS_TASK_DLY_OBJ() {
Init(pQueueStorage, size); }
566 uint8_t
Init(
void **pQueueStorage, uint8_t size);
581 uint8_t
Post(
void *pItem);
645 void *
Pend(uint32_t timeoutTicks, uint8_t &result);
678 return Pend(timeoutTicks, unused);
706 TEMPL_Q(T **pQueueStorage, uint8_t size) { m_q.
Init((
void **)pQueueStorage, size); }
707 uint8_t Init(T **pQueueStorage, uint8_t size) {
return m_q.
Init((
void **)pQueueStorage, size); }
708 uint8_t Post(T *item) {
return m_q.
Post((
void *)item); }
709 uint8_t PostFirst(T *item) {
return m_q.
PostFirst((
void *)item); };
710 uint8_t PostUnique(T *item) {
return m_q.
PostUnique((
void *)item); };
711 uint8_t PostUniqueFirst(T *item) {
return m_q.
PostUniqueFirst((
void *)item); };
713 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks, result)); };
715 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_q.
Pend(timeoutTicks)); };
717 inline T *PendNoWait() {
return static_cast<T *
>(m_q.
PendNoWait()); };
719 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_q.
PendNoWait(result)); };
722 typedef struct os_fifo_el
725 struct os_fifo_el *pNextFifo_El;
741 bool Claim(
volatile OS_FIFO_EL *&pToRet);
769 uint8_t
Post(OS_FIFO_EL *pToPost);
802 OS_FIFO_EL *
Pend(uint32_t timeoutTicks, uint8_t &result);
834 return Pend(timeoutTicks, unused);
861 TEMPL_FIFO() { m_fifo.
Init(); }
862 uint8_t Init() {
return m_fifo.
Init(); }
863 uint8_t Post(T *item) {
return m_fifo.
Post((OS_FIFO_EL *)item); }
864 uint8_t PostFirst(T *item) {
return m_fifo.
PostFirst((OS_FIFO_EL *)item); };
866 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks, result)); };
868 inline T *Pend(uint32_t timeoutTicks =
WAIT_FOREVER) {
return static_cast<T *
>(m_fifo.
Pend(timeoutTicks)); };
870 inline T *PendNoWait() {
return static_cast<T *
>(m_fifo.
PendNoWait()); };
872 inline T *PendNoWait(uint8_t &result) {
return static_cast<T *
>(m_fifo.
PendNoWait(result)); };
884 class BufferCriticalLock;
885 class fifo_buffer_storage;
895 OS_TCB *OSCritOwnerTCB;
896 uint32_t OSCritDepthCount;
994 friend class BufferCriticalLock;
995 friend class fifo_buffer_storage;
1001 } __attribute__((packed));
1003 struct OS_FLAGS_WAIT;
1012 vuint32_t m_current_flags;
1013 void *m_pWaitinglist;
1015 void AddOFW(OS_FLAGS_WAIT *ofw);
1016 void RemoveOFW(OS_FLAGS_WAIT *ofw);
1037 void Set(uint32_t bits_to_set);
1047 void Clear(uint32_t bits_to_clr);
1062 uint8_t
PendAny(uint32_t bit_mask, uint16_t timeout);
1091 uint8_t
PendAll(uint32_t bit_mask, uint16_t timeout);
1122 [[deprecated]]
inline void OSFlagCreate(
OS_FLAGS *pf)
1139 flags->
Set(bits_to_set);
1154 flags->
Clear(bits_to_clr);
1173 return flags->
PendAny(bit_mask, timeout);
1210 return flags->
PendAll(bit_mask, timeout);
1244 return flags->
State();
1253 extern volatile OS_TCB *OSTCBPrioTbl[OS_MAX_PRIOS];
1256 extern volatile task_bit_list OSTaskReadyList;
1257 #ifdef NBRTOS_PRIO_PROMOTION 1258 extern volatile task_bit_list OSInUsePrioList FAST_SYS_VAR;
1259 extern volatile task_bit_list OSActivePrioList FAST_SYS_VAR;
1262 extern OS_TCB OSTCBTbl[OS_MAX_TASKS];
1264 extern OS_TCB *pOSActiveTCBList;
1267 extern volatile uint32_t nPrioOfCurTask;
1268 extern volatile uint32_t nPrioOfHighReady;
1269 extern volatile OS_TCB *OSTCBCur;
1270 extern volatile OS_TCB *OSTCBHighRdy;
1272 extern OS_TCB *pOSTCBFreeList;
1274 extern volatile uint32_t OSIntNesting;
1275 extern volatile uint32_t OSLockNesting;
1276 extern volatile uint32_t OSISRLevel32;
1278 extern volatile bool OSRunning;
1281 extern unsigned long OSTcbStructSize;
1283 #ifdef NBRTOS_TASK_LOG 1284 extern void (*pTaskLogger)(uint8_t nextPrio);
1296 void OSInit(uint8_t maxtasks);
1298 void OSCreateIdleTask();
1346 #define OSSimpleTaskCreatewName(x, p, n) \ 1348 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))); \ 1349 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \ 1351 #define OSSimpleTaskCreatewNameSRAM(x, p, n) \ 1353 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))) FAST_USER_STK; \ 1354 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \ 1357 void OSTimeWaitUntil(uint32_t to_when);
1370 uint32_t to_when = to_count + TimeTick;
1371 if (!to_when) to_when++;
1372 OSTimeWaitUntil(to_when);
1379 void OSIntExit(
void);
1381 void OSTickISR(
void);
1382 void OSStartHighRdy(
void);
1383 void OSSetupVBR(
void);
1385 void OSTimeTick(
void);
1401 OS_TCB *OSTCBGetFree(
void);
1424 void OSSetName(
const char *cp);
1468 return (psem !=
nullptr) ? psem->
Init(value) : OS_CRIT_ERR;
1487 return psem->
Post();
1507 return psem->
Pend(timeout);
1544 return (pmbox !=
nullptr) ? pmbox->
Init(msg) : OS_CRIT_ERR;
1563 return pmbox->
Post(msg);
1580 return pmbox->
Pend(timeout, *err);
1614 [[deprecated]]
inline uint8_t
OSQInit(
OS_Q *pq,
void **start, uint8_t size)
1616 return (pq !=
nullptr) ? pq->
Init(start, size) : OS_CRIT_ERR;
1635 return pq->
Post(msg);
1711 [[deprecated]]
inline void *
OSQPend(
OS_Q *pq, uint16_t timeout, uint8_t *err)
1713 return pq->
Pend(timeout, *err);
1747 return (pFifo !=
nullptr) ? pFifo->
Init() : OS_CRIT_ERR;
1765 return pFifo->
Post(pToPost);
1798 return pFifo->
Pend(timeout);
1831 return pCrit->
Init();
1833 [[deprecated]]
inline uint8_t OSCritLockAndEnter(
OS_CRIT *pCrit, uint16_t timeout)
1854 return pCrit->
Enter(timeout);
1890 return pCrit->
Leave();
1892 [[deprecated]]
inline uint8_t OSCritLeaveAndUnlock(
OS_CRIT *pCrit)
1900 uint8_t OSTaskID(
void);
1905 const char *OSTaskName();
1907 void OSChangeTaskWhen(uint16_t task_prio, uint32_t to_when);
1923 uint32_t to_when = to_count + TimeTick;
1924 if (!to_when) to_when++;
1925 OSChangeTaskWhen(task_prio, to_when);
1928 void OSDumpStack(
void);
1930 #if (defined NBRTOS_STACKOVERFLOW) || (defined NBRTOS_STACKUNDERFLOW) 1931 void EnableOSStackProtector();
1932 extern "C" void OSStackProtectCtxSw();
1933 extern "C" void OSStackProtector();
1936 #ifdef NBRTOS_STACKCHECK 1954 #ifdef NBRTOS_TASKLIST 1964 uint32_t GetCurrentTaskTime(uint32_t *
const TotalTicks);
1965 void ShowTaskTimes(
void);
1966 void ClearTaskTimes(
void);
1993 } __attribute__((packed));
2028 } __attribute__((packed));
2105 USERCritObj() { USER_ENTER_CRITICAL(); }
2106 ~USERCritObj() { USER_EXIT_CRITICAL(); }
uint8_t LockAndEnter(uint32_t timeoutTicks=WAIT_FOREVER)
Locks the current task to prevent task switching, and claims a critical section.
Definition: nbrtos.cpp:1388
OS_MBOX(void *msg)
Create and initialize a mailbox object with a given message.
Definition: nbrtos.h:409
#define OS_TIMEOUT
Timeout.
Definition: nbrtos.h:59
A FIFO is used to pass structures from one task to another. Note: Structures to be passed must have a...
Definition: nbrtos.h:736
uint8_t Init(int32_t cnt=0)
This function is used to initialize a semaphore structure. Note: This must be done before using a sem...
Definition: nbrtos.cpp:805
OS_FIFO_EL * PendNoWait(uint8_t &result)
Checks to see if a structure has been posted to a FIFO, but does not wait.
Definition: nbrtos.cpp:1294
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:1171
uint8_t PendAll(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/source/nbrtosflags.cpp:157
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:1652
uint8_t Leave()
This function releases the critical section.
Definition: nbrtos.cpp:1459
void OSTaskDelete(void)
This function deletes the current calling task, but we do not recommend the use of this function beca...
Definition: nbrtos.cpp:772
uint8_t PostUniqueFirst(void *msg)
This function checks to see if a message already exists in a queue, and if it doesn't, it then posts it at the head of the queue. Note: Any higher priority task waiting on this queue will be started.
Definition: nbrtos.cpp:1173
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:1673
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.
Definition: nbrtos.h:2077
uint8_t PendAllNoWait(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/source/nbrtosflags.cpp:179
OS_CRIT()
Create and initialize an OS_CRIT object.
Definition: nbrtos.h:903
Semaphores are used to control access to shared resource critical section, or to communicate between ...
Definition: nbrtos.h:318
uint8_t Init(void **pQueueStorage, uint8_t size)
Sets the queue object to its initial state.
Definition: nbrtos.cpp:1031
TickTimeouts are used to facilitate sequential function calls with timeout parameters that need to in...
Definition: nbrtos.h:112
void * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait timeout ticks for another task to post to the queue. Note: A timeout value of 0 (zero) waits for...
Definition: nbrtos.cpp:1070
A queue functions as a fixed size FIFO for communication between tasks.
Definition: nbrtos.h:531
uint8_t Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait timeout ticks for the value of the semaphore to be non zero. Note: A timeout value of 0 (zero) w...
Definition: nbrtos.cpp:845
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:1137
#define WAIT_FOREVER
Definition: nbrtos.h:71
A simple wrapper class that helps use OS locks effectively.
Definition: nbrtos.h:1981
OS_FLAGS()
Create and initialize an OS_FLAG object.
Definition: nbrtos/source/nbrtosflags.cpp:87
void ShowTaskList(void)
This functions dumps the current RTOS task states to stdio.
Definition: nbrtos.cpp:74
OS_FIFO_EL * PendNoWait()
Checks to see if a structure has been posted to a FIFO, but does not wait. This is the same as PendNo...
Definition: nbrtos.h:847
uint8_t Init(void *msg=NULL)
Sets the mailbox object to its initial state.
Definition: nbrtos.cpp:915
OS_FIFO_EL * Pend(uint32_t timeoutTicks, uint8_t &result)
This function pends on a FIFO for a specified number of ticks.
Definition: nbrtos.cpp:1254
uint8_t PendNoWait()
Pend on a semaphore with no waiting period.
Definition: nbrtos.cpp:883
uint8_t OSMboxInit(OS_MBOX *pmbox, void *msg)
This function is used to initialize an OS_MBOX structure.
Definition: nbrtos.h:1542
void * PendNoWait()
Checks to see if a message has been posted to a mailbox, but does not wait. This is the same as PendN...
Definition: nbrtos.h:500
void OSLock(void)
Calling the OSLock function will prevent the OS from changing tasks.
Definition: nbrtos.cpp:509
TickTimeout(uint32_t timeout)
Create and initialize the Timeout.
Definition: nbrtos.h:145
uint8_t EnterNoWait()
This function tries to enter or claim the critical section. However, this function does not wait if i...
Definition: nbrtos.cpp:1439
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:1152
uint8_t Post(void *pItem)
This function posts a message to a Queue. Note: Any higher priority task waiting on this queue will b...
Definition: nbrtos.cpp:1135
uint8_t OSTaskCreatewName(void(*task)(void *dptr), void *data, void *pstktop, void *pstkbot, uint8_t prio, const char *name)
uint8_t LeaveAndUnlock()
This function unlocks the task and releases the critical section.
Definition: nbrtos.cpp:1452
uint8_t OSCritLeave(OS_CRIT *pCrit)
This function releases the critical section.
Definition: nbrtos.h:1888
OS_MBOX()
Create and initialize a mailbox object.
Definition: nbrtos.h:402
~OSSpinCrit()
Initialize the OSSpinCrit object, and then call Leave() on the OS_CRIT object that is passed in...
Definition: nbrtos.h:2099
uint8_t Post(OS_FIFO_EL *pToPost)
This function posts to a FIFO object.
Definition: nbrtos.cpp:1318
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:1921
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:1694
friend void ForceReboot(bool fromIRQ)
Forces the system hardware to perform a soft reset.
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:1614
uint8_t OSFifoPost(OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
This function posts to a FIFO.
Definition: nbrtos.h:1763
OS_FIFO_EL * OSFifoPend(OS_FIFO *pFifo, uint16_t timeout)
This function pends on a FIFO.
Definition: nbrtos.h:1796
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:1208
~OSLockObj()
Destructs the OSLockObj and calls OSUnlock().
Definition: nbrtos.h:1992
uint32_t val() const
Get the timeout duration to be passed to a function utilizing timeout ticks.
Definition: nbrtos.h:153
OSLockAndCritObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call LockAndEnter() on the OS_CRIT object that i...
Definition: nbrtos.h:2053
void * OSMboxPendNoWait(OS_MBOX *pmbox, uint8_t *err)
OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.
Definition: nbrtos.h:1594
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:1780
uint8_t OSQPost(OS_Q *pq, void *msg)
This function posts a message to a Queue.
Definition: nbrtos.h:1633
void Set(uint32_t bits_to_set)
This function sets the corresponding bits asserted in bits_to_set.
Definition: nbrtos/source/nbrtosflags.cpp:104
uint8_t OSFifoInit(OS_FIFO *pFifo)
Initialize a FIFO, which is used to pass structures from one task to another.
Definition: nbrtos.h:1745
bool expired() const
Determine whether the timeout duration has elapsed.
Definition: nbrtos.h:167
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:1226
uint8_t PostFirst(OS_FIFO_EL *pToPost)
This function is identical to Post(), but the element posted is put on the beginning of the FIFO list...
Definition: nbrtos.cpp:1341
uint8_t OSSemPendNoWait(OS_SEM *psem)
OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.
Definition: nbrtos.h:1523
uint8_t Init()
Initialize an OS_CRIT object to its default state.
Definition: nbrtos.cpp:1378
A simple wrapper class that helps utilize OS_CRIT objects to lock tasks and enter critical sections m...
Definition: nbrtos.h:2042
uint8_t Enter(uint32_t timeoutTicks=WAIT_FOREVER)
This function tries to enter or claim the critical section.
Definition: nbrtos.cpp:1399
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:1485
uint8_t OSChangePrio(uint32_t newp)
This function changes the priority of the calling task.
Definition: nbrtos.cpp:731
void * PendNoWait(uint8_t &result)
Checks to see if a message has been posted to a queue, but does not wait. An err holds the error code...
Definition: nbrtos.cpp:1111
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:1242
uint8_t PostFirst(void *pItem)
This function posts a message like OSQPost, but posts the message at the head of the queue...
Definition: nbrtos.cpp:1198
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:1505
void * PendNoWait()
Checks to see if a message has been posted to a queue, but does not wait. This is the same as PendNoW...
Definition: nbrtos.h:691
void Init()
Initialize an OS_FLAG object to its default value.
Definition: nbrtos/source/nbrtosflags.cpp:95
uint8_t PendAnyNoWait(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/source/nbrtosflags.cpp:145
uint8_t PendAny(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/source/nbrtosflags.cpp:126
OS_FIFO()
Create and initialize a FIFO object.
Definition: nbrtos.h:747
void * PendNoWait(uint8_t &result)
Checks to see if a message has been posted to a mailbox, but does not wait.
Definition: nbrtos.cpp:983
uint8_t OSCritEnterNoWait(OS_CRIT *pCrit)
This function tries to enter or claim the critical section.
Definition: nbrtos.h:1870
~OSCriticalSectionObj()
Destructs the OSCriticalSectionObj object, and call Leave() on the OS_CRIT object that was passed int...
Definition: nbrtos.h:2027
OS_FIFO_EL * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
This function pends on a FIFO for a specified number of ticks. This is the same as Pend(uint32_t time...
Definition: nbrtos.h:831
uint8_t Post(void *msg)
This function posts a message to the mailbox.
Definition: nbrtos.cpp:1008
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition: nbrtos.h:893
#define NULL
Definition: nm_bsp.h:76
uint8_t Post()
This function increases the value of the semaphore by one. Note: If any higher priority tasks were wa...
Definition: nbrtos.cpp:903
OS_Q(void **pQueueStorage, uint8_t size)
Create and initialize a queue object.
Definition: nbrtos.h:554
void Clear(uint32_t bits_to_clr)
This function clears the bits asserted in bits_to_clr.
Definition: nbrtos/source/nbrtosflags.cpp:112
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:1578
A simple wrapper class that helps utilize OS_CRIT objects more effectively.
Definition: nbrtos.h:2006
void * OSQPendNoWait(OS_Q *pq, uint8_t *err)
OSQPendNoWait() is identical to the OSQPend() function but it does not wait.
Definition: nbrtos.h:1727
void OSUnlock(void)
This function unlocks the OS.
Definition: nbrtos.cpp:524
OSSpinCrit(OS_CRIT &ocrit)
Initialize the OSSpinCrit object, and then call EnterNoWait() repeatedly on the OS_CRIT object that i...
Definition: nbrtos.h:2088
uint32_t State()
This function returns the current values of the flags stored in the OS_FLAGS object structure...
Definition: nbrtos/source/nbrtosflags.cpp:187
void OSDumpTasks(void)
This function dumps the state and call stack for every task to stdout. This function is useful for de...
Mailboxes are used to communicate between tasks.
Definition: nbrtos.h:391
OS_FIFO_EL * OSFifoPendNoWait(OS_FIFO *pFifo)
This function is identical to the OSFifoPen() function, but it does not wait.
Definition: nbrtos.h:1811
OSCriticalSectionObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call Enter() on the OS_CRIT object that is passe...
Definition: nbrtos.h:2017
An OS_FLAGS object is used to set, clear, and pend on a set of flags that is held and maintained by t...
Definition: nbrtos.h:1009
void * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait timeout ticks for some other task to post to the mailbox. Note: Pend will wait forever if 0 is p...
Definition: nbrtos.cpp:943
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:1368
~OSLockAndCritObj()
Initialize the OSCriticalSectionObj object, and then call LeaveAndUnlock() on the OS_CRIT object that...
Definition: nbrtos.h:2061
uint8_t OSCritInit(OS_CRIT *pCrit)
This function initializes the critical section.
Definition: nbrtos.h:1829
uint8_t OSMboxPost(OS_MBOX *pmbox, void *msg)
This function posts a message to a Mail box.
Definition: nbrtos.h:1561
void OSDumpTCBStacks(void)
This function dumps information about the UCOS stacks and tasks to stdout. This function is useful fo...
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:1189
OSLockObj()
Initialize the OSLockObj and calls OSLock().
Definition: nbrtos.h:1987
void * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait timeout ticks for some other task to post to the mailbox. This is the same as Pend(uint32_t time...
Definition: nbrtos.h:482
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:1711
uint8_t OSSemInit(OS_SEM *psem, long value)
Initializes a semaphore.
Definition: nbrtos.h:1466
uint8_t PostUnique(void *pItem)
This function checks to see if a message already exists in a queue, and if it doesn't, it then posts it. Note: Any higher priority task waiting on this queue will be started.
Definition: nbrtos.cpp:1154
OS_Q()
Create and initialize a queue object.
Definition: nbrtos.h:546
void * Pend(uint32_t timeoutTicks=WAIT_FOREVER)
Wait timeout ticks for another task to post to the queue. This is the same as Pend(uint32_t timeoutTi...
Definition: nbrtos.h:675
uint8_t OSCritEnter(OS_CRIT *pCrit, uint16_t timeout)
This function tries to enter or claim the critical section.
Definition: nbrtos.h:1852
uint8_t Init()
Sets the FIFO object to its initial state.
Definition: nbrtos.cpp:1238
OS_SEM(int32_t cnt=0)
Create and initialize a semaphore.
Definition: nbrtos.h:332