📄 os_flag.ls1
字号:
166 ; * OS_FLAG_WAIT_CLR_ALL You will check ALL bits in 'flags' to
be clear (0)
167 ; * OS_FLAG_WAIT_CLR_ANY You will check ANY bit in 'flags' to
be clear (0)
168 ; * OS_FLAG_WAIT_SET_ALL You will check ALL bits in 'flags' to
be set (1)
169 ; * OS_FLAG_WAIT_SET_ANY You will check ANY bit in 'flags' to
be set (1)
170 ; *
171 ; * NOTE: Add OS_FLAG_CONSUME if you want the event flag to be '
consumed' by
A51 MACRO ASSEMBLER OS_FLAG 05/17/2005 11:19:52 PAGE 4
172 ; * the call. Example, to wait for any flag in a group AN
D then clear
173 ; * the flags that are present, set 'wait_type' to:
174 ; *
175 ; * OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
176 ; *
177 ; * err is a pointer to an error code and can be:
178 ; * OS_NO_ERR No error
179 ; * OS_ERR_EVENT_TYPE You are not pointing to an event flag
group
180 ; * OS_FLAG_ERR_WAIT_TYPE You didn't specify a proper 'wait_typ
e' argument.
181 ; * OS_FLAG_INVALID_PGRP You passed a NULL pointer instead of
the event flag
182 ; * group handle.
183 ; * OS_FLAG_ERR_NOT_RDY The desired flags you are waiting for
are not
184 ; * available.
185 ; *
186 ; * Returns : The state of the flags in the event flag group.
187 ; *
188 ; * Called from: Task or ISR
189 ; *****************************************************************************************
****************
190 ; */
191 ;
192 ; #if OS_FLAG_ACCEPT_EN > 0
193 ; OS_FLAGS OSFlagAccept (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT8U *err) L
G_REENTRANT
194 ; {
195 ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU st
atus register */
196 ; OS_CPU_SR cpu_sr;
197 ; #endif
198 ; OS_FLAGS flags_cur;
199 ; OS_FLAGS flags_rdy;
200 ; BOOLEAN consume;
201 ;
202 ;
203 ; #if OS_ARG_CHK_EN > 0
204 ; if (pgrp == (OS_FLAG_GRP *)0) { /* Validate 'pgrp'
*/
205 ; *err = OS_FLAG_INVALID_PGRP;
206 ; return ((OS_FLAGS)0);
207 ; }
208 ; if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type
*/
209 ; *err = OS_ERR_EVENT_TYPE;
210 ; return ((OS_FLAGS)0);
211 ; }
212 ; #endif
213 ; if (wait_type & OS_FLAG_CONSUME) { /* See if we need to consume t
he flags */
214 ; wait_type &= ~OS_FLAG_CONSUME;
215 ; consume = TRUE;
216 ; } else {
217 ; consume = FALSE;
218 ; }
219 ; /*$PAGE*/
220 ; *err = OS_NO_ERR; /* Assume NO error until prove
n otherwise. */
221 ; OS_ENTER_CRITICAL();
222 ; switch (wait_type) {
223 ; case OS_FLAG_WAIT_SET_ALL: /* See if all required flags a
re set */
224 ; flags_rdy = pgrp->OSFlagFlags & flags; /* Extract only the bits we wa
A51 MACRO ASSEMBLER OS_FLAG 05/17/2005 11:19:52 PAGE 5
nt */
225 ; if (flags_rdy == flags) { /* Must match ALL the bits tha
t we want */
226 ; if (consume == TRUE) { /* See if we need to consume t
he flags */
227 ; pgrp->OSFlagFlags &= ~flags_rdy; /* Clear ONLY the flags that w
e wanted */
228 ; }
229 ; } else {
230 ; *err = OS_FLAG_ERR_NOT_RDY;
231 ; }
232 ; flags_cur = pgrp->OSFlagFlags; /* Will return the state of th
e group */
233 ; OS_EXIT_CRITICAL();
234 ; break;
235 ;
236 ; case OS_FLAG_WAIT_SET_ANY:
237 ; flags_rdy = pgrp->OSFlagFlags & flags; /* Extract only the bits we wa
nt */
238 ; if (flags_rdy != (OS_FLAGS)0) { /* See if any flag set
*/
239 ; if (consume == TRUE) { /* See if we need to consume t
he flags */
240 ; pgrp->OSFlagFlags &= ~flags_rdy; /* Clear ONLY the flags that w
e got */
241 ; }
242 ; } else {
243 ; *err = OS_FLAG_ERR_NOT_RDY;
244 ; }
245 ; flags_cur = pgrp->OSFlagFlags; /* Will return the state of th
e group */
246 ; OS_EXIT_CRITICAL();
247 ; break;
248 ;
249 ; #if OS_FLAG_WAIT_CLR_EN > 0
250 ; case OS_FLAG_WAIT_CLR_ALL: /* See if all required flags a
re cleared */
251 ; flags_rdy = ~pgrp->OSFlagFlags & flags; /* Extract only the bits we wa
nt */
252 ; if (flags_rdy == flags) { /* Must match ALL the bits tha
t we want */
253 ; if (consume == TRUE) { /* See if we need to consume t
he flags */
254 ; pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we
wanted */
255 ; }
256 ; } else {
257 ; *err = OS_FLAG_ERR_NOT_RDY;
258 ; }
259 ; flags_cur = pgrp->OSFlagFlags; /* Will return the state of th
e group */
260 ; OS_EXIT_CRITICAL();
261 ; break;
262 ;
263 ; case OS_FLAG_WAIT_CLR_ANY:
264 ; flags_rdy = ~pgrp->OSFlagFlags & flags; /* Extract only the bits we wa
nt */
265 ; if (flags_rdy != (OS_FLAGS)0) { /* See if any flag cleared
*/
266 ; if (consume == TRUE) { /* See if we need to consume t
he flags */
267 ; pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we
got */
268 ; }
269 ; } else {
270 ; *err = OS_FLAG_ERR_NOT_RDY;
A51 MACRO ASSEMBLER OS_FLAG 05/17/2005 11:19:52 PAGE 6
271 ; }
272 ; flags_cur = pgrp->OSFlagFlags; /* Will return the state of th
e group */
273 ; OS_EXIT_CRITICAL();
274 ; break;
275 ; #endif
276 ;
277 ; default:
278 ; OS_EXIT_CRITICAL();
279 ; flags_cur = (OS_FLAGS)0;
280 ; *err = OS_FLAG_ERR_WAIT_TYPE;
281 ; break;
282 ; }
283 ; return (flags_cur);
284 ; }
285 ; #endif
286 ;
287 ; /*$PAGE*/
288 ; /*
289 ; *****************************************************************************************
****************
290 ; * CREATE AN EVENT FLAG
291 ; *
292 ; * Description: This function is called to create an event flag group.
293 ; *
294 ; * Arguments : flags Contains the initial value to store in the event flag group.
295 ; *
296 ; * err is a pointer to an error code which will be returned to your
application:
297 ; * OS_NO_ERR if the call was successful.
298 ; * OS_ERR_CREATE_ISR if you attempted to create an Ev
ent Flag from an
299 ; * ISR.
300 ; * OS_FLAG_GRP_DEPLETED if there are no more event flag
groups
301 ; *
302 ; * Returns : A pointer to an event flag group or a NULL pointer if no more groups are a
vailable.
303 ; *
304 ; * Called from: Task ONLY
305 ; *****************************************************************************************
****************
306 ; */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -