📄 os_flag.lst
字号:
\ 00000008 .... LDR.N R0,??DataTable6 ;; OSIntNesting
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 0028 CMP R0,#+0
\ 0000000E 02D0 BEQ.N ??OSFlagNameSet_0
483 *perr = OS_ERR_NAME_SET_ISR;
\ 00000010 1220 MOVS R0,#+18
\ 00000012 3070 STRB R0,[R6, #+0]
484 return;
\ 00000014 F0BD POP {R4-R7,PC}
485 }
486 OS_ENTER_CRITICAL();
\ ??OSFlagNameSet_0:
\ 00000016 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000001A 0700 MOVS R7,R0
487 if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
\ 0000001C 2078 LDRB R0,[R4, #+0]
\ 0000001E 0528 CMP R0,#+5
\ 00000020 05D0 BEQ.N ??OSFlagNameSet_1
488 OS_EXIT_CRITICAL();
\ 00000022 3800 MOVS R0,R7
\ 00000024 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
489 *perr = OS_ERR_EVENT_TYPE;
\ 00000028 0120 MOVS R0,#+1
\ 0000002A 3070 STRB R0,[R6, #+0]
490 return;
\ 0000002C F0BD POP {R4-R7,PC}
491 }
492 len = OS_StrLen(pname); /* Can we fit the string in the storage area? */
\ ??OSFlagNameSet_1:
\ 0000002E 2800 MOVS R0,R5
\ 00000030 ........ _BLF OS_StrLen,??OS_StrLen??rT
493 if (len > (OS_FLAG_NAME_SIZE - 1)) { /* No */
\ 00000034 1028 CMP R0,#+16
\ 00000036 05D3 BCC.N ??OSFlagNameSet_2
494 OS_EXIT_CRITICAL();
\ 00000038 3800 MOVS R0,R7
\ 0000003A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
495 *perr = OS_ERR_FLAG_NAME_TOO_LONG;
\ 0000003E 7320 MOVS R0,#+115
\ 00000040 3070 STRB R0,[R6, #+0]
496 return;
\ 00000042 F0BD POP {R4-R7,PC}
497 }
498 (void)OS_StrCopy(pgrp->OSFlagName, pname); /* Yes, copy name from OS_FLAG_GRP */
\ ??OSFlagNameSet_2:
\ 00000044 2900 MOVS R1,R5
\ 00000046 0A34 ADDS R4,R4,#+10
\ 00000048 2000 MOVS R0,R4
\ 0000004A ........ _BLF OS_StrCopy,??OS_StrCopy??rT
499 OS_EXIT_CRITICAL();
\ 0000004E 3800 MOVS R0,R7
\ 00000050 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
500 *perr = OS_ERR_NONE;
\ 00000054 0020 MOVS R0,#+0
\ 00000056 3070 STRB R0,[R6, #+0]
501 return;
\ 00000058 F0BD POP {R4-R7,PC} ;; return
502 }
503 #endif
504
505 /*$PAGE*/
506 /*
507 *********************************************************************************************************
508 * WAIT ON AN EVENT FLAG GROUP
509 *
510 * Description: This function is called to wait for a combination of bits to be set in an event flag
511 * group. Your application can wait for ANY bit to be set or ALL bits to be set.
512 *
513 * Arguments : pgrp is a pointer to the desired event flag group.
514 *
515 * flags Is a bit pattern indicating which bit(s) (i.e. flags) you wish to wait for.
516 * The bits you want are specified by setting the corresponding bits in
517 * 'flags'. e.g. if your application wants to wait for bits 0 and 1 then
518 * 'flags' would contain 0x03.
519 *
520 * wait_type specifies whether you want ALL bits to be set or ANY of the bits to be set.
521 * You can specify the following argument:
522 *
523 * OS_FLAG_WAIT_CLR_ALL You will wait for ALL bits in 'mask' to be clear (0)
524 * OS_FLAG_WAIT_SET_ALL You will wait for ALL bits in 'mask' to be set (1)
525 * OS_FLAG_WAIT_CLR_ANY You will wait for ANY bit in 'mask' to be clear (0)
526 * OS_FLAG_WAIT_SET_ANY You will wait for ANY bit in 'mask' to be set (1)
527 *
528 * NOTE: Add OS_FLAG_CONSUME if you want the event flag to be 'consumed' by
529 * the call. Example, to wait for any flag in a group AND then clear
530 * the flags that are present, set 'wait_type' to:
531 *
532 * OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
533 *
534 * timeout is an optional timeout (in clock ticks) that your task will wait for the
535 * desired bit combination. If you specify 0, however, your task will wait
536 * forever at the specified event flag group or, until a message arrives.
537 *
538 * perr is a pointer to an error code and can be:
539 * OS_ERR_NONE The desired bits have been set within the specified
540 * 'timeout'.
541 * OS_ERR_PEND_ISR If you tried to PEND from an ISR
542 * OS_ERR_FLAG_INVALID_PGRP If 'pgrp' is a NULL pointer.
543 * OS_ERR_EVENT_TYPE You are not pointing to an event flag group
544 * OS_ERR_TIMEOUT The bit(s) have not been set in the specified
545 * 'timeout'.
546 * OS_ERR_PEND_ABORT The wait on the flag was aborted.
547 * OS_ERR_FLAG_WAIT_TYPE You didn't specify a proper 'wait_type' argument.
548 *
549 * Returns : The flags in the event flag group that made the task ready or, 0 if a timeout or an error
550 * occurred.
551 *
552 * Called from: Task ONLY
553 *
554 * Note(s) : 1) IMPORTANT, the behavior of this function has changed from PREVIOUS versions. The
555 * function NOW returns the flags that were ready INSTEAD of the current state of the
556 * event flags.
557 *********************************************************************************************************
558 */
559
\ In segment CODE, align 4, keep-with-next
560 OS_FLAGS OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *perr)
561 {
\ OSFlagPend:
\ 00000000 2DE9F04F PUSH {R4-R11,LR}
\ 00000004 87B0 SUB SP,SP,#+28
\ 00000006 8846 MOV R8,R1
\ 00000008 9146 MOV R9,R2
\ 0000000A ADF80430 STRH R3,[SP, #+4]
\ 0000000E 0400 MOVS R4,R0
\ 00000010 109D LDR R5,[SP, #+64]
562 OS_FLAG_NODE node;
563 OS_FLAGS flags_rdy;
564 INT8U result;
565 INT8U pend_stat;
566 BOOLEAN consume;
567 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
568 OS_CPU_SR cpu_sr = 0;
569 #endif
570
571
572
573 #if OS_ARG_CHK_EN > 0
574 if (perr == (INT8U *)0) { /* Validate 'perr' */
575 return ((OS_FLAGS)0);
576 }
577 if (pgrp == (OS_FLAG_GRP *)0) { /* Validate 'pgrp' */
578 *perr = OS_ERR_FLAG_INVALID_PGRP;
579 return ((OS_FLAGS)0);
580 }
581 #endif
582 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000012 .... LDR.N R0,??DataTable6 ;; OSIntNesting
\ 00000014 0078 LDRB R0,[R0, #+0]
\ 00000016 0028 CMP R0,#+0
\ 00000018 02D0 BEQ.N ??OSFlagPend_1
583 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000001A 0220 MOVS R0,#+2
\ 0000001C 2870 STRB R0,[R5, #+0]
\ 0000001E 97E0 B.N ??OSFlagPend_2
584 return ((OS_FLAGS)0);
585 }
586 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSFlagPend_1:
\ 00000020 5348 LDR.N R0,??OSFlagPend_3 ;; OSLockNesting
\ 00000022 0078 LDRB R0,[R0, #+0]
\ 00000024 0028 CMP R0,#+0
\ 00000026 02D0 BEQ.N ??OSFlagPend_4
587 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 00000028 0D20 MOVS R0,#+13
\ 0000002A 2870 STRB R0,[R5, #+0]
\ 0000002C 90E0 B.N ??OSFlagPend_2
588 return ((OS_FLAGS)0);
589 }
590 if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type */
\ ??OSFlagPend_4:
\ 0000002E 0126 MOVS R6,#+1
\ 00000030 2078 LDRB R0,[R4, #+0]
\ 00000032 0528 CMP R0,#+5
\ 00000034 01D0 BEQ.N ??OSFlagPend_5
591 *perr = OS_ERR_EVENT_TYPE;
\ 00000036 2E70 STRB R6,[R5, #+0]
\ 00000038 8AE0 B.N ??OSFlagPend_2
592 return ((OS_FLAGS)0);
593 }
594 result = (INT8U)(wait_type & OS_FLAG_CONSUME);
595 if (result != (INT8U)0) { /* See if we need to consume the flags */
\ ??OSFlagPend_5:
\ 0000003A 0020 MOVS R0,#+0
\ 0000003C 8246 MOV R10,R0
\ 0000003E 4846 MOV R0,R9
\ 00000040 0006 LSLS R0,R0,#+24
\ 00000042 04D5 BPL.N ??OSFlagPend_6
596 wait_type &= ~(INT8U)OS_FLAG_CONSUME;
\ 00000044 4846 MOV R0,R9
\ 00000046 4006 LSLS R0,R0,#+25
\ 00000048 400E LSRS R0,R0,#+25
\ 0000004A 8146 MOV R9,R0
597 consume = OS_TRUE;
\ 0000004C 00E0 B.N ??OSFlagPend_7
598 } else {
599 consume = OS_FALSE;
\ ??OSFlagPend_6:
\ 0000004E 5646 MOV R6,R10
600 }
601 /*$PAGE*/
602 OS_ENTER_CRITICAL();
\ ??OSFlagPend_7:
\ 00000050 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -