本文整理汇总了C++中CPU_CRITICAL_EXIT函数的典型用法代码示例。如果您正苦于以下问题:C++ CPU_CRITICAL_EXIT函数的具体用法?C++ CPU_CRITICAL_EXIT怎么用?C++ CPU_CRITICAL_EXIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPU_CRITICAL_EXIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 */
}
示例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);
}
示例3: 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);
}
示例4: wireless_exec_cmd
int wireless_exec_cmd(char *cmd)
{
SHELL_ERR err;
CPU_SR cpu_sr;
struct net_device *net_dev;
char s[45];
CPU_CRITICAL_ENTER();
if(!_pnet_device)
{
CPU_CRITICAL_EXIT();
return -1;
}
net_dev = _pnet_device;
net_dev->status |= NET_IOCTL_RUNNING;
CPU_CRITICAL_EXIT();
strncpy(s,cmd,sizeof(s));
Shell_Exec(s, NULL, NULL, &err);
CPU_CRITICAL_ENTER();
net_dev->status &= ~NET_IOCTL_RUNNING;
CPU_CRITICAL_EXIT();
return 0;
}
示例5: SerialOS_SemDel
void SerialOS_SemDel (void *psem)
{
INT8U os_err;
#if (SERIAL_CFG_ARG_CHK_EXT_EN == DEF_ENABLED)
CPU_SIZE_T i;
#endif
CPU_SR_ALLOC();
OSSemPendAbort((OS_EVENT *) psem,
(INT8U ) OS_PEND_OPT_BROADCAST,
(INT8U *)&os_err);
CPU_CRITICAL_ENTER();
if (OSEventObjIx >= SERIAL_OS_MAX_NBR_SEM) {
CPU_CRITICAL_EXIT();
return;
}
#if (SERIAL_CFG_ARG_CHK_EXT_EN == DEF_ENABLED) /* ----------------- VALIDATE OS EVENT ---------------- */
for (i = 0u; i < OSEventObjIx; i++) {
if (OSEventObj[i] == (OS_EVENT *)psem) {
CPU_CRITICAL_EXIT();
return;
}
}
#endif
/* --------------- FREE OS EVENT TO POOL -------------- */
OSEventObj[OSEventObjIx] = (OS_EVENT *)psem;
OSEventObjIx++;
CPU_CRITICAL_EXIT();
}
示例6: tasklet_kill
//in t->func(t->data), don't restart tasklet_schedule,oterwise tasklet_kill will not exit.
void tasklet_kill(struct tasklet_struct *t)
{
OS_ERR err;
CPU_SR cpu_sr;
if (in_interrupt())
USBH_DBG("tasklet_kill Attempt to kill tasklet from interrupt\r\n");
CPU_CRITICAL_ENTER();
while (t->state == TASKLET_STATE_SCHED){
t->state = TASKLET_STATE_SCHED;
do {
CPU_CRITICAL_EXIT();
OSTimeDlyHMSM(0,0,0,5, OS_OPT_TIME_DLY,&err);
CPU_CRITICAL_ENTER();
} while (t->state == TASKLET_STATE_SCHED);
}
CPU_CRITICAL_EXIT();
// while (test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
// do {
// yield();
// } while (test_bit(TASKLET_STATE_SCHED, &t->state));
// }
// tasklet_unlock_wait(t);
// clear_bit(TASKLET_STATE_SCHED, &t->state);
}
示例7: 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);
}
示例8: 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);
}
示例9: OS_TLS_GetID
OS_TLS_ID OS_TLS_GetID (OS_ERR *p_err)
{
OS_TLS_ID id;
CPU_SR_ALLOC();
#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return ((OS_TLS_ID)OS_CFG_TLS_TBL_SIZE);
}
#endif
CPU_CRITICAL_ENTER();
if (OS_TLS_NextAvailID >= OS_CFG_TLS_TBL_SIZE) { /* See if we exceeded the number of IDs available */
*p_err = OS_ERR_TLS_NO_MORE_AVAIL; /* Yes, cannot allocate more TLS */
CPU_CRITICAL_EXIT();
return ((OS_TLS_ID)OS_CFG_TLS_TBL_SIZE);
}
id = OS_TLS_NextAvailID; /* Assign the next available ID */
OS_TLS_NextAvailID++; /* Increment available ID for next request */
CPU_CRITICAL_EXIT();
*p_err = OS_ERR_NONE;
return (id);
}
示例10: OSMemPut
void OSMemPut (OS_MEM *p_mem,
void *p_blk,
OS_ERR *p_err)
{
CPU_SR_ALLOC();
#ifdef OS_SAFETY_CRITICAL
if (p_err == DEF_NULL) {
OS_SAFETY_CRITICAL_EXCEPTION();
return;
}
#endif
#if (OS_CFG_ARG_CHK_EN == DEF_ENABLED)
if (p_mem == DEF_NULL) { /* Must point to a valid memory partition */
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_PUT_FAILED(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_MEM_INVALID_P_MEM;
return;
}
if (p_blk == DEF_NULL) { /* Must release a valid block */
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_PUT_FAILED(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_MEM_INVALID_P_BLK;
return;
}
#endif
#if (OS_CFG_OBJ_TYPE_CHK_EN == DEF_ENABLED)
if (p_mem->Type != OS_OBJ_TYPE_MEM) { /* Make sure the memory block was created */
*p_err = OS_ERR_OBJ_TYPE;
return;
}
#endif
CPU_CRITICAL_ENTER();
if (p_mem->NbrFree >= p_mem->NbrMax) { /* Make sure all blocks not already returned */
CPU_CRITICAL_EXIT();
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_PUT_FAILED(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_MEM_FULL;
return;
}
*(void **)p_blk = p_mem->FreeListPtr; /* Insert released block into free block list */
p_mem->FreeListPtr = p_blk;
p_mem->NbrFree++; /* One more memory block in this partition */
CPU_CRITICAL_EXIT();
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_PUT(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_NONE; /* Notify caller that memory block was released */
}
示例11: OS_SemPost
OS_SEM_CTR OS_SemPost (OS_SEM *p_sem,
OS_OPT opt,
CPU_TS ts,
OS_ERR *p_err)
{
OS_SEM_CTR ctr;
OS_PEND_LIST *p_pend_list;
OS_PEND_DATA *p_pend_data;
OS_PEND_DATA *p_pend_data_next;
OS_TCB *p_tcb;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
p_pend_list = &p_sem->PendList;
if (p_pend_list->HeadPtr == DEF_NULL) { /* Any task waiting on semaphore? */
if (p_sem->Ctr == (OS_SEM_CTR)-1) {
CPU_CRITICAL_EXIT();
*p_err = OS_ERR_SEM_OVF;
return (0u);
}
p_sem->Ctr++; /* No */
ctr = p_sem->Ctr;
#if (OS_CFG_TS_EN == DEF_ENABLED)
p_sem->TS = ts; /* Save timestamp in semaphore control block */
#endif
CPU_CRITICAL_EXIT();
*p_err = OS_ERR_NONE;
return (ctr);
}
OS_CRITICAL_ENTER_CPU_EXIT();
p_pend_data = p_pend_list->HeadPtr;
while (p_pend_data != DEF_NULL) {
p_tcb = p_pend_data->TCBPtr;
p_pend_data_next = p_pend_data->NextPtr;
OS_Post((OS_PEND_OBJ *)((void *)p_sem),
p_tcb,
DEF_NULL,
0u,
ts);
if ((opt & OS_OPT_POST_ALL) == 0) { /* Post to all tasks waiting? */
break; /* No */
}
p_pend_data = p_pend_data_next;
}
OS_CRITICAL_EXIT_NO_SCHED();
if ((opt & OS_OPT_POST_NO_SCHED) == 0u) {
OSSched(); /* Run the scheduler */
}
*p_err = OS_ERR_NONE;
return (0u);
}
示例12: 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 == DEF_NULL) {
OS_SAFETY_CRITICAL_EXCEPTION();
return (DEF_NULL);
}
#endif
#if (OS_CFG_ARG_CHK_EN == DEF_ENABLED)
if (p_mem == DEF_NULL) { /* Must point to a valid memory partition */
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_GET_FAILED(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_MEM_INVALID_P_MEM;
return (DEF_NULL);
}
#endif
#if (OS_CFG_OBJ_TYPE_CHK_EN == DEF_ENABLED)
if (p_mem->Type != OS_OBJ_TYPE_MEM) { /* Make sure the memory block was created */
*p_err = OS_ERR_OBJ_TYPE;
return (DEF_NULL);
}
#endif
CPU_CRITICAL_ENTER();
if (p_mem->NbrFree == 0u) { /* See if there are any free memory blocks */
CPU_CRITICAL_EXIT();
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_GET_FAILED(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_MEM_NO_FREE_BLKS; /* No, Notify caller of empty memory partition */
return (DEF_NULL); /* 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();
#if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN == DEF_ENABLED))
TRACE_OS_MEM_GET(p_mem); /* Record the event. */
#endif
*p_err = OS_ERR_NONE; /* No error */
return (p_blk); /* Return memory block to caller */
}
示例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. */
}
示例14: OSView_RxTxISRHandler
/*
*********************************************************************************************************
* Rx/Tx Communication handler for uC/OS-View
*
* Description: This function is called in stm32f10x_it.c
*********************************************************************************************************
*/
void OSView_RxTxISRHandler (void)
{
CPU_SR cpu_sr;
CPU_CRITICAL_ENTER(); /* Tell uC/OS-II that we are starting an ISR */
OSIntNesting++;
CPU_CRITICAL_EXIT();
if (USART_GetITStatus(OS_VIEW_USART, USART_IT_RXNE) != RESET) {
/* Read one byte from the receive data register */
OSView_RxHandler( USART_ReceiveData(OS_VIEW_USART) & 0xFF );
USART_ClearITPendingBit(OS_VIEW_USART, USART_IT_RXNE); /* Clear the USART Receive interrupt */
}
if (USART_GetITStatus(OS_VIEW_USART, USART_IT_TXE) != RESET) {
OSView_TxHandler();
USART_ClearITPendingBit(OS_VIEW_USART, USART_IT_TXE); /* Clear the USART transmit interrupt */
}
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
示例15: 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();
}