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

📄 os_mutex.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 4 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART     26/Dec/2008  18:22:03 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  thumb                                                #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mutex.c    #
#    Command line    =  F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mutex.c    #
#                       -lCN F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E- #
#                       EVAL\IAR\OS-Probe\Flash\List\ -o                     #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\ -z6 --no_unroll --no_inline  #
#                       --no_tbaa --no_scheduling --debug --cpu_mode thumb   #
#                       --endian little --cpu cortex-M3 --stack_align 4 -e   #
#                       --fpu None --dlib_config "E:\Program Files\IAR       #
#                       Systems\Embedded Workbench 4.0                       #
#                       Kickstart\arm\LIB\dl7mptnnl8n.h" -I                  #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ #
#                       ST\STM3210E-EVAL\IAR\OS-Probe\..\BSP\ -I             #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\CPU\ST\STM32\inc\ -I     #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ARM-Cortex-M3\IAR #
#                       \ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E- #
#                       EVAL\IAR\OS-Probe\..\..\..\..\..\uC-LCD\Source\ -I   #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-LIB\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uCOS-II\Ports\ARM-Cortex #
#                       -M3\Generic\IAR\ -I F:\PROJECT\STM32_UCOSII\EvalBoar #
#                       ds\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uCOS #
#                       -II\Source\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST #
#                       \STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uC-Probe\ #
#                       Target\Communication\Generic\RS-232\Source\ -I       #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\RS-232\Ports\ST\STM32\ -I              #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\Source\ -I F:\PROJECT\STM32_UCOSII\Eva #
#                       lBoards\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\.. #
#                       \uC-Probe\Target\Plugins\uCOS-II\ -I "E:\Program     #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Kickstart\arm\INC\"                                  #
#    List file       =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\List\os_mutex.lst                 #
#    Object file     =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\os_mutex.r79                  #
#                                                                            #
#                                                                            #
##############################################################################

