当前位置: 首页>>代码示例>>C++>>正文


C++ CPU_SR_ALLOC函数代码示例

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


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

示例1: led0_task

//led0任务函数
void led0_task(void *p_arg)
{
	OS_ERR err;
	u8 test[20];
	u8 times = 0;
	CPU_SR_ALLOC();
	u8 temp;	
	p_arg = p_arg;
	while(1)
	{
		OS_CRITICAL_ENTER();
		temp = FloatTaskTCB.MsgQ.NbrEntriesSize - FloatTaskTCB.MsgQ.NbrEntries;
		printf("que remain %d.\r\n",temp);
		OS_CRITICAL_EXIT();	
		sprintf((char *)test,"led_send_que %d",times++);
		printf("led0 task send que.\r\n");
		OSTaskQPost((OS_TCB*	)&FloatTaskTCB,	//向任务Msgdis发送消息
					(void*		)test,
          (OS_MSG_SIZE)20,
          (OS_OPT		)OS_OPT_POST_FIFO,
					(OS_ERR*	)&err);
				
		OSTimeDlyHMSM(0,0,1,0,OS_OPT_TIME_HMSM_STRICT,&err); //延时1s	
			
	}
}
开发者ID:BearZPY,项目名称:STM32-uCOSIII,代码行数:27,代码来源:led_task.c

示例2: CPU_SR_ALLOC

void  *SerialOS_SemCreate (CPU_INT16U  cnt)
{
    OS_EVENT  *psem;
    INT8U      os_err;
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    if (OSEventObjIx < 1u) {
        CPU_CRITICAL_EXIT();
        return ((void *)0);
    }

    if (OSEventObjIx > SERIAL_OS_MAX_NBR_SEM) {
        CPU_CRITICAL_EXIT();
        return ((void *)0);
    }

                                                                /* -------------- GET OS EVENT FROM POOL -------------- */
    OSEventObjIx--;
    psem = OSEventObj[OSEventObjIx];
    CPU_CRITICAL_EXIT();

    OSSemSet(psem, cnt, &os_err);

    return ((void *)psem);
}
开发者ID:ptracton,项目名称:experimental,代码行数:27,代码来源:serial_os.c

示例3: OS_TLS_LockDel

void  OS_TLS_LockDel (void  *p_lock)
{
    OS_TLS_LOCK   *p_tls_lock;
    OS_ERR         os_err;
    CPU_SR_ALLOC();

    
    if (p_lock == (void *)0) {
        return;
    }
    
    p_tls_lock = (OS_TLS_LOCK *)p_lock;

    (void)OSMutexDel((OS_MUTEX *)&p_tls_lock->Mutex,
                     (OS_OPT    ) OS_OPT_DEL_ALWAYS,
                     (OS_ERR   *)&os_err);
    (void)&os_err;

    CPU_CRITICAL_ENTER();
                                                                  /* Return the OS_TLS_LOCK in front of the list      */
    if (OS_TLS_LockPoolListPtr == (OS_TLS_LOCK *)0) {
        p_tls_lock->NextPtr  = (OS_TLS_LOCK *)0;
    } else {
        p_tls_lock->NextPtr = OS_TLS_LockPoolListPtr;
    }
    OS_TLS_LockPoolListPtr = p_tls_lock;                      

    CPU_CRITICAL_EXIT();
}
开发者ID:Akagi201,项目名称:uCOS-III,代码行数:29,代码来源:os_tls.c

示例4: SerialBuf_WrOctet

CPU_BOOLEAN  SerialBuf_WrOctet (SERIAL_BUF  *pbuf,
                                CPU_INT08U   datum)
{
    CPU_SIZE_T  empty_cnt;
    CPU_SIZE_T  ix_wr;
    CPU_SIZE_T  len;
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    empty_cnt = pbuf->EmptyCnt;

    if (empty_cnt == 0) {
        CPU_CRITICAL_EXIT();
        return (DEF_NO);
    }

    ix_wr                = pbuf->IxWr;
    pbuf->DataPtr[ix_wr] = datum;
    pbuf->EmptyCnt       = empty_cnt - 1;
    len                  = pbuf->Len;

    if (ix_wr + 1 == len) {
        pbuf->IxWr = 0;
    } else {
        pbuf->IxWr = ix_wr + 1;
    }
    CPU_CRITICAL_EXIT();

    return (DEF_YES);
}
开发者ID:ptracton,项目名称:experimental,代码行数:31,代码来源:serial_buf.c

示例5: SerialBuf_RdOctet

CPU_BOOLEAN  SerialBuf_RdOctet (SERIAL_BUF  *pbuf,
                                CPU_INT08U  *pdatum)
{
    CPU_SIZE_T  empty_cnt;
    CPU_SIZE_T  ix_rd;
    CPU_SIZE_T  len;
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    len       = pbuf->Len;
    empty_cnt = pbuf->EmptyCnt;

    if (empty_cnt == len) {
        CPU_CRITICAL_EXIT();
        return (DEF_NO);
    }

    ix_rd          = pbuf->IxRd;
   *pdatum         = pbuf->DataPtr[ix_rd];
    pbuf->EmptyCnt = empty_cnt + 1;

    if (ix_rd + 1 == len) {
        pbuf->IxRd = 0;
    } else {
        pbuf->IxRd = ix_rd + 1;
    }
    CPU_CRITICAL_EXIT();

    return (DEF_YES);
}
开发者ID:ptracton,项目名称:experimental,代码行数:31,代码来源:serial_buf.c

示例6: CPU_SR_ALLOC

void  *OSMemGet (OS_MEM  *p_mem,
                 OS_ERR  *p_err)
{
    void    *p_blk;
    CPU_SR_ALLOC();



#ifdef OS_SAFETY_CRITICAL
    if (p_err == (OS_ERR *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return ((void *)0);
    }
#endif

#if OS_CFG_ARG_CHK_EN > 0u
    if (p_mem == (OS_MEM *)0) {                             /* Must point to a valid memory partition                 */
       *p_err  = OS_ERR_MEM_INVALID_P_MEM;
        return ((void *)0);
    }
#endif

    CPU_CRITICAL_ENTER();
    if (p_mem->NbrFree == (OS_MEM_QTY)0) {                  /* See if there are any free memory blocks                */
        CPU_CRITICAL_EXIT();
       *p_err = OS_ERR_MEM_NO_FREE_BLKS;                    /* No,  Notify caller of empty memory partition           */
        return ((void *)0);                                 /*      Return NULL pointer to caller                     */
    }
    p_blk              = p_mem->FreeListPtr;                /* Yes, point to next free memory block                   */
    p_mem->FreeListPtr = *(void **)p_blk;                   /*      Adjust pointer to new free list                   */
    p_mem->NbrFree--;                                       /*      One less memory block in this partition           */
    CPU_CRITICAL_EXIT();
   *p_err = OS_ERR_NONE;                                    /*      No error                                          */
    return (p_blk);                                         /*      Return memory block to caller                     */
}
开发者ID:FanNiu,项目名称:wildfire_stm32_iso_mini,代码行数:35,代码来源:os_mem.c

示例7: OS_TLS_SetDestruct

void  OS_TLS_SetDestruct (OS_TLS_ID            id,
                          OS_TLS_DESTRUCT_PTR  p_destruct,
                          OS_ERR              *p_err)
{
    CPU_SR_ALLOC();


#ifdef OS_SAFETY_CRITICAL
    if (p_err == (OS_ERR *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return;
    }
#endif

    if (id >= OS_TLS_NextAvailID) {                             /* See if we exceeded the number of TLS IDs available */
       *p_err = OS_ERR_TLS_ID_INVALID;
        return;
    }
     
    if (OS_TLS_DestructPtrTbl[id] != (OS_TLS_DESTRUCT_PTR)0) {  /* Can only assign a destructor once                  */
       *p_err = OS_ERR_TLS_DESTRUCT_ASSIGNED;
        return;
    }
     
    CPU_CRITICAL_ENTER();
    OS_TLS_DestructPtrTbl[id] = p_destruct;
    CPU_CRITICAL_EXIT();
   *p_err                     = OS_ERR_NONE;
}
开发者ID:Akagi201,项目名称:uCOS-III,代码行数:29,代码来源:os_tls.c

示例8: SerialBuf_Cmp

CPU_BOOLEAN  SerialBuf_Cmp (SERIAL_BUF  *pbuf,
                            CPU_INT08U   datum)
{
    CPU_SIZE_T   ix_rd;
    CPU_BOOLEAN  full;
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    full = SerialBuf_IsFull(pbuf);
    if (full == DEF_NO) {
        CPU_CRITICAL_EXIT();
        return (DEF_NO);
    }

    ix_rd = pbuf->IxRd;
    if(pbuf->DataPtr[ix_rd] != datum) {
        pbuf->IxRd = 0;                                         /* Reset comparison.                                    */
        CPU_CRITICAL_EXIT();
        return (DEF_NO);
    }

    ix_rd++;

    if (ix_rd == pbuf->Len) {
        pbuf->IxRd = 0;
        CPU_CRITICAL_EXIT();
        return (DEF_YES);
    }

    pbuf->IxRd = ix_rd;
    CPU_CRITICAL_EXIT();
    return (DEF_NO);
}
开发者ID:ptracton,项目名称:experimental,代码行数:34,代码来源:serial_buf.c

示例9: PngGetData

/*********************************************************************
*
*       PngGetData
*
* Function description
*   This routine is called by GUI_PNG_DrawEx(). The routine is responsible
*   for setting the data pointer to a valid data location with at least
*   one valid byte.
*
* Parameters:
*   p           - Pointer to application defined data.
*   NumBytesReq - Number of bytes requested.
*   ppData      - Pointer to data pointer. This pointer should be set to
*                 a valid location.
*   StartOfFile - If this flag is 1, the data pointer should be set to the
*                 beginning of the data stream.
*
* Return value:
*   Number of data bytes available.
*/
static int PngGetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off) 
{
	static int readaddress=0;
	FIL * phFile;
	U8 *pData;
	UINT NumBytesRead;
	#if SYSTEM_SUPPORT_OS
		CPU_SR_ALLOC();
	#endif
	
	pData = (U8*)*ppData;
	phFile = (FIL *)p;
	
	//移动指针到应该读取的位置
	if(Off == 1) readaddress = 0;
	else readaddress=Off;
	
	#if SYSTEM_SUPPORT_OS
		OS_CRITICAL_ENTER();	//临界区
	#endif
	f_lseek(phFile,readaddress); 
	
	//读取数据到缓冲区中
	f_read(phFile,pData,NumBytesReq,&NumBytesRead);
	
		
	#if SYSTEM_SUPPORT_OS
		OS_CRITICAL_EXIT();//退出临界区
	#endif
	return NumBytesRead;//返回读取到的字节数
}
开发者ID:fanwenl,项目名称:STM32F469,代码行数:51,代码来源:displaypng.c

示例10: CSP_TmrInit

void  CSP_TmrInit (void)
{
    CSP_DEV_NBR  per_nbr;
    CSP_DEV_NBR  tmr_nbr;
    CSP_TMR_REG  *p_tmr_reg;
    CPU_SR_ALLOC();


    for (tmr_nbr = CSP_TMR_NBR_00; tmr_nbr <= CSP_TMR_NBR_03; tmr_nbr++) {
        p_tmr_reg = (CSP_TMR_REG *)CSP_TmrAddrTbl[tmr_nbr];
        per_nbr   = (CSP_DEV_NBR  )CSP_TmrPerTbl[tmr_nbr];
        
        CPU_CRITICAL_ENTER();
        CSP_PM_PerClkEn(per_nbr);
        p_tmr_reg->MCR    = DEF_BIT_NONE;
        p_tmr_reg->MRx[0] = 0u;
        p_tmr_reg->MRx[1] = 0u;
        p_tmr_reg->MRx[2] = 0u;
        p_tmr_reg->IR     = DEF_BIT_FIELD(5u, 0u);
        p_tmr_reg->TCR    = DEF_BIT_NONE;        
        p_tmr_reg->MCR    = DEF_BIT_NONE;
        p_tmr_reg->EMR    = DEF_BIT_NONE;
        CSP_PM_PerClkDis(per_nbr);        
        CPU_CRITICAL_EXIT();
    }
}
开发者ID:strahlex,项目名称:LPC_Ethernet,代码行数:26,代码来源:csp_tmr.c

示例11: CSP_DMA_CH_FreeExt

CPU_BOOLEAN  CSP_DMA_CH_FreeExt (CSP_DEV_NBR  ch_nbr)
                               
{
    CSP_DMA_REG     *p_dma_reg;    
    CSP_DMA_CH_REG  *p_dma_ch_reg;
    CSP_DMA_CH      *p_ch_tbl;
    
    CPU_SR_ALLOC();

#if (CSP_CFG_ARG_CHK_EN == DEF_ENABLED)         
    if (ch_nbr > CSP_DMA_CH_MAX_NBR - 1u) {
        return (DEF_FAIL);
    }
#endif    

    p_dma_reg    = (CSP_DMA_REG *)CSP_ADDR_DMA_REG;
    p_dma_ch_reg = &(p_dma_reg->CHx[ch_nbr]);
    p_ch_tbl     = &CSP_DMA_ChTbl[ch_nbr];
        
    CPU_CRITICAL_ENTER();
    p_dma_reg->IntTCClr    = DEF_BIT(ch_nbr);                   /* Clear all pending interrupts.                        */
    p_dma_reg->IntErrClr   = DEF_BIT(ch_nbr);    
    p_ch_tbl->State        = CSP_DMA_CH_STATE_FREE;             /* Free the channel.                                    */
    p_dma_ch_reg->SrcAddr  = DEF_BIT_NONE;                      /* Unitialize DMA channel cfg & ctrl registers.         */
    p_dma_ch_reg->DestAddr = DEF_BIT_NONE;
    p_dma_ch_reg->Cfg      = DEF_BIT_NONE;
    p_dma_ch_reg->Ctrl     = DEF_BIT_NONE;       
    CPU_CRITICAL_EXIT();

    return (DEF_OK);
}
开发者ID:strahlex,项目名称:LPC_Ethernet,代码行数:31,代码来源:csp_dma.c

示例12: OSTimeDly

void  OSTimeDly (OS_TICK   dly,
                 OS_OPT    opt,
                 OS_ERR   *p_err)
{
    CPU_SR_ALLOC();



#ifdef OS_SAFETY_CRITICAL
    if (p_err == (OS_ERR *)0) {
        OS_SAFETY_CRITICAL_EXCEPTION();
        return;
    }
#endif

#if OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u
    if (OSIntNestingCtr > (OS_NESTING_CTR)0u) {             /* Not allowed to call from an ISR                        */
       *p_err = OS_ERR_TIME_DLY_ISR;
        return;
    }
#endif

    if (OSSchedLockNestingCtr > (OS_NESTING_CTR)0u) {       /* Can't delay when the scheduler is locked               */
       *p_err = OS_ERR_SCHED_LOCKED;
        return;
    }

    switch (opt) {
        case OS_OPT_TIME_DLY:
        case OS_OPT_TIME_TIMEOUT:
        case OS_OPT_TIME_PERIODIC:
             if (dly == (OS_TICK)0u) {                      /* 0 means no delay!                                      */
                *p_err = OS_ERR_TIME_ZERO_DLY;
                 return;
             }
             break;

        case OS_OPT_TIME_MATCH:
             break;

        default:
            *p_err = OS_ERR_OPT_INVALID;
             return;
    }

    OS_CRITICAL_ENTER();
    OSTCBCurPtr->TaskState = OS_TASK_STATE_DLY;
    OS_TickListInsert(OSTCBCurPtr,
                      dly,
                      opt,
                      p_err);
    if (*p_err != OS_ERR_NONE) {
         OS_CRITICAL_EXIT_NO_SCHED();
         return;
    }
    OS_RdyListRemove(OSTCBCurPtr);                          /* Remove current task from ready list                    */
    OS_CRITICAL_EXIT_NO_SCHED();
    OSSched();                                              /* Find next task to run!                                 */
   *p_err = OS_ERR_NONE;
}
开发者ID:AtomicForceMiscrocopy,项目名称:ucos3-stm32f4-discovery-AFM,代码行数:60,代码来源:os_time.c

示例13: OS_TLS_LockCreate

void  OS_TLS_LockCreate (void  **p_lock)
{
    OS_TLS_LOCK   *p_tls_lock;
    OS_ERR         os_err;
    CPU_SR_ALLOC();

    
    if (p_lock == (void **)0) {
        return;
    }

    if (OS_TLS_LockPoolListPtr == (OS_TLS_LOCK *)0) {             /* If 'OS_TLS_LOCK' object pool is empty?           */
        *p_lock = (void *)0;                                      /*   return a 'NULL' pointer.                       */
        return;
    }

    p_tls_lock = OS_TLS_LockPoolListPtr;                          /* Get the first object in the list.                */

    OSMutexCreate((OS_MUTEX *)&p_tls_lock->Mutex,                 /* Create the mutex in the kernel.                  */
                  (CPU_CHAR *) 0,				       
                  (OS_ERR   *)&os_err);			       
                             					       
    if (os_err != OS_ERR_NONE) {                                  /* If the mutex create funtion fail?                */
        *p_lock = (void *)0;                                      /* ... return a 'NULL' pointer.                     */
         return;        						       
    }											       

    CPU_CRITICAL_ENTER();
    OS_TLS_LockPoolListPtr = p_tls_lock->NextPtr;                 /* Move HEAD pointer to the next object in the list.*/
    CPU_CRITICAL_EXIT();
    
    *p_lock = (void *)p_tls_lock;                                 /* Return the new 'OS_TLS_LOCK' object pointer.     */
}
开发者ID:Akagi201,项目名称:uCOS-III,代码行数:33,代码来源:os_tls.c

示例14: OS_TLS_Init

void  OS_TLS_Init (OS_ERR *p_err)
{
    CPU_INT16U    ix;
    OS_TLS_LOCK  *p_lock;
    CPU_SR_ALLOC();



    OS_TLS_NextAvailID = 0u;
    OS_TLS_LibID       = OS_TLS_GetID(p_err);
    
    CPU_CRITICAL_ENTER();    
                                                                   /* Create the link list of OS_TLS_LOCK objects.    */
    for (ix = 0u; ix < (OS_TLS_LOCK_MAX - 1u); ix++) {
        p_lock             = &OS_TLS_LockPoolTbl[ix];
        p_lock->NextPtr    = &OS_TLS_LockPoolTbl[ix + 1u];
    }
    
    p_lock                 = &OS_TLS_LockPoolTbl[OS_TLS_LOCK_MAX - 1u];
    p_lock->NextPtr        = (OS_TLS_LOCK *)0;                     /* Last node points to 'NULL'                      */

    OS_TLS_LockPoolListPtr = &OS_TLS_LockPoolTbl[0];               /* Initialize the list head pointer.               */

    CPU_CRITICAL_EXIT();    
}
开发者ID:Akagi201,项目名称:uCOS-III,代码行数:25,代码来源:os_tls.c

示例15: OS_TickTask

void  OS_TickTask (void  *p_arg)
{
    OS_ERR  err;
    CPU_TS  ts_delta;
    CPU_TS  ts_delta_dly;
    CPU_TS  ts_delta_timeout;
    CPU_SR_ALLOC();


    (void)&p_arg;                                               /* Prevent compiler warning                             */

    while (DEF_ON) {
        (void)OSTaskSemPend((OS_TICK  )0,
                            (OS_OPT   )OS_OPT_PEND_BLOCKING,
                            (CPU_TS  *)0,
                            (OS_ERR  *)&err);                   /* Wait for signal from tick interrupt                  */
        if (err == OS_ERR_NONE) {
            OS_CRITICAL_ENTER();
            OSTickCtr++;                                        /* Keep track of the number of ticks                    */
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN > 0u))
            TRACE_OS_TICK_INCREMENT(OSTickCtr);                 /* Record the event.                                    */
#endif
            OS_CRITICAL_EXIT();
            ts_delta_dly     = OS_TickListUpdateDly();
            ts_delta_timeout = OS_TickListUpdateTimeout();
            ts_delta         = ts_delta_dly + ts_delta_timeout; /* Compute total execution time of list updates         */
            if (OSTickTaskTimeMax < ts_delta) {
                OSTickTaskTimeMax = ts_delta;
            }
        }
    }
}
开发者ID:PlainSailing,项目名称:K60_uCOSIII,代码行数:32,代码来源:os_tick.c


注:本文中的CPU_SR_ALLOC函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。