• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OS_EXIT_CRITICAL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OS_EXIT_CRITICAL函数的典型用法代码示例。如果您正苦于以下问题:C++ OS_EXIT_CRITICAL函数的具体用法?C++ OS_EXIT_CRITICAL怎么用?C++ OS_EXIT_CRITICAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OS_EXIT_CRITICAL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OS_SAFETY_CRITICAL_EXCEPTION

OS_EVENT  *OSMutexCreate (INT8U   prio,
                          INT8U  *perr)
{
    OS_EVENT  *pevent;
#if OS_CRITICAL_METHOD == 3u                               /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return ((OS_EVENT *)0);
    }
#endif

#ifdef OS_SAFETY_CRITICAL_IEC61508
    if (OSSafetyCriticalStartFlag == OS_TRUE) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return ((OS_EVENT *)0);
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
        if (prio >= OS_LOWEST_PRIO) {                      /* Validate PCP                             */
           *perr = OS_ERR_PRIO_INVALID;
            return ((OS_EVENT *)0);
        }
    }
#endif
    if (OSIntNesting > 0u) {                               /* See if called from ISR ...               */
        *perr = OS_ERR_CREATE_ISR;                         /* ... can't CREATE mutex from an ISR       */
        return ((OS_EVENT *)0);
    }
    OS_ENTER_CRITICAL();
    if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
        if (OSTCBPrioTbl[prio] != (OS_TCB *)0) {           /* Mutex priority must not already exist    */
            OS_EXIT_CRITICAL();                            /* Task already exist at priority ...       */
           *perr = OS_ERR_PRIO_EXIST;                      /* ... ceiling priority                     */
            return ((OS_EVENT *)0);
        }
        OSTCBPrioTbl[prio] = OS_TCB_RESERVED;              /* Reserve the table entry                  */
    }

    pevent = OSEventFreeList;                              /* Get next free event control block        */
    if (pevent == (OS_EVENT *)0) {                         /* See if an ECB was available              */
        if (prio != OS_PRIO_MUTEX_CEIL_DIS) {
            OSTCBPrioTbl[prio] = (OS_TCB *)0;              /* No, Release the table entry              */
        }
        OS_EXIT_CRITICAL();
       *perr = OS_ERR_PEVENT_NULL;                         /* No more event control blocks             */
        return (pevent);
    }
    OSEventFreeList     = (OS_EVENT *)OSEventFreeList->OSEventPtr; /* Adjust the free list             */
    OS_EXIT_CRITICAL();
    pevent->OSEventType = OS_EVENT_TYPE_MUTEX;
    pevent->OSEventCnt  = (INT16U)((INT16U)prio << 8u) | OS_MUTEX_AVAILABLE; /* Resource is avail.     */
    pevent->OSEventPtr  = (void *)0;                       /* No task owning the mutex                 */
#if OS_EVENT_NAME_EN > 0u
    pevent->OSEventName = (INT8U *)(void *)"?";
#endif
    OS_EventWaitListInit(pevent);
   *perr = OS_ERR_NONE;
    return (pevent);
}
开发者ID:ChijunShen,项目名称:wildfire_stm32_iso,代码行数:67,代码来源:os_mutex.c


示例2: OSSemPend

/*$PAGE*/
void  OSSemPend (OS_EVENT  *pevent,
                 INT32U     timeout,
                 INT8U     *perr)
{
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return;
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        *perr = OS_ERR_PEVENT_NULL;
        return;
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        *perr = OS_ERR_EVENT_TYPE;
        return;
    }
    if (OSIntNesting > 0u) {                          /* See if called from ISR ...                    */
        *perr = OS_ERR_PEND_ISR;                      /* ... can't PEND from an ISR                    */
        return;
    }
    if (OSLockNesting > 0u) {                         /* See if called with scheduler locked ...       */
        *perr = OS_ERR_PEND_LOCKED;                   /* ... can't PEND when locked                    */
        return;
    }
    OS_ENTER_CRITICAL();
	/* 信号量大于0,则信号量减1,返回 */
    if (pevent->OSEventCnt > 0u) {                    /* If sem. is positive, resource available ...   */
        pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
        OS_EXIT_CRITICAL();
        *perr = OS_ERR_NONE;
        return;
    }
	
	/* 信号量为0,则把TCB中的状态设置为等待信号量,并设置请求状态为请求OK */
                                                      /* Otherwise, must wait until event occurs       */
    OSTCBCur->OSTCBStat     |= OS_STAT_SEM;           /* Resource not available, pend on semaphore     */
    OSTCBCur->OSTCBStatPend  = OS_STAT_PEND_OK;
	/* 把等待时限写入TCB */
    OSTCBCur->OSTCBDly       = timeout;               /* Store pend timeout in TCB                     */
	/* 设置TCB中等待的事件
	 * 设置事件控制块中等待任务列表
	 * 取消当前任务的就绪状态 
	 */
    OS_EventTaskWait(pevent);                         /* Suspend task until event or timeout occurs    */
    OS_EXIT_CRITICAL();
	/* 查找最高优先级的就绪任务,并调度运行 */
    OS_Sched();                                       /* Find next highest priority task ready         */
	/* 执行OS_Sched()后,已经切换到其他任务。执行这里时,已经是信号量有效或者是等待超时了 */
    OS_ENTER_CRITICAL();
	/* 根据状态设置函数返回值 */
    switch (OSTCBCur->OSTCBStatPend) {                /* See if we timed-out or aborted                */
        case OS_STAT_PEND_OK:
             *perr = OS_ERR_NONE;
             break;

        case OS_STAT_PEND_ABORT:
             *perr = OS_ERR_PEND_ABORT;               /* Indicate that we aborted                      */
             break;

        case OS_STAT_PEND_TO:
        default:
			/* 清除事件等待列表中的当前任务 
			 * 因为OSSemPost()而退出等待状态的任务,会在OSSemPost()中清除事件等待列表中的该任务对应位
			 * 因为超时而退出等待状态的任务,对应的事件控制块的事件等待列表中该任务不会被清除,需要在这里清除
			 */
             OS_EventTaskRemove(OSTCBCur, pevent);
             *perr = OS_ERR_TIMEOUT;                  /* Indicate that we didn't get event within TO   */
             break;
    }
	/* 设置当前任务控制块状态 */
    OSTCBCur->OSTCBStat          =  OS_STAT_RDY;      /* Set   task  status to ready                   */
    OSTCBCur->OSTCBStatPend      =  OS_STAT_PEND_OK;  /* Clear pend  status                            */
    OSTCBCur->OSTCBEventPtr      = (OS_EVENT  *)0;    /* Clear event pointers                          */