F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mutex.c
      1          /*
      2          *********************************************************************************************************
      3          *                                                uC/OS-II
      4          *                                          The Real-Time Kernel
      5          *                                  MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
      6          *
      7          *                              (c) Copyright 1992-2007, Micrium, Weston, FL
      8          *                                           All Rights Reserved
      9          *
     10          * File    : OS_MUTEX.C
     11          * By      : Jean J. Labrosse
     12          * Version : V2.86
     13          *
     14          * LICENSING TERMS:
     15          * ---------------
     16          *   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
     17          * If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
     18          * its use in your product. We provide ALL the source code for your convenience and to help you experience 
     19          * uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
     20          * licensing fee.
     21          *********************************************************************************************************
     22          */
     23          
     24          #ifndef  OS_MASTER_FILE
     25          #include <ucos_ii.h>
     26          #endif
     27          
     28          
     29          #if OS_MUTEX_EN > 0
     30          /*
     31          *********************************************************************************************************
     32          *                                            LOCAL CONSTANTS
     33          *********************************************************************************************************
     34          */
     35          
     36          #define  OS_MUTEX_KEEP_LOWER_8   ((INT16U)0x00FFu)
     37          #define  OS_MUTEX_KEEP_UPPER_8   ((INT16U)0xFF00u)
     38          
     39          #define  OS_MUTEX_AVAILABLE      ((INT16U)0x00FFu)
     40          
     41          /*
     42          *********************************************************************************************************
     43          *                                            LOCAL CONSTANTS
     44          *********************************************************************************************************
     45          */
     46          
     47          static  void  OSMutex_RdyAtPrio(OS_TCB *ptcb, INT8U prio);
     48          
     49          /*$PAGE*/
     50          /*
     51          *********************************************************************************************************
     52          *                                   ACCEPT MUTUAL EXCLUSION SEMAPHORE
     53          *
     54          * Description: This  function checks the mutual exclusion semaphore to see if a resource is available.
     55          *              Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if the resource is
     56          *              not available or the event did not occur.
     57          *
     58          * Arguments  : pevent     is a pointer to the event control block
     59          *
     60          *              perr       is a pointer to an error code which will be returned to your application:
     61          *                            OS_ERR_NONE         if the call was successful.
     62          *                            OS_ERR_EVENT_TYPE   if 'pevent' is not a pointer to a mutex
     63          *                            OS_ERR_PEVENT_NULL  'pevent' is a NULL pointer
     64          *                            OS_ERR_PEND_ISR     if you called this function from an ISR
     65          *                            OS_ERR_PIP_LOWER    If the priority of the task that owns the Mutex is
     66          *                                                HIGHER (i.e. a lower number) than the PIP.  This error
     67          *                                                indicates that you did not set the PIP higher (lower
     68          *                                                number) than ALL the tasks that compete for the Mutex.
     69          *                                                Unfortunately, this is something that could not be
     70          *                                                detected when the Mutex is created because we don't know
     71          *                                                what tasks will be using the Mutex.
     72          *
     73          * Returns    : == OS_TRUE    if the resource is available, the mutual exclusion semaphore is acquired
     74          *              == OS_FALSE   a) if the resource is not available
     75          *                            b) you didn't pass a pointer to a mutual exclusion semaphore
     76          *                            c) you called this function from an ISR
     77          *
     78          * Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
     79          *              intended to be used by tasks only.
     80          *********************************************************************************************************
     81          */
     82          
     83          #if OS_MUTEX_ACCEPT_EN > 0
     84          BOOLEAN  OSMutexAccept (OS_EVENT *pevent, INT8U *perr)
     85          {
     86              INT8U      pip;                                    /* Priority Inheritance Priority (PIP)          */
     87          #if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
     88              OS_CPU_SR  cpu_sr = 0;
     89          #endif
     90          
     91          
     92          
     93          #if OS_ARG_CHK_EN > 0
     94              if (perr == (INT8U *)0) {                          /* Validate 'perr'                              */
     95                  return (OS_FALSE);
     96              }
     97              if (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
     98                  *perr = OS_ERR_PEVENT_NULL;
     99                  return (OS_FALSE);
    100              }
    101          #endif
    102              if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) {  /* Validate event block type                    */
    103                  *perr = OS_ERR_EVENT_TYPE;
    104                  return (OS_FALSE);
    105              }
    106              if (OSIntNesting > 0) {                            /* Make sure it's not called from an ISR        */
    107                  *perr = OS_ERR_PEND_ISR;
    108                  return (OS_FALSE);
    109              }
    110              OS_ENTER_CRITICAL();                               /* Get value (0 or 1) of Mutex                  */
    111              pip = (INT8U)(pevent->OSEventCnt >> 8);            /* Get PIP from mutex                           */
    112              if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
    113                  pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8;   /*      Mask off LSByte (Acquire Mutex)         */
    114                  pevent->OSEventCnt |= OSTCBCur->OSTCBPrio;     /*      Save current task priority in LSByte    */
    115                  pevent->OSEventPtr  = (void *)OSTCBCur;        /*      Link TCB of task owning Mutex           */
    116                  if (OSTCBCur->OSTCBPrio <= pip) {              /*      PIP 'must' have a SMALLER prio ...      */
    117                      OS_EXIT_CRITICAL();                        /*      ... than current task!                  */
    118                      *perr = OS_ERR_PIP_LOWER;
    119                  } else {
    120                      OS_EXIT_CRITICAL();
    121                      *perr = OS_ERR_NONE;
    122                  }
    123                  return (OS_TRUE);
    124              }
    125              OS_EXIT_CRITICAL();
    126              *perr = OS_ERR_NONE;
    127              return (OS_FALSE);
    128          }
    129          #endif
    130          
    131          /*$PAGE*/
    132          /*
    133          *********************************************************************************************************
    134          *                                  CREATE A MUTUAL EXCLUSION SEMAPHORE
    135          *
    136          * Description: This function creates a mutual exclusion semaphore.
    137          *
    138          * Arguments  : prio          is the priority to use when accessing the mutual exclusion semaphore.  In
    139          *                            other words, when the semaphore is acquired and a higher priority task

⌨️ 快捷键说明

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