本文整理汇总了C++中CPU_CRITICAL_ENTER函数的典型用法代码示例。如果您正苦于以下问题:C++ CPU_CRITICAL_ENTER函数的具体用法?C++ CPU_CRITICAL_ENTER怎么用?C++ CPU_CRITICAL_ENTER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPU_CRITICAL_ENTER函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例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();
}
示例4: IAP_JumpTo
/*******************************************************************************
* 名 称: IAP_JumpTo()
* 功 能: 跳转到应用程序段
* 入口参数:
* 出口参数: 无
* 作 者: 无名沈
* 创建日期: 2014-04-23
* 修 改:
* 修改日期:
*******************************************************************************/
void IAP_JumpTo(u32 appAddr)
{
u32 JumpAddress = 0;
u8 cpu_sr;
/***********************************************
* 描述: 保存程序地址
*/
IAP_SetAppAddr(appAddr);
/***********************************************
* 描述: 关中断,防止值被中断修改
*/
CPU_CRITICAL_ENTER();
/***********************************************
* 描述: 外设恢复默认,避免进入应用程序后影响程序正常运行
*/
IAP_DevDeInit();
/***********************************************
* 描述: 获取应用入口及初始化堆栈指针
*/
JumpAddress =*(volatile u32*) (appAddr + 4); // 地址+4为PC地址
pApp = (pFunction)JumpAddress; // 函数指针指向APP
__set_MSP (*(volatile u32*) appAddr); // 初始化主堆栈指针(MSP)
__set_PSP (*(volatile u32*) appAddr); // 初始化进程堆栈指针(PSP)
__set_CONTROL (0); // 清零CONTROL
/***********************************************
* 描述: 跳转到APP程序
*/
pApp();
CPU_CRITICAL_EXIT();
}
示例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);
}
示例6: 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);
}
示例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;
}
示例8: 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);
}
示例9: 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);
}
示例10: tasklet_action
void tasklet_action(void *p_arg)
{
OS_ERR err;
OS_MSG_SIZE msg_size;
struct tasklet_struct *t;
CPU_SR cpu_sr;
while(1)
{
t = OSTaskQPend(0, OS_OPT_PEND_BLOCKING, &msg_size, 0,&err);
if(err != OS_ERR_NONE)
{
USBH_DBG("tasklet_schedule OSTaskQPend Failed %d\r\n",err);
continue;
}
if(!t){
USBH_DBG("tasklet_schedule t == NULL\r\n");
continue;
}
// OSSchedLock(&err);
CPU_CRITICAL_ENTER();
if(t->state == TASKLET_STATE_UNSCHED)
USBH_DBG("tasklet_action Error at %d\r\n",__LINE__);
t->state = TASKLET_STATE_UNSCHED;
CPU_CRITICAL_EXIT();
t->func(t->data);
// OSSchedUnlock(&err);
}
}
示例11: 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();
}
}
示例12: 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);
}
示例13: 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 */
}
示例14: 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();
}
示例15: 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 */
}