NetBurner 3.3.9
PDF Version
nbrtos.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
16#ifndef _NBRTOS_H
17#define _NBRTOS_H
18
19// NB Definitions
20#include <predef.h>
21
22// NB Constants
23#include <constants.h>
24
25// NB Libs
26#include <basictypes.h>
27#include <nbrtoscpu.h>
28#include <predef.h>
29
30/***********************************************************
31 * NBRTOS.H
32 * SYSTEM DECLARATIONS
33 ***********************************************************
34 */
35#define OS_LO_PRIO 63 /*IDLE task priority */
36
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
58#define OS_NO_ERR 0
59#define OS_TIMEOUT 10
60#define OS_MBOX_FULL 20
61#define OS_Q_FULL 30
62#define OS_Q_EXISTS 31
63#define OS_PRIO_EXIST 40
64#define OS_PRIO_INVALID 41
65#define OS_SEM_ERR 50
66#define OS_SEM_OVF 51
67#define OS_CRIT_ERR 60
68#define OS_NO_MORE_TCB 70 // No TCBs free to create task
71#define WAIT_FOREVER 0
73typedef volatile uint32_t tick_t;
74
76// GLOBAL VARIABLES
77//
78extern vuint32_t Secs; // Number of seconds since system start
79extern volatile tick_t TimeTick; // Number of time ticks since system start
80
81// Is test_time later than now (TimeTick)
82inline bool IsTickLater(uint32_t test_time)
83{
84 return ((int)(TimeTick - test_time) < 0);
85}
86
87// Is test_time NoworEarlier than TimeTick
88inline bool IsTickNowOrEarlier(uint32_t test_time)
89{
90 return ((int)(TimeTick - test_time) >= 0);
91}
92
93// Compare two timetick values
94inline bool Is2ndTickEarlier(uint32_t t1, uint32_t t2)
95{
96 return (((int)(t1 - t2)) > 0);
97}
98
99class TickTimeout;
100struct RawTickTimeout_t
101{
102 tick_t expiration;
103
104 inline bool expired() const { return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
105 inline bool expired() volatile { return expiration ? (((int)(expiration - TimeTick)) <= 0) : false; }
106 inline operator bool() const { return !expired(); }
107 const RawTickTimeout_t &operator=(const TickTimeout &rhs);
108 volatile RawTickTimeout_t &operator=(const TickTimeout &rhs) volatile;
109
110 inline tick_t operator-(const tick_t &tick) { return expiration - tick; }
111 inline tick_t operator-(const tick_t &tick) const { return expiration - tick; }
112 inline tick_t operator-(const tick_t &tick) volatile { return expiration - tick; }
113};
114
115inline bool operator==(const RawTickTimeout_t &lhs, const int &rhs)
116{
117 return lhs.expiration == (tick_t)rhs;
118}
119inline bool operator==(const volatile RawTickTimeout_t &lhs, const int &rhs)
120{
121 return lhs.expiration == (tick_t)rhs;
122}
123
131{
132 RawTickTimeout_t raw;
133
134 void set(uint32_t timeout)
135 {
136 if (!timeout) { raw.expiration = 0; }
137 else
138 {
139 raw.expiration = TimeTick + (timeout & 0x7FFFFFFF);
140 // A 1 tick delay extension is introduced on TimeTick overflow
141 // in order to allow for infinite delays to be indicated with an
142 // expiration of zero
143 if (timeout && !raw.expiration) { raw.expiration = 1; }
144 }
145 }
146
147 public:
148 class uint32_nonboolean_t
149 {
150 uint32_t value;
151
152 public:
153 uint32_nonboolean_t(uint32_t val) : value(val) {}
154 inline explicit operator bool() { return (bool)value; }
155 inline operator uint32_t() { return value; }
156 };
157 explicit TickTimeout() { set(0); }
163 explicit TickTimeout(uint32_t timeout) { set(timeout); }
164
171 inline uint32_t val() const
172 {
173 if (!raw.expiration) { return raw.expiration; }
174 int ret = raw.expiration - TimeTick;
175 // Prevent passing an infinite or otherwise bogus timeout in a tick race
176 return (ret > 0) ? ret : 1;
177 }
178
185 inline bool expired() const { return raw.expired(); }
186
197 inline operator bool() const { return !expired(); }
198
199 inline operator uint32_t() const { return val(); }
200 inline operator uint16_t() const
201 {
202 uint32_t ret = val();
203 return ret > 0xFFFF ? 0xFFFE : ret;
204 }
205
206 inline TickTimeout &operator=(const TickTimeout &rhs)
207 {
208 raw.expiration = rhs.raw.expiration;
209 return *this;
210 }
211 inline TickTimeout &operator=(uint32_t val)
212 {
213 set(val);
214 return *this;
215 }
216 inline void SetUntil(uint32_t when) {raw.expiration = when; }
217 friend void OSTimeWaitUntil(uint32_t systemTickValue);
218 friend class RawTickTimeout_t;
219};
220
221inline const RawTickTimeout_t &RawTickTimeout_t::operator=(const TickTimeout &rhs)
222{
223 expiration = rhs.raw.expiration;
224 return *this;
225}
226inline volatile RawTickTimeout_t &RawTickTimeout_t::operator=(const TickTimeout &rhs) volatile
227{
228 expiration = rhs.raw.expiration;
229 return *this;
230}
231
232// The following class holds a list of tasks...
233
234class task_bit_list
235{
236 public:
237 volatile uint32_t OSTbl[TASK_TABLE_SIZE];
238
239 // task_bit_list();
240 void Init() volatile;
241 void Copy(volatile task_bit_list &rhs)
242 {
243 for (int i = 0; i < TASK_TABLE_SIZE; i++)
244 {
245 OSTbl[i] = rhs.OSTbl[i];
246 }
247 }
248
249 // The following functions are all guaranteed to be atomic
250 void set(int set_num) volatile;
251 void clr(int clr_num) volatile;
252
253 // The following functions return 0 if no bits are set.
254 uint32_t gethigh() volatile;
255 uint32_t get_high_and_clear() volatile;
256
257 inline bool isSet(int num) volatile const { return (OSTbl[num / 32] & (0x80000000 >> (num % 32))); }
258};
259
260class OS_TCB;
261
262// The common element of all the task objects...
263class OS_TASK_DLY_OBJ
264{
265 task_bit_list tasks_waiting;
266
267 public:
268 OS_TASK_DLY_OBJ();
269 void Init();
270
271 // Returns true if woken up, returns false if timed out
272 bool Wait_when(uint8_t StatReason, TickTimeout &timeout);
273
274 inline bool Wait(uint8_t StatReason, uint32_t to_count)
275 {
276 TickTimeout to_when(to_count);
277 return Wait_when(StatReason, to_when);
278 }
279
280 // This releases the highest priority task waiting on this object.
281 void MakeHighTaskWaitingReady(uint8_t StatReason);
282 friend class OS_TCB;
283} __attribute__((packed));
284
285// class OS_TCB;//forward
286
287class OS_TCB : public cpu_tcb
288{
289 public:
290 uint8_t OSTCBStat; // Holds the current status of the TCB
291 uint8_t OSTCBResult; // Basically holds the timeout or not flag when woken.
292 uint8_t OSTCBPrio; // Index to prio table.... not sure if we need to keep this.
293 uint8_t pad; // Make 32 bit aligned.
294
295 RawTickTimeout_t OSTCBDly_when; // When to release timeout the task, 0= never.
296
297 const char *pOSTCBName;
298 OS_TCB *OSTCBNext;
299 OS_TCB *OSTCBPrev;
300
301#ifdef NBRTOS_PRIO_PROMOTION
302 // These pointers are for handling Priority Promotion when OS_CRITs create
303 // an inversion situation
304 volatile OS_TCB *pPromotedTo;
305 volatile OS_TCB *pDisplacedBy;
306 OS_TASK_DLY_OBJ *pWaiting;
307 uint32_t displacedByOrigPrio;
308
309 void PromoteToCurPrio() volatile;
310 void Demote() volatile;
311#endif
312
313 static volatile OS_TCB *GetCur();
314
315#ifdef NBRTOS_TIME
316 unsigned long switchTimeTick;
317 unsigned long switchTimeFraction;
318 unsigned long runningTime;
319 unsigned long runningTimeFraction;
320#endif
321 // OS_TCB(); //Zero everything
322 void Init();
323
324 // Set up TCB assuming that the STACK has already been setup and properly initalized.
325 bool Init(uint8_t prio, void *pActualTop, void *pstk, long *pbot, const char *name);
326};
327
328/* Forward Declaration */
329struct OS_CRIT;
330
336struct OS_SEM : public OS_TASK_DLY_OBJ
337{
338 volatile uint32_t OSSemCnt;
339 volatile uint32_t OSSemUsed;
340
341 private:
342 bool Claim();
343
344 public:
350 inline OS_SEM(int32_t cnt = 0) : OS_TASK_DLY_OBJ() { Init(cnt); }
351
363 uint8_t Init(int32_t cnt = 0);
364
374 uint8_t Post();
375
389 inline uint8_t Pend(uint32_t timeoutTicks = WAIT_FOREVER){TickTimeout tt(timeoutTicks); return Pend(tt);};
390 inline uint8_t PendUntil(uint32_t timeout_time){TickTimeout tt(0); tt.SetUntil(timeout_time); return Pend(tt);};
391 uint8_t Pend(TickTimeout &t);
392
404 uint8_t PendNoWait();
405
406 inline uint32_t Avail() { uint32_t v; USER_ENTER_CRITICAL(); v=OSSemCnt-OSSemUsed; USER_EXIT_CRITICAL(); return v;};
407} __attribute__((packed));
408
413struct OS_MBOX : public OS_TASK_DLY_OBJ
414{
415 void *OSMboxMsg;
416 bool OSMboxDataAvail;
417
418 bool Claim(void *&Result);
419
420 public:
424 inline OS_MBOX() : OS_TASK_DLY_OBJ() { Init(); }
425
431 inline OS_MBOX(void *msg) : OS_TASK_DLY_OBJ() { Init(msg); }
432
442 uint8_t Init(void *msg = NULL);
443
454 uint8_t Post(void *msg);
455
472 inline void *Pend(uint32_t timeoutTicks, uint8_t &result){TickTimeout tt(timeoutTicks); return Pend(tt,result);};
473 inline void *PendUntil(uint32_t timeoutTime, uint8_t &result){TickTimeout tt(0); tt.SetUntil(timeoutTime); return Pend(tt,result);};
474 void *Pend(TickTimeout &t, uint8_t &result);
475
490 void *PendNoWait(uint8_t &result);
491
506 inline void *Pend(uint32_t timeoutTicks = WAIT_FOREVER)
507 {
508 uint8_t unused;
509 return Pend(timeoutTicks, unused);
510 };
511
524 inline void *PendNoWait()
525 {
526 uint8_t unused;
527 return PendNoWait(unused);
528 };
529};
530
531template<typename T>
532class TEMPL_MBOX
533{
534 protected:
535 OS_MBOX m_mbox;
536
537 public:
538 TEMPL_MBOX(const T *msg) : m_mbox((void *)msg) {}
539 inline uint8_t Init(const T *msg) { return m_mbox.Init((void *)msg); }
540 inline uint8_t Post(const T *msg) { return m_mbox.Post((void *)msg); }
541
542 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) { return static_cast<T *>(m_mbox.Pend(timeoutTicks, result)); };
543
544 inline T *PendNoWait(uint8_t &result) { return static_cast<T *>(m_mbox.PendNoWait(result)); };
545
546 inline T *Pend(uint32_t timeoutTicks = WAIT_FOREVER) { return static_cast<T *>(m_mbox.Pend(timeoutTicks)); };
547
548 inline T *PendNoWait() { return static_cast<T *>(m_mbox.PendNoWait()); };
549};
550
555struct OS_Q : public OS_TASK_DLY_OBJ
556{
557 void **OSQStart;
558 void **OSQEnd;
559 void **OSQIn;
560 void **OSQOut;
561 uint8_t OSQSize;
562 uint8_t OSQEntries;
563
564 bool Claim(void *&Result);
565
566 public:
573 inline OS_Q(void **pQueueStorage, uint8_t size) : OS_TASK_DLY_OBJ() { Init(pQueueStorage, size); }
574
585 uint8_t Init(void **pQueueStorage, uint8_t size);
586
600 uint8_t Post(void *pItem);
601
615 uint8_t PostFirst(void *pItem);
616
631 uint8_t PostUnique(void *pItem);
632
648 uint8_t PostUniqueFirst(void *msg);
649
664 inline void *Pend(uint32_t timeoutTicks, uint8_t &result){TickTimeout tt(timeoutTicks); return Pend(tt,result);};
665 inline void *PendUntil(uint32_t timeoutTime, uint8_t &result){TickTimeout tt(0); tt.SetUntil(timeoutTime); return Pend(tt,result);};
666 void *Pend(TickTimeout &t, uint8_t &result);
667
668
669
683 void *PendNoWait(uint8_t &result);
684
698 inline void *Pend(uint32_t timeoutTicks = WAIT_FOREVER)
699 {
700 uint8_t unused;
701 return Pend(timeoutTicks, unused);
702 };
703
714 inline void *PendNoWait()
715 {
716 uint8_t unused;
717 return PendNoWait(unused);
718 };
719};
720
721template<typename T>
722struct TEMPL_Q
723{
724 protected:
725 OS_Q m_q;
726
727 public:
728 TEMPL_Q() {}
729 TEMPL_Q(T **pQueueStorage, uint8_t size) { m_q.Init((void **)pQueueStorage, size); }
730 uint8_t Init(T **pQueueStorage, uint8_t size) { return m_q.Init((void **)pQueueStorage, size); }
731 uint8_t Post(T *item) { return m_q.Post((void *)item); }
732 uint8_t PostFirst(T *item) { return m_q.PostFirst((void *)item); };
733 uint8_t PostUnique(T *item) { return m_q.PostUnique((void *)item); };
734 uint8_t PostUniqueFirst(T *item) { return m_q.PostUniqueFirst((void *)item); };
735
736 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) { return static_cast<T *>(m_q.Pend(timeoutTicks, result)); };
737
738 inline T *Pend(uint32_t timeoutTicks = WAIT_FOREVER) { return static_cast<T *>(m_q.Pend(timeoutTicks)); };
739
740 inline T *PendNoWait() { return static_cast<T *>(m_q.PendNoWait()); };
741
742 inline T *PendNoWait(uint8_t &result) { return static_cast<T *>(m_q.PendNoWait(result)); };
743};
744
745typedef struct os_fifo_el
746{
747 union
748 {
749 struct os_fifo_el *pNextFifo_El;
750 puint8_t pAsBytePtr;
751 };
752} OS_FIFO_EL;
753
760struct OS_FIFO : public OS_TASK_DLY_OBJ
761{
762 OS_FIFO_EL *pHead;
763 OS_FIFO_EL *pTail;
764
765 bool Claim(volatile OS_FIFO_EL *&pToRet);
766
767 public:
771 inline OS_FIFO() : OS_TASK_DLY_OBJ() { Init(); }
772
780 uint8_t Init();
781
793 uint8_t Post(OS_FIFO_EL *pToPost);
794
810 uint8_t PostFirst(OS_FIFO_EL *pToPost);
811
826 inline OS_FIFO_EL *Pend(uint32_t timeoutTicks, uint8_t &result){TickTimeout tt(timeoutTicks); return Pend(tt,result);};
827 inline OS_FIFO_EL *PendUntil(uint32_t timeoutTime, uint8_t &result){TickTimeout tt(0); tt.SetUntil(timeoutTime); return Pend(tt,result);};
828 OS_FIFO_EL *Pend(TickTimeout &t, uint8_t &result);
829
830
831
832
833
847 OS_FIFO_EL *PendNoWait(uint8_t &result);
848
861 inline OS_FIFO_EL *Pend(uint32_t timeoutTicks = WAIT_FOREVER)
862 {
863 uint8_t unused;
864 return Pend(timeoutTicks, unused);
865 };
866
877 inline OS_FIFO_EL *PendNoWait()
878 {
879 uint8_t unused;
880 return PendNoWait(unused);
881 };
882};
883
884template<typename T>
885struct TEMPL_FIFO
886{
887 protected:
888 OS_FIFO m_fifo;
889
890 public:
891 TEMPL_FIFO() { m_fifo.Init(); }
892 uint8_t Init() { return m_fifo.Init(); }
893 uint8_t Post(T *item) { return m_fifo.Post((OS_FIFO_EL *)item); }
894 uint8_t PostFirst(T *item) { return m_fifo.PostFirst((OS_FIFO_EL *)item); };
895
896 inline T *Pend(uint32_t timeoutTicks, uint8_t &result) { return static_cast<T *>(m_fifo.Pend(timeoutTicks, result)); };
897
898 inline T *Pend(uint32_t timeoutTicks = WAIT_FOREVER) { return static_cast<T *>(m_fifo.Pend(timeoutTicks)); };
899
900 inline T *PendNoWait() { return static_cast<T *>(m_fifo.PendNoWait()); };
901
902 inline T *PendNoWait(uint8_t &result) { return static_cast<T *>(m_fifo.PendNoWait(result)); };
903
904 inline OS_FIFO *GetRawFIFO() { return &m_fifo; }
905};
906
907/*
908 ***********************************************************
909 * Critical Section DATA STRUCTURES
910 *
911 * Added by PTB 5/09/99
912 * Modified by DEC 3/21/16
913 ***********************************************************
914 */
915
916class BufferCriticalLock;
917class fifo_buffer_storage;
918
925struct OS_CRIT : public OS_TASK_DLY_OBJ
926{
927 OS_TCB *OSCritOwnerTCB;
928 uint32_t OSCritDepthCount;
929 bool Claim();
930
931 public:
935 OS_CRIT() { Init(); }
936
944 uint8_t Init();
945
963 uint8_t LockAndEnter(uint32_t timeoutTicks = WAIT_FOREVER);
964
981 uint8_t Enter(uint32_t timeoutTicks = WAIT_FOREVER);
982
997 uint8_t EnterNoWait();
998
1012 uint8_t Leave();
1013
1025 uint8_t LeaveAndUnlock();
1026 friend class BufferCriticalLock;
1027 friend class fifo_buffer_storage;
1028
1029 bool UsedFromISR() { return OSCritOwnerTCB == (OS_TCB *)0xFFFFFFFF; }
1030 void SetUseFromISR(bool enableFromISR)
1031 {
1032 if (enableFromISR) { OSCritOwnerTCB = (OS_TCB *)0xFFFFFFFF; }
1033 else if (UsedFromISR())
1034 {
1035 OSCritOwnerTCB = NULL;
1036 }
1037 }
1038 bool OwnedByCurTask();
1039 uint32_t CurDepth() { return OSCritDepthCount; }
1043 friend void ForceReboot(bool fromIRQ);
1044} __attribute__((packed));
1045
1046struct OS_FLAGS_WAIT;
1047
1053{
1054 protected:
1055 vuint32_t m_current_flags;
1056 void *m_pWaitinglist;
1057 void TestFlags();
1058 void AddOFW(OS_FLAGS_WAIT *ofw);
1059 void RemoveOFW(OS_FLAGS_WAIT *ofw);
1060
1061 public:
1065 OS_FLAGS();
1066
1070 void Init();
1071
1080 void Set(uint32_t bits_to_set);
1081
1090 void Clear(uint32_t bits_to_clr);
1091
1092
1102 void Write(uint32_t bits_to_force);
1103
1104
1118 uint8_t PendAny(uint32_t bit_mask, uint16_t timeout = WAIT_FOREVER){TickTimeout tt(timeout); return PendAny(bit_mask,tt);}
1119 uint8_t PendAnyUntil(uint32_t bit_mask, uint32_t end_time){TickTimeout tt(0); tt.SetUntil(end_time); return PendAny(bit_mask,tt);}
1120 uint8_t PendAny(uint32_t bit_mask,TickTimeout & timeout);
1121
1134 uint8_t PendAnyNoWait(uint32_t bit_mask);
1135
1149 uint8_t PendAll(uint32_t bit_mask, uint16_t timeout = WAIT_FOREVER){TickTimeout tt(timeout); return PendAll(bit_mask,tt);}
1150 uint8_t PendAllUntil(uint32_t bit_mask, uint32_t end_time){TickTimeout tt(0); tt.SetUntil(end_time); return PendAll(bit_mask,tt);}
1151 uint8_t PendAll(uint32_t bit_mask,TickTimeout & timeout);
1152
1153
1166 uint8_t PendAllNoWait(uint32_t bit_mask);
1167
1177 uint32_t State();
1178};
1179
1180/* Create and initialize an OS flags object
1181This function must be called before you use an OS_FLAGS object.
1182*/
1183[[deprecated]] inline void OSFlagCreate(OS_FLAGS *pf)
1184{
1185 pf->Init();
1186};
1187
1198[[deprecated]] inline void OSFlagSet(OS_FLAGS *flags, uint32_t bits_to_set)
1199{
1200 flags->Set(bits_to_set);
1201};
1202
1213[[deprecated]] inline void OSFlagClear(OS_FLAGS *flags, uint32_t bits_to_clr)
1214{
1215 flags->Clear(bits_to_clr);
1216};
1217
1232[[deprecated]] inline uint8_t OSFlagPendAny(OS_FLAGS *flags, uint32_t bit_mask, uint16_t timeout)
1233{
1234 return flags->PendAny(bit_mask, timeout);
1235};
1236
1250[[deprecated]] inline uint8_t OSFlagPendAnyNoWait(OS_FLAGS *flags, uint32_t bit_mask)
1251{
1252 return flags->PendAnyNoWait(bit_mask);
1253};
1254
1269[[deprecated]] inline uint8_t OSFlagPendAll(OS_FLAGS *flags, uint32_t bit_mask, uint16_t timeout)
1270{
1271 return flags->PendAll(bit_mask, timeout);
1272};
1273
1287[[deprecated]] inline uint8_t OSFlagPendAllNoWait(OS_FLAGS *flags, uint32_t bit_mask)
1288{
1289 return flags->PendAllNoWait(bit_mask);
1290};
1291
1303[[deprecated]] inline uint32_t OSFlagState(OS_FLAGS *flags)
1304{
1305 return flags->State();
1306};
1307
1308/*
1309 ***********************************************************
1310 * NBRTOS GLOBAL VARIABLES
1311 ***********************************************************
1312 */
1313// Pointers to each of the OS_TCB structure sorted by priority
1314extern volatile OS_TCB *OSTCBPrioTbl[OS_MAX_PRIOS];
1315
1316// taks bits for what tasks are ready to run
1317extern volatile task_bit_list OSTaskReadyList;
1318#ifdef NBRTOS_PRIO_PROMOTION
1319extern volatile task_bit_list OSInUsePrioList FAST_SYS_VAR;
1320extern volatile task_bit_list OSActivePrioList FAST_SYS_VAR;
1321#endif
1322
1323extern OS_TCB OSTCBTbl[OS_MAX_TASKS]; // All the possible TCB's
1324
1325extern OS_TCB *pOSActiveTCBList; // Linked list of activ TCB's
1326
1327// One of the following two variables wsill go away....
1328extern volatile uint32_t nPrioOfCurTask; // Current task priority number
1329extern volatile uint32_t nPrioOfHighReady; // highest task ready to run
1330extern volatile OS_TCB *OSTCBCur;
1331extern volatile OS_TCB *OSTCBHighRdy;
1332
1333extern OS_TCB *pOSTCBFreeList; // List of unused TCB's
1334
1335extern volatile uint32_t OSIntNesting;
1336extern volatile uint32_t OSLockNesting;
1337extern volatile uint32_t OSISRLevel32;
1338
1339extern volatile bool OSRunning;
1340
1341// So non-recompilable files can reference the right struct size
1342extern unsigned long OSTcbStructSize;
1343
1344#ifdef NBRTOS_TASK_LOG
1345extern void (*pTaskLogger)(uint8_t nextPrio);
1346#endif
1347/*
1348Removed
1349 extern volatile BOOLEAN OSShowTasksOnLeds;
1350*/
1351
1352/*
1353***********************************************************
1354* NBRTOS FUNCTION PROTOTYPES
1355***********************************************************
1356*/
1357void OSInit(uint8_t maxtasks);
1358void OSStart(void);
1359void OSCreateIdleTask();
1360
1387uint8_t OSTaskCreatewName(void (*task)(void *dptr), // Function to call
1388 void *data, // Data to pass as a parameter
1389 void *pstktop, // Stack top
1390 void *pstkbot, // Stack bottom
1391 uint8_t prio, // current priority
1392 const char *name // task name
1393);
1394
1407#define OSSimpleTaskCreatewName(x, p, n) \
1408 { \
1409 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))); \
1410 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1411 }
1412#define OSSimpleTaskCreatewNameSRAM(x, p, n) \
1413 { \
1414 static uint32_t func_##x_Stk[USER_TASK_STK_SIZE] __attribute__((aligned(4))) FAST_USER_STK; \
1415 OSTaskCreatewName(x, NULL, (void *)&func_##x_Stk[USER_TASK_STK_SIZE], (void *)func_##x_Stk, p, n); \
1416 }
1417
1418/* Helper macro*/
1419#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)
1420
1435#define OSSimpleTaskCreateLambda(p,n,f) LambdaTask2(p,n,[]( void * pv)f,__COUNTER__)
1436
1437
1457void OSTimeWaitUntil(uint32_t to_when);
1458
1468inline void OSTimeDly(uint32_t to_count)
1469{
1470 uint32_t to_when = to_count + TimeTick;
1471 if (!to_when) to_when++;
1472 OSTimeWaitUntil(to_when);
1473};
1474
1475// void OSIntEnter( void );
1476
1477extern "C"
1478{
1479 void OSIntExit(void);
1480 void OSCtxSw(void);
1481 void OSTickISR(void);
1482 void OSStartHighRdy(void);
1483 void OSSetupVBR(void);
1484 void OSSched(void);
1485 void OSTimeTick(void);
1486
1498 void OSTaskDelete(void);
1499}
1500
1501OS_TCB *OSTCBGetFree(void);
1502
1522uint8_t OSChangePrio(uint32_t newp);
1523
1524void OSSetName(const char *cp);
1525
1539void OSLock(void);
1540
1549void OSUnlock(void);
1550
1565[[deprecated]] inline uint8_t OSSemInit(OS_SEM *psem, long value)
1566{
1567 return (psem != nullptr) ? psem->Init(value) : OS_CRIT_ERR;
1568}
1569
1583[[deprecated]] inline uint8_t OSSemPost(OS_SEM *psem)
1584{
1585 return psem->Post();
1586}
1587
1602[[deprecated]] inline uint8_t OSSemPend(OS_SEM *psem, uint16_t timeout)
1603{
1604 return psem->Pend(timeout);
1605}
1606
1619[[deprecated]] inline uint8_t OSSemPendNoWait(OS_SEM *psem)
1620{
1621 return psem->PendNoWait();
1622}
1623
1637[[deprecated]] inline uint8_t OSMboxInit(OS_MBOX *pmbox, void *msg)
1638{
1639 return (pmbox != nullptr) ? pmbox->Init(msg) : OS_CRIT_ERR;
1640}
1641
1655[[deprecated]] inline uint8_t OSMboxPost(OS_MBOX *pmbox, void *msg)
1656{
1657 return pmbox->Post(msg);
1658}
1659
1671[[deprecated]] inline void *OSMboxPend(OS_MBOX *pmbox, uint16_t timeout, uint8_t *err)
1672{
1673 return pmbox->Pend(timeout, *err);
1674}
1675
1686[[deprecated]] inline void *OSMboxPendNoWait(OS_MBOX *pmbox, uint8_t *err)
1687{
1688 return pmbox->PendNoWait(*err);
1689}
1690
1705[[deprecated]] inline uint8_t OSQInit(OS_Q *pq, void **start, uint8_t size)
1706{
1707 return (pq != nullptr) ? pq->Init(start, size) : OS_CRIT_ERR;
1708}
1709
1723[[deprecated]] inline uint8_t OSQPost(OS_Q *pq, void *msg)
1724{
1725 return pq->Post(msg);
1726}
1727
1741[[deprecated]] inline uint8_t OSQPostFirst(OS_Q *pq, void *msg)
1742{
1743 return pq->PostFirst(msg);
1744}
1745
1761[[deprecated]] inline uint8_t OSQPostUnique(OS_Q *pq, void *msg)
1762{
1763 return pq->PostUnique(msg);
1764}
1765
1781[[deprecated]] inline uint8_t OSQPostUniqueFirst(OS_Q *pq, void *msg)
1782{
1783 return pq->PostUniqueFirst(msg);
1784}
1785
1797[[deprecated]] inline void *OSQPend(OS_Q *pq, uint16_t timeout, uint8_t *err)
1798{
1799 return pq->Pend(timeout, *err);
1800}
1801
1812[[deprecated]] inline void *OSQPendNoWait(OS_Q *pq, uint8_t *err)
1813{
1814 return pq->PendNoWait(*err);
1815}
1816
1829[[deprecated]] inline uint8_t OSFifoInit(OS_FIFO *pFifo)
1830{
1831 return (pFifo != nullptr) ? pFifo->Init() : OS_CRIT_ERR;
1832}
1833
1846[[deprecated]] inline uint8_t OSFifoPost(OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
1847{
1848 return pFifo->Post(pToPost);
1849}
1862[[deprecated]] inline uint8_t OSFifoPostFirst(OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
1863{
1864 return pFifo->PostFirst(pToPost);
1865};
1866
1877[[deprecated]] inline OS_FIFO_EL *OSFifoPend(OS_FIFO *pFifo, uint16_t timeout)
1878{
1879 return pFifo->Pend(timeout);
1880};
1881
1891[[deprecated]] inline OS_FIFO_EL *OSFifoPendNoWait(OS_FIFO *pFifo)
1892{
1893 return pFifo->PendNoWait();
1894 ;
1895}
1896
1908[[deprecated]] inline uint8_t OSCritInit(OS_CRIT *pCrit)
1909{
1910 return pCrit->Init();
1911}
1912[[deprecated]] inline uint8_t OSCritLockAndEnter(OS_CRIT *pCrit, uint16_t timeout)
1913{
1914 return pCrit->LockAndEnter(timeout);
1915}
1916
1930[[deprecated]] inline uint8_t OSCritEnter(OS_CRIT *pCrit, uint16_t timeout)
1931{
1932 return pCrit->Enter(timeout);
1933}
1934
1947[[deprecated]] inline uint8_t OSCritEnterNoWait(OS_CRIT *pCrit)
1948{
1949 return pCrit->EnterNoWait();
1950}
1951
1964[[deprecated]] inline uint8_t OSCritLeave(OS_CRIT *pCrit)
1965{
1966 return pCrit->Leave();
1967}
1968[[deprecated]] inline uint8_t OSCritLeaveAndUnlock(OS_CRIT *pCrit)
1969{
1970 return pCrit->LeaveAndUnlock();
1971}
1972
1973/*
1974 This function returns the current tasks priority
1975*/
1976uint8_t OSTaskID(void);
1977
1978/*
1979 This function returns the current tasks name
1980*/
1981const char *OSTaskName();
1982
1983void OSChangeTaskWhen(uint16_t task_prio, uint32_t to_when);
1984
1995inline void OSChangeTaskDly(uint16_t task_prio, uint32_t to_count)
1996{
1997 uint32_t to_when = to_count + TimeTick;
1998 if (!to_when) to_when++;
1999 OSChangeTaskWhen(task_prio, to_when);
2000}
2001
2002void OSDumpStack(void);
2003
2004#if (defined NBRTOS_STACKOVERFLOW) || (defined NBRTOS_STACKUNDERFLOW)
2005void EnableOSStackProtector();
2006extern "C" void OSStackProtectCtxSw(); // ASM task switcher
2007extern "C" void OSStackProtectIntCtxSw(); // ASM task switcher
2008extern "C" void OSStackProtector(); // extern because must be called from ASM
2009#endif
2010
2011#ifdef NBRTOS_STACKCHECK
2019
2026void OSDumpTasks(void);
2027#endif
2028
2029#ifdef NBRTOS_TASKLIST
2035void ShowTaskList(void);
2036#endif
2037
2038#ifdef NBRTOS_TIME
2039uint32_t GetCurrentTaskTime(uint32_t *const TotalTicks);
2040void ShowTaskTimes(void);
2041void ClearTaskTimes(void);
2042#endif
2043
2057{
2058 public:
2063
2068} __attribute__((packed));
2069
2082{
2083 OS_CRIT *pcrit;
2084
2085 public:
2093 {
2094 pcrit = &ocrit;
2095 ocrit.Enter(0);
2096 };
2097
2103} __attribute__((packed));
2104
2118{
2119 OS_CRIT *pcrit;
2120
2121 public:
2128 OSLockAndCritObj(OS_CRIT &ocrit) : pcrit(&ocrit) { pcrit->LockAndEnter(0); }
2129
2135};
2136
2151{
2152 OS_CRIT *pcrit;
2153
2154 public:
2161 OSSpinCrit(OS_CRIT &ocrit) : pcrit(&ocrit)
2162 {
2163 while (pcrit->EnterNoWait() == OS_TIMEOUT) {}
2164 }
2165
2170 ~OSSpinCrit() { pcrit->Leave(); }
2171};
2172
2173class USERCritObj
2174{
2175 public:
2176 USERCritObj() { USER_ENTER_CRITICAL(); }
2177 ~USERCritObj() { USER_EXIT_CRITICAL(); }
2178};
2179
2180inline bool OS_CRIT::OwnedByCurTask()
2181{
2182 return OSCritOwnerTCB == OSTCBCur;
2183}
2184
2198{
2199static NBRtosInitObj * pHead;
2200static bool bAlreadInited;
2201NBRtosInitObj *pNext;
2202protected:
2203 /*
2204 @brief Has RTOS init already occured?
2205 */
2206inline bool WasInitDone() {return bAlreadInited; }
2207 NBRtosInitObj();
2209public:
2214 virtual void Notify()=0;
2215 //Used internally
2216 static void InitWholeSet();
2217};
2218
2219
2220#endif
2221
2222
2223
2224
A simple class to derive from if you are creating taks that are constructed at global scope and need ...
Definition: nbrtos.h:2198
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:2082
OSCriticalSectionObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call Enter() on the OS_CRIT object that is passe...
Definition: nbrtos.h:2092
~OSCriticalSectionObj()
Destructs the OSCriticalSectionObj object, and call Leave() on the OS_CRIT object that was passed int...
Definition: nbrtos.h:2102
A simple wrapper class that helps utilize OS_CRIT objects to lock tasks and enter critical sections m...
Definition: nbrtos.h:2118
~OSLockAndCritObj()
Call LeaveAndUnlock() on the OSCriticalSectionObj object, then destruct.
Definition: nbrtos.h:2134
OSLockAndCritObj(OS_CRIT &ocrit)
Initialize the OSCriticalSectionObj object, and then call LockAndEnter() on the OS_CRIT object that i...
Definition: nbrtos.h:2128
A simple wrapper class that helps use OS locks effectively.
Definition: nbrtos.h:2057
OSLockObj()
Initialize the OSLockObj and calls OSLock().
Definition: nbrtos.h:2062
~OSLockObj()
Destructs the OSLockObj and calls OSUnlock().
Definition: nbrtos.h:2067
A simple wrapper class that uses an OS_CRIT object to try and claim a critical section,...
Definition: nbrtos.h:2151
~OSSpinCrit()
Call Leave() on the OS_CRIT object, and then destruct/.
Definition: nbrtos.h:2170
OSSpinCrit(OS_CRIT &ocrit)
Initialize the OSSpinCrit object, and then call EnterNoWait() repeatedly on the OS_CRIT object that i...
Definition: nbrtos.h:2161
TickTimeouts are used to facilitate sequential function calls with timeout parameters that need to in...
Definition: nbrtos.h:131
bool expired() const
Determine whether the timeout duration has elapsed.
Definition: nbrtos.h:185
TickTimeout(uint32_t timeout)
Create and initialize the Timeout.
Definition: nbrtos.h:163
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...
Definition: nbrtos.cpp:440
uint32_t val() const
Get the timeout duration to be passed to a function utilizing timeout ticks.
Definition: nbrtos.h:171
NetBurner System Constants.
void OSUnlock(void)
This function unlocks the OS.
Definition: nbrtos.cpp:520
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:1995
uint8_t OSCritInit(OS_CRIT *pCrit)
This function initializes the critical section.
Definition: nbrtos.h:1908
uint8_t OSChangePrio(uint32_t newp)
This function changes the priority of the calling task.
Definition: nbrtos.cpp:717
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:1741
void OSDumpTasks(void)
This function dumps the state and call stack for every task to stdout. This function is useful for de...
uint8_t OSSemInit(OS_SEM *psem, long value)
Initializes a semaphore.
Definition: nbrtos.h:1565
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:1269
uint8_t OSMboxPost(OS_MBOX *pmbox, void *msg)
This function posts a message to a Mail box.
Definition: nbrtos.h:1655
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:1671
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:1761
uint8_t OSCritEnter(OS_CRIT *pCrit, uint16_t timeout)
This function tries to enter or claim the critical section.
Definition: nbrtos.h:1930
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:1232
void OSTaskDelete(void)
This function deletes the current calling task, but we do not recommend the use of this function beca...
Definition: nbrtos.cpp:758
uint8_t OSCritEnterNoWait(OS_CRIT *pCrit)
This function tries to enter or claim the critical section.
Definition: nbrtos.h:1947
uint8_t OSCritLeave(OS_CRIT *pCrit)
This function releases the critical section.
Definition: nbrtos.h:1964
void OSTimeWaitUntil(uint32_t to_when)
Delay the task until the specified value of the system timer tick. The number of system ticks per sec...
Definition: nbrtos.cpp:440
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:1781
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:1862
void ShowTaskList(void)
This functions dumps the current RTOS task states to stdio.
Definition: nbrtos.cpp:79
uint8_t OSFifoPost(OS_FIFO *pFifo, OS_FIFO_EL *pToPost)
This function posts to a FIFO.
Definition: nbrtos.h:1846
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:1198
OS_FIFO_EL * OSFifoPend(OS_FIFO *pFifo, uint16_t timeout)
This function pends on a FIFO.
Definition: nbrtos.h:1877
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:1250
uint8_t OSTaskCreatewName(void(*task)(void *dptr), void *data, void *pstktop, void *pstkbot, uint8_t prio, const char *name)
This function creates a new task.
uint8_t OSQPost(OS_Q *pq, void *msg)
This function posts a message to a Queue.
Definition: nbrtos.h:1723
uint8_t OSSemPendNoWait(OS_SEM *psem)
OSSemPendNoWait() is identical to OSSemPend(), but it does not wait.
Definition: nbrtos.h:1619
uint8_t OSFifoInit(OS_FIFO *pFifo)
Initialize a FIFO, which is used to pass structures from one task to another.
Definition: nbrtos.h:1829
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.
Definition: nbrtos.cpp:505
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:1303
#define WAIT_FOREVER
Definition: nbrtos.h:71
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:1602
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:1213
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:1705
void * OSMboxPendNoWait(OS_MBOX *pmbox, uint8_t *err)
OSMboxPendNoWait() is identical to OSMboxPend(), but it does not wait.
Definition: nbrtos.h:1686
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:1287
void * OSQPendNoWait(OS_Q *pq, uint8_t *err)
OSQPendNoWait() is identical to the OSQPend() function but it does not wait.
Definition: nbrtos.h:1812
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:1468
OS_FIFO_EL * OSFifoPendNoWait(OS_FIFO *pFifo)
This function is identical to the OSFifoPen() function, but it does not wait.
Definition: nbrtos.h:1891
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:1797
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:1583
uint8_t OSMboxInit(OS_MBOX *pmbox, void *msg)
This function is used to initialize an OS_MBOX structure.
Definition: nbrtos.h:1637
#define OS_TIMEOUT
Timeout.
Definition: nbrtos.h:59
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition: nbrtos.h:926
uint8_t LockAndEnter(uint32_t timeoutTicks=WAIT_FOREVER)
Locks the current task to prevent task switching, and claims a critical section.
Definition: nbrtos.cpp:1369
uint8_t LeaveAndUnlock()
This function unlocks the task and releases the critical section.
Definition: nbrtos.cpp:1433
uint8_t Init()
Initialize an OS_CRIT object to its default state.
Definition: nbrtos.cpp:1359
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:935
uint8_t Enter(uint32_t timeoutTicks=WAIT_FOREVER)
This function tries to enter or claim the critical section.
Definition: nbrtos.cpp:1380
uint8_t EnterNoWait()
This function tries to enter or claim the critical section. However, this function does not wait if i...
Definition: nbrtos.cpp:1420
uint8_t Leave()
This function releases the critical section.
Definition: nbrtos.cpp:1440
A FIFO is used to pass structures from one task to another. Note: Structures to be passed must have a...
Definition: nbrtos.h:761
OS_FIFO()
Create and initialize a FIFO object.
Definition: nbrtos.h:771
uint8_t Init()
Sets the FIFO object to its initial state.
Definition: nbrtos.cpp:1221
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:1276
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:1323
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:861
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:877
OS_FIFO_EL * Pend(uint32_t timeoutTicks, uint8_t &result)
This function pends on a FIFO for a specified number of ticks.
Definition: nbrtos.h:826
uint8_t Post(OS_FIFO_EL *pToPost)
This function posts to a FIFO object.
Definition: nbrtos.cpp:1300
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:1053
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: nbrtosflags.cpp:145
void Write(uint32_t bits_to_force)
This function forces the bits to match the passe din bits`.
Definition: nbrtosflags.cpp:201
void Init()
Initialize an OS_FLAG object to its default value.
Definition: nbrtosflags.cpp:95
OS_FLAGS()
Create and initialize an OS_FLAG object.
Definition: nbrtosflags.cpp:87
uint8_t PendAny(uint32_t bit_mask, uint16_t timeout=WAIT_FOREVER)
This function waits a number of time ticks specified by timeout until any of the flags indicated by b...
Definition: nbrtos.h:1118
uint32_t State()
This function returns the current values of the flags stored in the OS_FLAGS object structure.
Definition: nbrtosflags.cpp:188
void Set(uint32_t bits_to_set)
This function sets the corresponding bits asserted in bits_to_set.
Definition: nbrtosflags.cpp:104
uint8_t PendAll(uint32_t bit_mask, uint16_t timeout=WAIT_FOREVER)
This function waits a number of time ticks specified by timeout until all the flags indicated by bit_...
Definition: nbrtos.h:1149
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: nbrtosflags.cpp:180
void Clear(uint32_t bits_to_clr)
This function clears the bits asserted in bits_to_clr.
Definition: nbrtosflags.cpp:112
Mailboxes are used to communicate between tasks.
Definition: nbrtos.h:414
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:524
OS_MBOX()
Create and initialize a mailbox object.
Definition: nbrtos.h:424
uint8_t Init(void *msg=NULL)
Sets the mailbox object to its initial state.
Definition: nbrtos.cpp:899
uint8_t Post(void *msg)
This function posts a message to the mailbox.
Definition: nbrtos.cpp:991
OS_MBOX(void *msg)
Create and initialize a mailbox object with a given message.
Definition: nbrtos.h:431
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:506
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.h:472
void * PendNoWait(uint8_t &result)
Checks to see if a message has been posted to a mailbox, but does not wait.
Definition: nbrtos.cpp:966
A queue functions as a fixed size FIFO for communication between tasks.
Definition: nbrtos.h:556
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:1181
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:714
uint8_t PostUnique(void *pItem)
This function checks to see if a message already exists in a queue, and if it doesn't,...
Definition: nbrtos.cpp:1137
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:1118
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.h:664
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:1094
OS_Q(void **pQueueStorage, uint8_t size)
Create and initialize a queue object.
Definition: nbrtos.h:573
uint8_t PostUniqueFirst(void *msg)
This function checks to see if a message already exists in a queue, and if it doesn't,...
Definition: nbrtos.cpp:1156
uint8_t Init(void **pQueueStorage, uint8_t size)
Sets the queue object to its initial state.
Definition: nbrtos.cpp:1014
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:698
Semaphores are used to control access to shared resource critical section, or to communicate between ...
Definition: nbrtos.h:337
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.h:389
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:791
OS_SEM(int32_t cnt=0)
Create and initialize a semaphore.
Definition: nbrtos.h:350
uint8_t PendNoWait()
Pend on a semaphore with no waiting period.
Definition: nbrtos.cpp:867
uint8_t Post()
This function increases the value of the semaphore by one. Note: If any higher priority tasks were wa...
Definition: nbrtos.cpp:887