#if (OS_EVENT_MULTI_EN > 0u)
    OSTCBCur->OSTCBEventMultiPtr = (OS_EVENT **)0;
#endif
    OS_EXIT_CRITICAL();
}
开发者ID:sdwuyawen,项目名称:uCOS-II_V2.92,代码行数:90,代码来源:os_sem.c


示例3: OSTaskDel

INT8U  OSTaskDel (INT8U prio)
{
#if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
    OS_FLAG_NODE *pnode;
#endif
    OS_TCB       *ptcb;
#if OS_CRITICAL_METHOD == 3                             /* Allocate storage for CPU status register    */
    OS_CPU_SR     cpu_sr = 0;
#endif



    if (OSIntNesting > 0) {                             /* See if trying to delete from ISR            */
        return (OS_ERR_TASK_DEL_ISR);
    }
    if (prio == OS_TASK_IDLE_PRIO) {                    /* Not allowed to delete idle task             */
        return (OS_ERR_TASK_DEL_IDLE);
    }
#if OS_ARG_CHK_EN > 0
    if (prio >= OS_LOWEST_PRIO) {                       /* Task priority valid ?                       */
        if (prio != OS_PRIO_SELF) {
            return (OS_ERR_PRIO_INVALID);
        }
    }
#endif

/*$PAGE*/
    OS_ENTER_CRITICAL();
    if (prio == OS_PRIO_SELF) {                         /* See if requesting to delete self            */
        prio = OSTCBCur->OSTCBPrio;                     /* Set priority to delete to current           */
    }
    ptcb = OSTCBPrioTbl[prio];
    if (ptcb == (OS_TCB *)0) {                          /* Task to delete must exist                   */
        OS_EXIT_CRITICAL();
        return (OS_ERR_TASK_NOT_EXIST);
    }
    if (ptcb == OS_TCB_RESERVED) {                      /* Must not be assigned to Mutex               */
        OS_EXIT_CRITICAL();
        return (OS_ERR_TASK_DEL);
    }

    OSRdyTbl[ptcb->OSTCBY] &= ~ptcb->OSTCBBitX;
    if (OSRdyTbl[ptcb->OSTCBY] == 0) {                  /* Make task not ready                         */
        OSRdyGrp           &= ~ptcb->OSTCBBitY;
    }
    
#if (OS_EVENT_EN)
    if (ptcb->OSTCBEventPtr != (OS_EVENT *)0) {
        OS_EventTaskRemove(ptcb, ptcb->OSTCBEventPtr);  /* Remove this task from any event   wait list */
    }
#if (OS_EVENT_MULTI_EN > 0)
    if (ptcb->OSTCBEventMultiPtr != (OS_EVENT **)0) {   /* Remove this task from any events' wait lists*/
        OS_EventTaskRemoveMulti(ptcb, ptcb->OSTCBEventMultiPtr);
    }
#endif
#endif

#if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
    pnode = ptcb->OSTCBFlagNode;
    if (pnode != (OS_FLAG_NODE *)0) {                   /* If task is waiting on event flag            */
        OS_FlagUnlink(pnode);                           /* Remove from wait list                       */
    }
#endif

    ptcb->OSTCBDly      = 0;                            /* Prevent OSTimeTick() from updating          */
    ptcb->OSTCBStat     = OS_STAT_RDY;                  /* Prevent task from being resumed             */
    ptcb->OSTCBStatPend = OS_STAT_PEND_OK;
    if (OSLockNesting < 255u) {                         /* Make sure we don't context switch           */
        OSLockNesting++;
    }
    OS_EXIT_CRITICAL();                                 /* Enabling INT. ignores next instruc.         */
    OS_Dummy();                                         /* ... Dummy ensures that INTs will be         */
    OS_ENTER_CRITICAL();                                /* ... disabled HERE!                          */
    if (OSLockNesting > 0) {                            /* Remove context switch lock                  */
        OSLockNesting--;
    }
    OSTaskDelHook(ptcb);                                /* Call user defined hook                      */
    OSTaskCtr--;                                        /* One less task being managed                 */
    OSTCBPrioTbl[prio] = (OS_TCB *)0;                   /* Clear old priority entry                    */
    if (ptcb->OSTCBPrev == (OS_TCB *)0) {               /* Remove from TCB chain                       */
        ptcb->OSTCBNext->OSTCBPrev = (OS_TCB *)0;
        OSTCBList                  = ptcb->OSTCBNext;
    } else {
        ptcb->OSTCBPrev->OSTCBNext = ptcb->OSTCBNext;
        ptcb->OSTCBNext->OSTCBPrev = ptcb->OSTCBPrev;
    }
    ptcb->OSTCBNext   = OSTCBFreeList;                  /* Return TCB to free TCB list                 */
    OSTCBFreeList     = ptcb;
#if OS_TASK_NAME_SIZE > 1
    ptcb->OSTCBTaskName[0] = '?';                       /* Unknown name                                */
    ptcb->OSTCBTaskName[1] = OS_ASCII_NUL;
#endif
    OS_EXIT_CRITICAL();
    if (OSRunning == OS_TRUE) {
        OS_Sched();                                     /* Find new highest priority task              */
    }
    return (OS_ERR_NONE);
}
开发者ID:0x1abin,项目名称:ebox_stm32,代码行数:98,代码来源:os_task.c


示例4: OSFlagAccept

OS_FLAGS OSFlagAccept(OS_FLAG_GRP * pgrp, OS_FLAGS flags, INT8U wait_type, INT8U * perr)
{
  OS_FLAGS flags_rdy;
  INT8U result;
  BOOLEAN consume;
#if OS_CRITICAL_METHOD == 3     /* Allocate storage for CPU status register */
  OS_CPU_SR cpu_sr = 0;
#endif

#if OS_ARG_CHK_EN > 0
  if (perr == (INT8U *) 0) {    /* Validate 'perr'                          */
    return ((OS_FLAGS) 0);
  }
  if (pgrp == (OS_FLAG_GRP *) 0) {      /* Validate 'pgrp'                          */
    *perr = OS_ERR_FLAG_INVALID_PGRP;
    return ((OS_FLAGS) 0);
  }
#endif
  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type                */
    *perr = OS_ERR_EVENT_TYPE;
    return ((OS_FLAGS) 0);
  }
  result = (INT8U) (wait_type & OS_FLAG_CONSUME);
  if (result != (INT8U) 0) {    /* See if we need to consume the flags      */
    wait_type &= ~OS_FLAG_CONSUME;
    consume = OS_TRUE;
  } else {
    consume = OS_FALSE;
  }
/*$PAGE*/
  *perr = OS_ERR_NONE;          /* Assume NO error until proven otherwise.  */
  OS_ENTER_CRITICAL();
  switch (wait_type) {
  case OS_FLAG_WAIT_SET_ALL:   /* See if all required flags are set        */
    flags_rdy = (OS_FLAGS) (pgrp->OSFlagFlags & flags); /* Extract only the bits we want   */
    if (flags_rdy == flags) {   /* Must match ALL the bits that we want     */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags &= ~flags_rdy;        /* Clear ONLY the flags that we wanted      */
      }
    } else {
      *perr = OS_ERR_FLAG_NOT_RDY;
    }
    OS_EXIT_CRITICAL();
    break;

  case OS_FLAG_WAIT_SET_ANY:
    flags_rdy = (OS_FLAGS) (pgrp->OSFlagFlags & flags); /* Extract only the bits we want   */
    if (flags_rdy != (OS_FLAGS) 0) {    /* See if any flag set                      */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags &= ~flags_rdy;        /* Clear ONLY the flags that we got         */
      }
    } else {
      *perr = OS_ERR_FLAG_NOT_RDY;
    }
    OS_EXIT_CRITICAL();
    break;

#if OS_FLAG_WAIT_CLR_EN > 0
  case OS_FLAG_WAIT_CLR_ALL:   /* See if all required flags are cleared    */
    flags_rdy = (OS_FLAGS) (~pgrp->OSFlagFlags & flags);        /* Extract only the bits we want     */
    if (flags_rdy == flags) {   /* Must match ALL the bits that we want     */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we wanted        */
      }
    } else {
      *perr = OS_ERR_FLAG_NOT_RDY;
    }
    OS_EXIT_CRITICAL();
    break;

  case OS_FLAG_WAIT_CLR_ANY:
    flags_rdy = (OS_FLAGS) (~pgrp->OSFlagFlags & flags);        /* Extract only the bits we want      */
    if (flags_rdy != (OS_FLAGS) 0) {    /* See if any flag cleared                  */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we got           */
      }
    } else {
      *perr = OS_ERR_FLAG_NOT_RDY;
    }
    OS_EXIT_CRITICAL();
    break;
#endif

  default:
    OS_EXIT_CRITICAL();
    flags_rdy = (OS_FLAGS) 0;
    *perr = OS_ERR_FLAG_WAIT_TYPE;
    break;
  }
  return (flags_rdy);
}
开发者ID:huyugui,项目名称:BLDM,代码行数:91,代码来源:os_flag.c


示例5: ambe_decode_wav_hook

/* The ambe_decode_wav() function decodes AMBE2+ bits to 80 samples
   (160 bytes) of 8kHz audio as signed shorts.  This hook will
   optionally print that data to the dmesg buffer, where it can be
   extracted and recorded on the host.
*/
int ambe_decode_wav_hook(int *a1, signed int eighty, char *bitbuffer,
			 int a4, short a5, short a6, int a7){

  /* This prints the AMBE2+ structure that is to be decoded.  The
     output is decodable with DSD, but it sounds horrible.
   */
#ifdef AMBEPRINT
  int ambestate=OS_ENTER_CRITICAL();
  
  short *bits=(short*) bitbuffer;
  static int i;

  /* I don't know why, but this output can only be decoded by DSD if
     half the frames are dropped.  The trick is to only decode those
     when the sixth paramter is zero, ignoring all the ones where that
     parameter is a one.
     
     Strangely enough, we do not skip half the frames of the WAV
     ouput below.
  */
  if(!a6){
    printf("AMBE2+ Corr: ");
    for(i=0;i<49;i++){
      md380_putc(NULL,bits[i]?'1':'0');
    }
    md380_putc(NULL,'\n');
  }
  OS_EXIT_CRITICAL(ambestate);
#endif //AMBEPRINT

  int toret=0xdeadbeef;
#ifdef CONFIG_AMBE
  //First we call the original function.
  toret=ambe_decode_wav(a1, eighty, bitbuffer,
			a4, a5, a6, a7);
#endif

  /* Print the parameters
  printf("ambe_decode_wav(0x%08x, %d, 0x%08x,\n"
    "%d, %d, %d, 0x%08x);\n",
    a1, eighty, bitbuffer,
    a4, a5, a6, a7);
  */

  /* This is very noisy, so we don't enable it by default.  It prints
     the WAV as hex pairs, which will quickly flood the buffer if it
     isn't cleared in time.
   */
#ifdef AMBEWAVPRINT
  //Does this really need to be in a critical section?
  int wavstate=OS_ENTER_CRITICAL();
  
  //A1 holds audio as signed LE shorts.
  printf("WAV: ");
  printhex(a1,160);
  printf("\n");
  
  OS_EXIT_CRITICAL(wavstate);
#endif //AMBEWAVPRINT

  
  return toret;
}
开发者ID:on6cg,项目名称:md380tools,代码行数:68,代码来源:ambe.c


示例6: OS_SAFETY_CRITICAL_EXCEPTION

void  *OSQPend (OS_EVENT  *pevent,
                INT32U     timeout,
                INT8U     *perr)
{
    void      *pmsg;
    OS_Q      *pq;
#if OS_CRITICAL_METHOD == 3u                     /* Allocate storage for CPU status register           */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (pevent == (OS_EVENT *)0) {               /* Validate 'pevent'                                  */
        *perr = OS_ERR_PEVENT_NULL;
        return ((void *)0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type                          */
        *perr = OS_ERR_EVENT_TYPE;
        return ((void *)0);
    }
    if (OSIntNesting > 0u) {                     /* See if called from ISR ...                         */
        *perr = OS_ERR_PEND_ISR;                 /* ... can't PEND from an ISR                         */
        return ((void *)0);
    }
    if (OSLockNesting > 0u) {                    /* See if called with scheduler locked ...            */
        *perr = OS_ERR_PEND_LOCKED;              /* ... can't PEND when locked                         */
        return ((void *)0);
    }
    OS_ENTER_CRITICAL();
    pq = (OS_Q *)pevent->OSEventPtr;             /* Point at queue control block                       */
    if (pq->OSQEntries > 0u) {                   /* See if any messages in the queue                   */
        pmsg = *pq->OSQOut++;                    /* Yes, extract oldest message from the queue         */
        pq->OSQEntries--;                        /* Update the number of entries in the queue          */
        if (pq->OSQOut == pq->OSQEnd) {          /* Wrap OUT pointer if we are at the end of the queue */
            pq->OSQOut = pq->OSQStart;
        }
        OS_EXIT_CRITICAL();
        *perr = OS_ERR_NONE;
        return (pmsg);                           /* Return message received                            */
    }
    OSTCBCur->OSTCBStat     |= OS_STAT_Q;        /* Task will have to pend for a message to be posted  */
    OSTCBCur->OSTCBStatPend  = OS_STAT_PEND_OK;
    OSTCBCur->OSTCBDly       = timeout;          /* Load timeout into TCB                              */
    OS_EventTaskWait(pevent);                    /* Suspend task until event or timeout occurs         */
    OS_EXIT_CRITICAL();
    OS_Sched();                                  /* Find next highest priority task ready to run       */
    OS_ENTER_CRITICAL();
    switch (OSTCBCur->OSTCBStatPend) {                /* See if we timed-out or aborted                */
        case OS_STAT_PEND_OK:                         /* Extract message from TCB (Put there by QPost) */
             pmsg =  OSTCBCur->OSTCBMsg;
            *perr =  OS_ERR_NONE;
             break;

        case OS_STAT_PEND_ABORT:
             pmsg = (void *)0;
            *perr =  OS_ERR_PEND_ABORT;               /* Indicate that we aborted                      */
             break;

        case OS_STAT_PEND_TO:
        default:
             OS_EventTaskRemove(OSTCBCur, pevent);
             pmsg = (void *)0;
            *perr =  OS_ERR_TIMEOUT;                  /* Indicate that we didn't get event within TO   */
             break;
    }
    OSTCBCur->OSTCBStat          =  OS_STAT_RDY;      /* Set   task  status to ready                   */
    OSTCBCur->OSTCBStatPend      =  OS_STAT_PEND_OK;  /* Clear pend  status                            */
    OSTCBCur->OSTCBEventPtr      = (OS_EVENT  *)0;    /* Clear event pointers                          */
#if (OS_EVENT_MULTI_EN > 0u)
    OSTCBCur->OSTCBEventMultiPtr = (OS_EVENT **)0;
#endif
    OSTCBCur->OSTCBMsg           = (void      *)0;    /* Clear  received message                       */
    OS_EXIT_CRITICAL();
    return (pmsg);                                    /* Return received message                       */
}
开发者ID:cxy560,项目名称:ZCloud-WM,代码行数:83,代码来源:os_q.c


示例7: OSFlagPend

OS_FLAGS OSFlagPend(OS_FLAG_GRP * pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U * perr)
{
  OS_FLAG_NODE node;
  OS_FLAGS flags_rdy;
  INT8U result;
  INT8U pend_stat;
  BOOLEAN consume;
#if OS_CRITICAL_METHOD == 3     /* Allocate storage for CPU status register */
  OS_CPU_SR cpu_sr = 0;
#endif

#if OS_ARG_CHK_EN > 0
  if (perr == (INT8U *) 0) {    /* Validate 'perr'                          */
    return ((OS_FLAGS) 0);
  }
  if (pgrp == (OS_FLAG_GRP *) 0) {      /* Validate 'pgrp'                          */
    *perr = OS_ERR_FLAG_INVALID_PGRP;
    return ((OS_FLAGS) 0);
  }
#endif
  if (OSIntNesting > 0) {       /* See if called from ISR ...               */
    *perr = OS_ERR_PEND_ISR;    /* ... can't PEND from an ISR               */
    return ((OS_FLAGS) 0);
  }
  if (OSLockNesting > 0) {      /* See if called with scheduler locked ...  */
    *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked               */
    return ((OS_FLAGS) 0);
  }
  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type                */
    *perr = OS_ERR_EVENT_TYPE;
    return ((OS_FLAGS) 0);
  }
  result = (INT8U) (wait_type & OS_FLAG_CONSUME);
  if (result != (INT8U) 0) {    /* See if we need to consume the flags      */
    wait_type &= ~(INT8U) OS_FLAG_CONSUME;
    consume = OS_TRUE;
  } else {
    consume = OS_FALSE;
  }
/*$PAGE*/
  OS_ENTER_CRITICAL();
  switch (wait_type) {
  case OS_FLAG_WAIT_SET_ALL:   /* See if all required flags are set        */
    flags_rdy = (OS_FLAGS) (pgrp->OSFlagFlags & flags); /* Extract only the bits we want     */
    if (flags_rdy == flags) {   /* Must match ALL the bits that we want     */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags &= ~flags_rdy;        /* Clear ONLY the flags that we wanted      */
      }
      OSTCBCur->OSTCBFlagsRdy = flags_rdy;      /* Save flags that were ready               */
      OS_EXIT_CRITICAL();       /* Yes, condition met, return to caller     */
      *perr = OS_ERR_NONE;
      return (flags_rdy);
    } else {                    /* Block task until events occur or timeout */
      OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
      OS_EXIT_CRITICAL();
    }
    break;

  case OS_FLAG_WAIT_SET_ANY:
    flags_rdy = (OS_FLAGS) (pgrp->OSFlagFlags & flags); /* Extract only the bits we want    */
    if (flags_rdy != (OS_FLAGS) 0) {    /* See if any flag set                      */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags &= ~flags_rdy;        /* Clear ONLY the flags that we got         */
      }
      OSTCBCur->OSTCBFlagsRdy = flags_rdy;      /* Save flags that were ready               */
      OS_EXIT_CRITICAL();       /* Yes, condition met, return to caller     */
      *perr = OS_ERR_NONE;
      return (flags_rdy);
    } else {                    /* Block task until events occur or timeout */
      OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
      OS_EXIT_CRITICAL();
    }
    break;

#if OS_FLAG_WAIT_CLR_EN > 0
  case OS_FLAG_WAIT_CLR_ALL:   /* See if all required flags are cleared    */
    flags_rdy = (OS_FLAGS) (~pgrp->OSFlagFlags & flags);        /* Extract only the bits we want     */
    if (flags_rdy == flags) {   /* Must match ALL the bits that we want     */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we wanted        */
      }
      OSTCBCur->OSTCBFlagsRdy = flags_rdy;      /* Save flags that were ready               */
      OS_EXIT_CRITICAL();       /* Yes, condition met, return to caller     */
      *perr = OS_ERR_NONE;
      return (flags_rdy);
    } else {                    /* Block task until events occur or timeout */
      OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
      OS_EXIT_CRITICAL();
    }
    break;

  case OS_FLAG_WAIT_CLR_ANY:
    flags_rdy = (OS_FLAGS) (~pgrp->OSFlagFlags & flags);        /* Extract only the bits we want      */
    if (flags_rdy != (OS_FLAGS) 0) {    /* See if any flag cleared                  */
      if (consume == OS_TRUE) { /* See if we need to consume the flags      */
        pgrp->OSFlagFlags |= flags_rdy; /* Set ONLY the flags that we got           */
      }
      OSTCBCur->OSTCBFlagsRdy = flags_rdy;      /* Save flags that were ready               */
      OS_EXIT_CRITICAL();       /* Yes, condition met, return to caller     */
      *perr = OS_ERR_NONE;
//.........这里部分代码省略.........
开发者ID:huyugui,项目名称:BLDM,代码行数:101,代码来源:os_flag.c


示例8: OSFlagPend

//等待事件标志组的事件标志位(事件组指针、需要检查的标志位、等待事件标志位的方式、允许等待
//的时钟节拍、出错代码的时钟节拍)	 
OS_FLAGS  OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR     cpu_sr;
#endif
    OS_FLAG_NODE  node;
    OS_FLAGS      flags_cur;
    OS_FLAGS      flags_rdy;
    BOOLEAN       consume;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_PEND_ISR;                            /* ... can't PEND from an ISR               */
        return ((OS_FLAGS)0);
    }
#if OS_ARG_CHK_EN > 0
    if (pgrp == (OS_FLAG_GRP *)0) {                        /* Validate 'pgrp'                          */
        *err = OS_FLAG_INVALID_PGRP;
        return ((OS_FLAGS)0);
    }
    if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {          /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return ((OS_FLAGS)0);
    }
#endif
    if (wait_type & OS_FLAG_CONSUME) {                     /* See if we need to consume the flags      */
        wait_type &= ~OS_FLAG_CONSUME;
        consume    = TRUE;
    } else {
        consume    = FALSE;
    }
/*$PAGE*/
    OS_ENTER_CRITICAL();
    switch (wait_type) {
        case OS_FLAG_WAIT_SET_ALL:                         /* See if all required flags are set        */
             flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we want            */
             if (flags_rdy == flags) {                     /* Must match ALL the bits that we want     */
                 if (consume == TRUE) {                    /* See if we need to consume the flags      */
                     pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that we wanted      */
                 }
                 flags_cur = pgrp->OSFlagFlags;            /* Will return the state of the group       */
                 OS_EXIT_CRITICAL();                       /* Yes, condition met, return to caller     */
                 *err      = OS_NO_ERR;
                 return (flags_cur);
             } else {                                      /* Block task until events occur or timeout */
                 OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                 OS_EXIT_CRITICAL();
             }
             break;

        case OS_FLAG_WAIT_SET_ANY:
             flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we want            */
             if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag set                      */
                 if (consume == TRUE) {                    /* See if we need to consume the flags      */
                     pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that we got         */
                 }
                 flags_cur = pgrp->OSFlagFlags;            /* Will return the state of the group       */
                 OS_EXIT_CRITICAL();                       /* Yes, condition met, return to caller     */
                 *err      = OS_NO_ERR;
                 return (flags_cur);
             } else {                                      /* Block task until events occur or timeout */
                 OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                 OS_EXIT_CRITICAL();
             }
             break;

#if OS_FLAG_WAIT_CLR_EN > 0
        case OS_FLAG_WAIT_CLR_ALL:                         /* See if all required flags are cleared    */
             flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we want            */
             if (flags_rdy == flags) {                     /* Must match ALL the bits that we want     */
                 if (consume == TRUE) {                    /* See if we need to consume the flags      */
                     pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we wanted        */
                 }
                 flags_cur = pgrp->OSFlagFlags;            /* Will return the state of the group       */
                 OS_EXIT_CRITICAL();                       /* Yes, condition met, return to caller     */
                 *err      = OS_NO_ERR;
                 return (flags_cur);
             } else {                                      /* Block task until events occur or timeout */
                 OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                 OS_EXIT_CRITICAL();
             }
             break;

        case OS_FLAG_WAIT_CLR_ANY:
             flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we want            */
             if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag cleared                  */
                 if (consume == TRUE) {                    /* See if we need to consume the flags      */
                     pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we got           */
                 }
                 flags_cur = pgrp->OSFlagFlags;            /* Will return the state of the group       */
                 OS_EXIT_CRITICAL();                       /* Yes, condition met, return to caller     */
                 *err      = OS_NO_ERR;
                 return (flags_cur);
             } else {                                      /* Block task until events occur or timeout */
                 OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                 OS_EXIT_CRITICAL();
             }
             break;
//.........这里部分代码省略.........
开发者ID:koson,项目名称:ecliscep_airfly,代码行数:101,代码来源:OS_FLAG.C


示例9: OS_SAFETY_CRITICAL_EXCEPTION

OS_MEM  *OSMemCreate (void   *addr,
                      INT32U  nblks,
                      INT32U  blksize,
                      INT8U  *perr)
{
    OS_MEM    *pmem;
    INT8U     *pblk;
    void     **plink;
    INT32U     loops;
    INT32U     i;
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#ifdef OS_SAFETY_CRITICAL_IEC61508
    if (OSSafetyCriticalStartFlag == OS_TRUE) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0u
    if (addr == (void *)0) {                          /* Must pass a valid address for the memory part.*/
        *perr = OS_ERR_MEM_INVALID_ADDR;
        return ((OS_MEM *)0);
    }
    if (((INT32U)addr & (sizeof(void *) - 1u)) != 0u){  /* Must be pointer size aligned                */
        *perr = OS_ERR_MEM_INVALID_ADDR;
        return ((OS_MEM *)0);
    }
    if (nblks < 2u) {                                 /* Must have at least 2 blocks per partition     */
        *perr = OS_ERR_MEM_INVALID_BLKS;
        return ((OS_MEM *)0);
    }
    if (blksize < sizeof(void *)) {                   /* Must contain space for at least a pointer     */
        *perr = OS_ERR_MEM_INVALID_SIZE;
        return ((OS_MEM *)0);
    }
#endif
    OS_ENTER_CRITICAL();
    pmem = OSMemFreeList;                             /* Get next free memory partition                */
    if (OSMemFreeList != (OS_MEM *)0) {               /* See if pool of free partitions was empty      */
        OSMemFreeList = (OS_MEM *)OSMemFreeList->OSMemFreeList;
    }
    OS_EXIT_CRITICAL();
    if (pmem == (OS_MEM *)0) {                        /* See if we have a memory partition             */
        *perr = OS_ERR_MEM_INVALID_PART;
        return ((OS_MEM *)0);
    }
    plink = (void **)addr;                            /* Create linked list of free memory blocks      */
    pblk  = (INT8U *)addr;
    loops  = nblks - 1u;
    for (i = 0u; i < loops; i++) {
        pblk +=  blksize;                             /* Point to the FOLLOWING block                  */
       *plink = (void  *)pblk;                        /* Save pointer to NEXT block in CURRENT block   */
        plink = (void **)pblk;                        /* Position to  NEXT      block                  */
    }
    *plink              = (void *)0;                  /* Last memory block points to NULL              */
    pmem->OSMemAddr     = addr;                       /* Store start address of memory partition       */
    pmem->OSMemFreeList = addr;                       /* Initialize pointer to pool of free blocks     */
    pmem->OSMemNFree    = nblks;                      /* Store number of free blocks in MCB            */
    pmem->OSMemNBlks    = nblks;
    pmem->OSMemBlkSize  = blksize;                    /* Store block size of each memory blocks        */
    *perr               = OS_ERR_NONE;
    return (pmem);
}
开发者ID:cxy560,项目名称:ZCloud-WM,代码行数:73,代码来源:os_mem.c


示例10: abx_mem_check_free

void abx_mem_check_free( void *buf)
{
	size_t old_size;
	INT8U* ptr = buf;
	int i;
    DECLARE_CPU_SR;

	if(ptr == NULL)
	{
		printf("abx_mem_free1\n");
		while(1);
	}

	if ((u32_t)ptr % 4)
	{
		printf("abx_mem_free2\n");
		while(1);
	}

	ptr -= 20;
		
	if((u32_t)ptr < ABX_MIN_MEM_PTR)
	{
		printf("abx_mem_free3\n");
		while(1);
	}
	
	if((u32_t)ptr >= ABX_MAX_MEM_PTR)
	{
		printf("abx_mem_free4\n");
		while(1);
	}
	
	if(memcmp(ptr, &mem_magic_head, 4))
	{
		printf("abx_mem_free5\n");
		while(1);
	}
	
	*(u32_t*)(ptr) = mem_free_magic_head;

	old_size = *(u32_t*)(ptr+4);
	
	if(memcmp(ptr + 20 + old_size, &mem_magic_tail, 4))
	{
		printf("abx_mem_free6\n");
		while(1);
	}
	
	memcpy(ptr + 20 + old_size, &mem_free_magic_tail, 4);

	if(g_abx_mem_used < old_size)
	{
		printf("abx_mem_free7\n");
		while(1);
	}
	
	//his
	OS_ENTER_CRITICAL();
	for(i=0; i< ABX_MEM_HIS_SIZE; i++)
	{
		if(g_abx_mem_his[i] == (abx_mem_struct_type*)ptr)
		{
			g_abx_mem_his[i] = NULL;
			g_abx_mem_his_used--;
			break;
		}
	}
	g_abx_mem_used -= old_size;
	OS_EXIT_CRITICAL();
	
	if(i >= ABX_MEM_HIS_SIZE)
	{
		printf("abx_mem_free(his1)\n");
		while(1);
	}

	AVMem_free(ptr);

}
开发者ID:Pivosgroup,项目名称:aml-original-linux-buildroot,代码行数:80,代码来源:abx_mem.c


示例11: AVMem_kmalloc

void *abx_mem_check_malloc( size_t size, const char* file, INT16U line)
{
	INT8U *ret;
	size_t new_size;
	char *sp;
	int i;
    DECLARE_CPU_SR;

	new_size = size + 24;
	
	ret = AVMem_kmalloc(new_size);

	if(ret)
	{
		if ((u32_t)ret % 4)
		{
			printf("abx_mem_malloc1\n");
			while(1);
		}
			
		if((u32_t)ret < ABX_MIN_MEM_PTR)
		{
			printf("abx_mem_malloc2\n");
			while(1);
		}
		
		if((u32_t)ret >= ABX_MAX_MEM_PTR)
		{
			printf("abx_mem_malloc3\n");
			while(1);
		}

		//his
		OS_ENTER_CRITICAL();
		for(i=0; i< ABX_MEM_HIS_SIZE; i++)
		{
			if(g_abx_mem_his[i] == NULL)
			{
				g_abx_mem_his[i] = (abx_mem_struct_type*)ret;
				g_abx_mem_his_used++;
				break;
			}
		}
		g_abx_mem_used += size;
		OS_EXIT_CRITICAL();
		
		if(i >= ABX_MEM_HIS_SIZE)
		{
			printf("abx_mem_malloc(his1)\n");
			while(1);
		}


		memcpy(ret, &mem_magic_head, 4);
		
		ret += 4;

		*(u32_t*)ret = size;

		ret += 4;
		
		sp = strrchr((char*)file, '/');
		if(!sp)
			sp = (char*)file;
		_rstrncpy((char*)ret, sp, 10);

		ret += 10;
		
		*(INT16U*)ret = line;

		ret += 2;
		
		memcpy(ret + size, &mem_magic_tail, 4);

	} 
	
	return ret;
}
开发者ID:Pivosgroup,项目名称:aml-original-linux-buildroot,代码行数:78,代码来源:abx_mem.c


示例12: printf

