📄 os_flag.lst
字号:
\ 00000054 BDE8F081 POP {R4-R8,PC} ;; return
459 }
460 #endif
461
462 /*$PAGE*/
463 /*
464 *********************************************************************************************************
465 * ASSIGN A NAME TO AN EVENT FLAG GROUP
466 *
467 * Description: This function assigns a name to an event flag group.
468 *
469 * Arguments : pgrp is a pointer to the event flag group.
470 *
471 * pname is a pointer to an ASCII string that will be used as the name of the event flag
472 * group.
473 *
474 * perr is a pointer to an error code that can contain one of the following values:
475 *
476 * OS_ERR_NONE if the requested task is resumed
477 * OS_ERR_EVENT_TYPE if 'pevent' is not pointing to an event flag group
478 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
479 * OS_ERR_FLAG_INVALID_PGRP if you passed a NULL pointer for 'pgrp'
480 * OS_ERR_NAME_SET_ISR if you called this function from an ISR
481 *
482 * Returns : None
483 *********************************************************************************************************
484 */
485
486 #if OS_FLAG_NAME_EN > 0u
\ In section .text, align 2, keep-with-next
487 void OSFlagNameSet (OS_FLAG_GRP *pgrp,
488 INT8U *pname,
489 INT8U *perr)
490 {
\ OSFlagNameSet:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
\ 00000006 1600 MOVS R6,R2
491 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
492 OS_CPU_SR cpu_sr = 0u;
\ 00000008 0027 MOVS R7,#+0
493 #endif
494
495
496
497 #ifdef OS_SAFETY_CRITICAL
498 if (perr == (INT8U *)0) {
499 OS_SAFETY_CRITICAL_EXCEPTION();
500 return;
501 }
502 #endif
503
504 #if OS_ARG_CHK_EN > 0u
505 if (pgrp == (OS_FLAG_GRP *)0) { /* Is 'pgrp' a NULL pointer? */
506 *perr = OS_ERR_FLAG_INVALID_PGRP;
507 return;
508 }
509 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
510 *perr = OS_ERR_PNAME_NULL;
511 return;
512 }
513 #endif
514 if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
\ 0000000A ........ LDR.W R0,??DataTable9_1
\ 0000000E 0078 LDRB R0,[R0, #+0]
\ 00000010 0028 CMP R0,#+0
\ 00000012 02D0 BEQ.N ??OSFlagNameSet_0
515 *perr = OS_ERR_NAME_SET_ISR;
\ 00000014 1220 MOVS R0,#+18
\ 00000016 3070 STRB R0,[R6, #+0]
516 return;
\ 00000018 11E0 B.N ??OSFlagNameSet_1
517 }
518 OS_ENTER_CRITICAL();
\ ??OSFlagNameSet_0:
\ 0000001A ........ BL OS_CPU_SR_Save
\ 0000001E 0700 MOVS R7,R0
519 if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
\ 00000020 2078 LDRB R0,[R4, #+0]
\ 00000022 0528 CMP R0,#+5
\ 00000024 05D0 BEQ.N ??OSFlagNameSet_2
520 OS_EXIT_CRITICAL();
\ 00000026 3800 MOVS R0,R7
\ 00000028 ........ BL OS_CPU_SR_Restore
521 *perr = OS_ERR_EVENT_TYPE;
\ 0000002C 0120 MOVS R0,#+1
\ 0000002E 3070 STRB R0,[R6, #+0]
522 return;
\ 00000030 05E0 B.N ??OSFlagNameSet_1
523 }
524 pgrp->OSFlagName = pname;
\ ??OSFlagNameSet_2:
\ 00000032 E560 STR R5,[R4, #+12]
525 OS_EXIT_CRITICAL();
\ 00000034 3800 MOVS R0,R7
\ 00000036 ........ BL OS_CPU_SR_Restore
526 *perr = OS_ERR_NONE;
\ 0000003A 0020 MOVS R0,#+0
\ 0000003C 3070 STRB R0,[R6, #+0]
527 return;
\ ??OSFlagNameSet_1:
\ 0000003E F1BD POP {R0,R4-R7,PC} ;; return
528 }
529 #endif
530
531 /*$PAGE*/
532 /*
533 *********************************************************************************************************
534 * WAIT ON AN EVENT FLAG GROUP
535 *
536 * Description: This function is called to wait for a combination of bits to be set in an event flag
537 * group. Your application can wait for ANY bit to be set or ALL bits to be set.
538 *
539 * Arguments : pgrp is a pointer to the desired event flag group.
540 *
541 * flags Is a bit pattern indicating which bit(s) (i.e. flags) you wish to wait for.
542 * The bits you want are specified by setting the corresponding bits in
543 * 'flags'. e.g. if your application wants to wait for bits 0 and 1 then
544 * 'flags' would contain 0x03.
545 *
546 * wait_type specifies whether you want ALL bits to be set or ANY of the bits to be set.
547 * You can specify the following argument:
548 *
549 * OS_FLAG_WAIT_CLR_ALL You will wait for ALL bits in 'mask' to be clear (0)
550 * OS_FLAG_WAIT_SET_ALL You will wait for ALL bits in 'mask' to be set (1)
551 * OS_FLAG_WAIT_CLR_ANY You will wait for ANY bit in 'mask' to be clear (0)
552 * OS_FLAG_WAIT_SET_ANY You will wait for ANY bit in 'mask' to be set (1)
553 *
554 * NOTE: Add OS_FLAG_CONSUME if you want the event flag to be 'consumed' by
555 * the call. Example, to wait for any flag in a group AND then clear
556 * the flags that are present, set 'wait_type' to:
557 *
558 * OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
559 *
560 * timeout is an optional timeout (in clock ticks) that your task will wait for the
561 * desired bit combination. If you specify 0, however, your task will wait
562 * forever at the specified event flag group or, until a message arrives.
563 *
564 * perr is a pointer to an error code and can be:
565 * OS_ERR_NONE The desired bits have been set within the specified
566 * 'timeout'.
567 * OS_ERR_PEND_ISR If you tried to PEND from an ISR
568 * OS_ERR_FLAG_INVALID_PGRP If 'pgrp' is a NULL pointer.
569 * OS_ERR_EVENT_TYPE You are not pointing to an event flag group
570 * OS_ERR_TIMEOUT The bit(s) have not been set in the specified
571 * 'timeout'.
572 * OS_ERR_PEND_ABORT The wait on the flag was aborted.
573 * OS_ERR_FLAG_WAIT_TYPE You didn't specify a proper 'wait_type' argument.
574 *
575 * Returns : The flags in the event flag group that made the task ready or, 0 if a timeout or an error
576 * occurred.
577 *
578 * Called from: Task ONLY
579 *
580 * Note(s) : 1) IMPORTANT, the behavior of this function has changed from PREVIOUS versions. The
581 * function NOW returns the flags that were ready INSTEAD of the current state of the
582 * event flags.
583 *********************************************************************************************************
584 */
585
\ In section .text, align 2, keep-with-next
586 OS_FLAGS OSFlagPend (OS_FLAG_GRP *pgrp,
587 OS_FLAGS flags,
588 INT8U wait_type,
589 INT32U timeout,
590 INT8U *perr)
591 {
\ OSFlagPend:
\ 00000000 2DE9F04F PUSH {R4-R11,LR}
\ 00000004 87B0 SUB SP,SP,#+28
\ 00000006 0400 MOVS R4,R0
\ 00000008 0D00 MOVS R5,R1
\ 0000000A 9246 MOV R10,R2
\ 0000000C 1E00 MOVS R6,R3
\ 0000000E 109F LDR R7,[SP, #+64]
592 OS_FLAG_NODE node;
593 OS_FLAGS flags_rdy;
594 INT8U result;
595 INT8U pend_stat;
596 BOOLEAN consume;
597 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
598 OS_CPU_SR cpu_sr = 0u;
\ 00000010 5FF00009 MOVS R9,#+0
599 #endif
600
601
602
603 #ifdef OS_SAFETY_CRITICAL
604 if (perr == (INT8U *)0) {
605 OS_SAFETY_CRITICAL_EXCEPTION();
606 return ((OS_FLAGS)0);
607 }
608 #endif
609
610 #if OS_ARG_CHK_EN > 0u
611 if (pgrp == (OS_FLAG_GRP *)0) { /* Validate 'pgrp' */
612 *perr = OS_ERR_FLAG_INVALID_PGRP;
613 return ((OS_FLAGS)0);
614 }
615 #endif
616 if (OSIntNesting > 0u) { /* See if called from ISR ... */
\ 00000014 ........ LDR.W R0,??DataTable9_1
\ 00000018 0078 LDRB R0,[R0, #+0]
\ 0000001A 0028 CMP R0,#+0
\ 0000001C 03D0 BEQ.N ??OSFlagPend_0
617 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000001E 0220 MOVS R0,#+2
\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -