⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_flag.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
        ARM
??OSFlagNameGet??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock6
        REQUIRE OSFlagNameGet
//  340 #endif
//  341 /*$PAGE*/
//  342 /*
//  343 *********************************************************************************************************
//  344 *                                 GET THE NAME OF AN EVENT FLAG GROUP
//  345 *
//  346 * Description: This function is used to obtain the name assigned to an event flag group
//  347 *
//  348 * Arguments  : pgrp      is a pointer to the event flag group.
//  349 *
//  350 *              pname     is a pointer to an ASCII string that will receive the name of the event flag
//  351 *                        group.  The string must be able to hold at least OS_FLAG_NAME_SIZE characters.
//  352 *
//  353 *              err       is a pointer to an error code that can contain one of the following values:
//  354 *
//  355 *                        OS_NO_ERR                  if the requested task is resumed
//  356 *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to an event flag group
//  357 *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
//  358 *                        OS_FLAG_INVALID_PGRP       if you passed a NULL pointer for 'pgrp'
//  359 *
//  360 * Returns    : The length of the string or 0 if the 'pgrp' is a NULL pointer.
//  361 *********************************************************************************************************
//  362 */
//  363 
//  364 #if OS_FLAG_NAME_SIZE > 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock7 Using cfiCommon1
        CFI Function OSFlagNameGet
        THUMB
//  365 INT8U  OSFlagNameGet (OS_FLAG_GRP *pgrp, char *pname, INT8U *err)
//  366 {
OSFlagNameGet:
        PUSH     {R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
        MOVS     R6,R0
        MOVS     R7,R1
        MOVS     R4,R2
//  367 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  368     OS_CPU_SR  cpu_sr;
//  369 #endif
//  370     INT8U      len;
//  371 
//  372 
//  373     OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R5,R0
//  374 #if OS_ARG_CHK_EN > 0
//  375     if (pgrp == (OS_FLAG_GRP *)0) {              /* Is 'pgrp' a NULL pointer?                          */
        CMP      R6,#+0
        BNE      ??OSFlagNameGet_0
//  376         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  377         *err = OS_FLAG_INVALID_PGRP;
        MOVS     R0,#+150
??OSFlagNameGet_1:
        STRB     R0,[R4, #+0]
//  378         return (0);
        MOVS     R0,#+0
        B        ??OSFlagNameGet_2
//  379     }
//  380     if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
??OSFlagNameGet_0:
        CMP      R7,#+0
        BNE      ??OSFlagNameGet_3
//  381         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  382         *err = OS_ERR_PNAME_NULL;
        MOVS     R0,#+15
        B.N      ??OSFlagNameGet_1
//  383         return (0);
//  384     }
//  385 #endif
//  386     if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
??OSFlagNameGet_3:
        LDRB     R0,[R6, #+0]
        CMP      R0,#+5
        BEQ      ??OSFlagNameGet_4
//  387         OS_EXIT_CRITICAL();
        MOVS     R0,R5
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  388         *err = OS_ERR_EVENT_TYPE;
        MOVS     R0,#+1
        STRB     R0,[R4, #+0]
//  389         return (0);
        MOVS     R0,#+0
        B        ??OSFlagNameGet_2
//  390     }
//  391     len  = OS_StrCopy(pname, pgrp->OSFlagName);  /* Copy name from OS_FLAG_GRP                         */
??OSFlagNameGet_4:
        ADDS     R6,R6,#+10
        MOVS     R1,R6
        MOVS     R0,R7
        _BLF     OS_StrCopy,??OS_StrCopy??rT
        MOVS     R6,R0
//  392     OS_EXIT_CRITICAL();
        MOVS     R0,R5
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  393     *err = OS_NO_ERR;
        MOVS     R0,#+0
        STRB     R0,[R4, #+0]
//  394     return (len);
        MOVS     R0,R6
??OSFlagNameGet_2:
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock7
//  395 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock8 Using cfiCommon0
        CFI NoFunction
        ARM
??OSFlagNameSet??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock8
        REQUIRE OSFlagNameSet
//  396 #endif
//  397 
//  398 /*$PAGE*/
//  399 /*
//  400 *********************************************************************************************************
//  401 *                                 ASSIGN A NAME TO AN EVENT FLAG GROUP
//  402 *
//  403 * Description: This function assigns a name to an event flag group.
//  404 *
//  405 * Arguments  : pgrp      is a pointer to the event flag group. 
//  406 *
//  407 *              pname     is a pointer to an ASCII string that will be used as the name of the event flag
//  408 *                        group.  The string must be able to hold at least OS_FLAG_NAME_SIZE characters.
//  409 *
//  410 *              err       is a pointer to an error code that can contain one of the following values:
//  411 *
//  412 *                        OS_NO_ERR                  if the requested task is resumed
//  413 *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to an event flag group
//  414 *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
//  415 *                        OS_FLAG_INVALID_PGRP       if you passed a NULL pointer for 'pgrp'
//  416 *
//  417 * Returns    : None
//  418 *********************************************************************************************************
//  419 */
//  420 
//  421 #if OS_FLAG_NAME_SIZE > 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock9 Using cfiCommon1
        CFI Function OSFlagNameSet
        THUMB
//  422 void  OSFlagNameSet (OS_FLAG_GRP *pgrp, char *pname, INT8U *err)
//  423 {
OSFlagNameSet:
        PUSH     {R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
        MOVS     R5,R0
        MOVS     R6,R1
        MOVS     R4,R2
//  424 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  425     OS_CPU_SR  cpu_sr;
//  426 #endif
//  427     INT8U      len;
//  428 
//  429 
//  430     OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R7,R0
//  431 #if OS_ARG_CHK_EN > 0
//  432     if (pgrp == (OS_FLAG_GRP *)0) {              /* Is 'pgrp' a NULL pointer?                          */
        CMP      R5,#+0
        BNE      ??OSFlagNameSet_0
//  433         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  434         *err = OS_FLAG_INVALID_PGRP;
        MOVS     R0,#+150
        B.N      ??OSFlagNameSet_1
//  435         return;
//  436     }
//  437     if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
??OSFlagNameSet_0:
        CMP      R6,#+0
        BNE      ??OSFlagNameSet_2
//  438         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  439         *err = OS_ERR_PNAME_NULL;
        MOVS     R0,#+15
        B.N      ??OSFlagNameSet_1
//  440         return;
//  441     }
//  442 #endif
//  443     if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
??OSFlagNameSet_2:
        LDRB     R0,[R5, #+0]
        CMP      R0,#+5
        BEQ      ??OSFlagNameSet_3
//  444         OS_EXIT_CRITICAL();
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  445         *err = OS_ERR_EVENT_TYPE;
        MOVS     R0,#+1
        B.N      ??OSFlagNameSet_1
//  446         return;
//  447     }
//  448     len = OS_StrLen(pname);                      /* Can we fit the string in the storage area?         */
??OSFlagNameSet_3:
        MOVS     R0,R6
        _BLF     OS_StrLen,??OS_StrLen??rT
//  449     if (len > (OS_FLAG_NAME_SIZE - 1)) {         /* No                                                 */
        CMP      R0,#+32
        BCC      ??OSFlagNameSet_4
//  450         OS_EXIT_CRITICAL();
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  451         *err = OS_ERR_FLAG_NAME_TOO_LONG;
        MOVS     R0,#+13
        B.N      ??OSFlagNameSet_1
//  452         return;
//  453     } 
//  454     (void)OS_StrCopy(pgrp->OSFlagName, pname);   /* Yes, copy name from OS_FLAG_GRP                    */
??OSFlagNameSet_4:
        MOVS     R1,R6
        ADDS     R5,R5,#+10
        MOVS     R0,R5
        _BLF     OS_StrCopy,??OS_StrCopy??rT
//  455     OS_EXIT_CRITICAL();
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  456     *err = OS_NO_ERR;
        MOVS     R0,#+0
??OSFlagNameSet_1:
        STRB     R0,[R4, #+0]
//  457     return;
        POP      {R4-R7}
        POP      {R0}
        BX       R0               ;; return
        CFI EndBlock cfiBlock9
//  458 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock10 Using cfiCommon0
        CFI NoFunction
        ARM
??OSFlagPend??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock10
        REQUIRE OSFlagPend
//  459 #endif
//  460 
//  461 /*$PAGE*/
//  462 /*
//  463 *********************************************************************************************************
//  464 *                                        WAIT ON AN EVENT FLAG GROUP
//  465 *
//  466 * Description: This function is called to wait for a combination of bits to be set in an event flag
//  467 *              group.  Your application can wait for ANY bit to be set or ALL bits to be set.
//  468 *
//  469 * Arguments  : pgrp          is a pointer to the desired event flag group.
//  470 *
//  471 *              flags         Is a bit pattern indicating which bit(s) (i.e. flags) you wish to wait for.
//  472 *                            The bits you want are specified by setting the corresponding bits in
//  473 *                            'flags'.  e.g. if your application wants to wait for bits 0 and 1 then
//  474 *                            'flags' would contain 0x03.
//  475 *
//  476 *              wait_type     specifies whether you want ALL bits to be set or ANY of the bits to be set.
//  477 *                            You can specify the following argument:
//  478 *
//  479 *                            OS_FLAG_WAIT_CLR_ALL   You will wait for ALL bits in 'mask' to be clear (0)
//  480 *                            OS_FLAG_WAIT_SET_ALL   You will wait for ALL bits in 'mask' to be set   (1)
//  481 *                            OS_FLAG_WAIT_CLR_ANY   You will wait for ANY bit  in 'mask' to be clear (0)
//  482 *                            OS_FLAG_WAIT_SET_ANY   You will wait for ANY bit  in 'mask' to be set   (1)
//  483 *
//  484 *                            NOTE: Add OS_FLAG_CONSUME if you want the event flag to be 'consumed' by
//  485 *                                  the call.  Example, to wait for any flag in a group AND then clear
//  486 *                                  the flags that are present, set 'wait_type' to:
//  487 *
//  488 *                                  OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
//  489 *
//  490 *              timeout       is an optional timeout (in clock ticks) that your task will wait for the
//  491 *                            desired bit combination.  If you specify 0, however, your task will wait
//  492 *                            forever at the specified event flag group or, until a message arrives.
//  493 *
//  494 *              err           is a pointer to an error code and can be:
//  495 *                            OS_NO_ERR              The desired bits have been set within the specified
//  496 *                                                   'timeout'.
//  497 *                            OS_ERR_PEND_ISR        If you tried to PEND from an ISR
//  498 *                            OS_FLAG_INVALID_PGRP   If 'pgrp' is a NULL pointer.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -