Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nzos_fiber.h
Go to the documentation of this file.
1 
48 #ifndef NZOS_FIBER_H
49 #define NZOS_FIBER_H
50 
52 // "RTOS Fiber" - documentation module
54 
71 #if (nzosFIBER_ENABLE==1)
72 
73 
75 #ifndef __INLINE_FUNCTION__
76 #define __INLINE_FUNCTION__ extern inline __attribute__((always_inline))
77 #endif
78 
79 
81 #if !defined(nzosFIBER_LEVELS)
82 #define nzosFIBER_LEVELS ( 2 )
83 #endif
84 
85 typedef struct FIBER_TCB_ {
86 WORD* pSchedule;
87 WORD mask;
88 } FIBER_TCB;
89 
90 
91 typedef struct NZOS_FIBER_INFO_
92 //typedef struct __attribute__((__packed__)) NZOS_FIBER_INFO_
93 //typedef struct __attribute__((aligned(2), packed)) NZOS_FIBER_INFO_
94 {
95  void (*pFibers[nzosFIBER_LEVELS*8])(void); //Array of fibers
96  WORD runBits[nzosFIBER_LEVELS/2]; //Bits indicating what fibers are scheduled to run
97 
98  union {
99  struct
100  {
101  unsigned int fill : 16;
102  } flagBits;
103  struct
104  {
105  BYTE LB;
106  BYTE HB;
107  } flagBytes;
108  WORD flagVal;
109  };
111 
112 
113 //#if !defined(THIS_IS_NZOS_FIBER_C)
114 extern NZOS_FIBER_INFO zvFbrInfo;
115 //#endif //#if !defined(THIS_IS_NZOS_FIBER_C)
116 
117 
142 WORD nzFbrCreate(BYTE level, BOOL highPriority, void (*ptrFiber)(void), FIBER_TCB* fbrTcb);
143 
144 
145 
155 #define nzFbrSchedule(pFbrTCB) \
156  /* Set flag for kernel to indicate fiber must be ran */ \
157  *((pFbrTCB)->pSchedule) |= (pFbrTCB)->mask; \
158  /* Schedule the "Netcruzer RTOS Kernel" to run! */ \
159  NZOS_INT_KERNEL_SET_IF();
160 
161 #endif //if (nzosFIBER_ENABLE==1)
162 
163 #endif //#ifndef NZ_OS_H
164