void *abx_mem_check_realloc( void *buf, size_t size, const char* file, INT16U line)
{
	size_t old_size;
	INT8U* ptr = buf;
	INT8U* ret;
	char *sp;
	int i;
    DECLARE_CPU_SR;

	if(ptr)
	{
		if ((u32_t)ptr % 4)
		{
			printf("abx_mem_realloc1\n");
			while(1);
		}

		ptr -= 20;
			
		if((u32_t)ptr < ABX_MIN_MEM_PTR)
		{
			printf("abx_mem_realloc2\n");
			while(1);
		}
		
		if((u32_t)ptr >= ABX_MAX_MEM_PTR)
		{
			printf("abx_mem_realloc3\n");
			while(1);
		}
		
		if(memcmp(ptr, &mem_magic_head, 4))
		{
			printf("abx_mem_realloc4\n");
			while(1);
		}

		old_size = *(u32_t*)(ptr+4);
		
		if(memcmp(ptr + 20 + old_size, &mem_magic_tail, 4))
		{
			printf("abx_mem_realloc5\n");
			while(1);
		}

		if(g_abx_mem_used < old_size)
		{
			printf("abx_mem_realloc6\n");
			while(1);
		}

		//his
		OS_ENTER_CRITICAL();
		for(i=0; i< ABX_MEM_HIS_SIZE; i++)
		{
			if(g_abx_mem_his[i] == (abx_mem_struct_type*)ptr)
			{
				break;
			}
		}
		OS_EXIT_CRITICAL();
		if(i >= ABX_MEM_HIS_SIZE)
		{
			printf("abx_mem_realloc(his1)\n");
			while(1);
		}
	}

	ret = AVMem_krealloc(ptr, size);

	if(ret)
	{
		if ((u32_t)ret % 4)
		{
			printf("abx_mem_realloc7\n");
			while(1);
		}
			
		if((u32_t)ret < ABX_MIN_MEM_PTR)
		{
			printf("abx_mem_realloc8\n");
			while(1);
		}
		
		if((u32_t)ret >= ABX_MAX_MEM_PTR)
		{
			printf("abx_mem_realloc9\n");
			while(1);
		}
		
		//his
		OS_ENTER_CRITICAL();
		if(ptr)
		{
			if(i >= ABX_MEM_HIS_SIZE)
			{
				printf("abx_mem_realloc(his2)\n");
				while(1);
			}
			g_abx_mem_his[i] = (abx_mem_struct_type*)ret;
//.........这里部分代码省略.........
开发者ID:Pivosgroup,项目名称:aml-original-linux-buildroot,代码行数:101,代码来源:abx_mem.c


示例13: Input_Task

void Input_Task(void *parg)
{
	u8 err;
	u8 OK=0;
	u8 buffer[4]={0};
	u8 LEN=0;
	u8 flag=0;
	u16 e=0;
	OS_CPU_SR cpu_sr;
	(void)parg;
	for(;;)
	{
		OSSemPend(PENIRQ,0,&err);
		Exti_Set(0);
		OS_ENTER_CRITICAL();
		touch.FLAG=Read_XY_2(&touch.AD_X,&touch.AD_Y);
		OS_EXIT_CRITICAL();
		if(touch.FLAG)
		{
			Led_On(1);
			touch.FLAG=0;
			touch.LCD_X=CalcXY(touch.AD_X,0);
			touch.LCD_Y=CalcXY(touch.AD_Y,1);
			touch.KEY=Get_Key(touch.PID,touch.LCD_X,touch.LCD_Y);
			if(touch.KEY<=10)
			{
				OS_ENTER_CRITICAL();
				Set_Color(WHITE,BLACK);
				if(touch.KEY==10)
					Show_Char('.',cursor.x,cursor.y);
				else
				{
					Show_Dec(touch.KEY,1,cursor.x,cursor.y);
					if(LEN<4)
					{
						buffer[LEN]=touch.KEY;
						LEN++;
					}
				}
				if(cursor.x<224)
				{
					cursor.x+=8;
					if(cursor.x>=224)
						cursor.x=224;
				}
				OS_EXIT_CRITICAL();
			}
		
			else if(touch.KEY==11)
			{
				OK++;
				if(OK==1)
				{
					VALUE1=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE1:",2,22);
					Show_Dec(VALUE1,LEN,82,22);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==2)
				{
					VALUE2=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE2:",2,38);
					Show_Dec(VALUE2,LEN,82,38);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==3)
				{
					VALUE3=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE3:",2,54);
					Show_Dec(VALUE3,LEN,82,54);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
//.........这里部分代码省略.........
开发者ID:yuiopt,项目名称:uCOSII-Demo,代码行数:101,代码来源:app.c


示例14: udpRead

int udpRead(u_int ud, void* buf, long len)
{
    unsigned char* d;
    int rtn;
    NBuf* b;
    UDP_QUEUE* q;
    struct in_addr fromAddr;
    UBYTE err;

//    TRACE("udpRead(%d,%p,%ld)\n",ud,buf,len);

    if (!(udps[ud].flags & FUDP_OPEN)) return -1;
    d = (unsigned char*)buf;
    rtn = 0;
    OSSemPend(udps[ud].sem, 0, &err);
    if (udps[ud].head == NULL) {
        return -1;
    }
    fromAddr = udps[ud].theirAddr = udps[ud].head->srcAddr;
    udps[ud].theirPort = udps[ud].head->srcPort;

    UDPDEBUG(("fromAddr.s_addr = %08X,   udps[ud].head->srcAddr.s_addr = %08X\n", fromAddr.s_addr, udps[ud].head->srcAddr.s_addr));

    while ((udps[ud].head) && (len) && (fromAddr.s_addr == udps[ud].head->srcAddr.s_addr)) {
        // Get next nBuf
        b = udps[ud].head->nBuf;
        // While we have more buffer to copy out to AND
        // We have a queued nBuf
        while ((len) && (b)) {
        // While we have more buffer space to copy to AND
        // nBuf is not empty
//            while ((len) && (b->data != &b->body[b->len])) {
            while ( (len) && (b->len) )	{
		// Copy one byte
                *d++ = *b->data++;
                b->len--; 
                len--;
                rtn++;
            }
	    // If nBuf is empty
//            if (b->data == &b->body[b->len]) {
            if (!b->len) {
                OS_ENTER_CRITICAL();
                b = udps[ud].head->nBuf = nFree(b);
                OS_EXIT_CRITICAL();
            }
        }
        // If nBuf was freed (we need another one if any)
        if (b == NULL) {
            // Get next nBuf in queue
            q = udps[ud].head;
            OS_ENTER_CRITICAL();
            udps[ud].head = q->next;
            OS_EXIT_CRITICAL();
            free_udp_q(q);
            #if ONETASK_SUPPORT > 0
            #else
            if (udps[ud].head)
                OSSemPend(udps[ud].sem, 0, &err);
            #endif
        } else {
            #if ONETASK_SUPPORT > 0
            // nBuf was not freed but we have filled our buffer (buf) 
            return rtn;
            #else
            OSSemPost(udps[ud].sem);
            #endif
        }
    }
    if (udps[ud].head == NULL)
        udps[ud].tail = NULL;
    return rtn;
}
开发者ID:ak869,项目名称:armcontroller,代码行数:73,代码来源:netudp.c


示例15: OS_SAFETY_CRITICAL_EXCEPTION

/*$PAGE*/
void  *OSMboxPend (OS_EVENT  *pevent,
                   INT32U     timeout,
                   INT8U     *perr)
{
    void      *pmsg;
#if OS_CRITICAL_METHOD == 3u                          /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr = 0u;
#endif



#ifdef OS_SAFETY_CRITICAL
    if (perr == (INT8U *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
    }
#endif

#if OS_ARG_CHK_EN > 0 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OS_EventTaskRdy函数代码示例发布时间:2022-05-30
下一篇:
C++ OS_ENTER_CRITICAL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap