本文整理汇总了C++中OSSchedUnlock函数的典型用法代码示例。如果您正苦于以下问题:C++ OSSchedUnlock函数的具体用法?C++ OSSchedUnlock怎么用?C++ OSSchedUnlock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OSSchedUnlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OSTmrStateGet
INT8U OSTmrStateGet (OS_TMR *ptmr,
INT8U *perr)
{
INT8U state;
#ifdef OS_SAFETY_CRITICAL
if (perr == (INT8U *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return (0u);
}
#endif
#if OS_ARG_CHK_EN > 0u
if (ptmr == (OS_TMR *)0) {
*perr = OS_ERR_TMR_INVALID;
return (0u);
}
#endif
if (ptmr->OSTmrType != OS_TMR_TYPE) { /* Validate timer structure */
*perr = OS_ERR_TMR_INVALID_TYPE;
return (0u);
}
if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
*perr = OS_ERR_TMR_ISR;
return (0u);
}
OSSchedLock();
state = ptmr->OSTmrState;
switch (state) {
case OS_TMR_STATE_UNUSED:
case OS_TMR_STATE_STOPPED:
case OS_TMR_STATE_COMPLETED:
case OS_TMR_STATE_RUNNING:
*perr = OS_ERR_NONE;
break;
default:
*perr = OS_ERR_TMR_INVALID_STATE;
break;
}
OSSchedUnlock();
return (state);
}
示例2: delay_us
void delay_us(u32 us)//函数:微秒延迟
{
u32 ticks;
u32 told,tnow,tcnt=0;
u32 reload = SysTick->LOAD;//LOAD的值
ticks = us * us_each;//需要的节拍数
OSSchedLock();//阻止ucos调度,防止打断us延时
told = SysTick->VAL;//刚进入时的计数器值
while(1){
tnow = SysTick->VAL;
if( tnow != told){
if( tnow < told) tcnt += told-tnow;//SYSTICK是一个递减的计数器
else tcnt += reload - tnow + told;
told = tnow;
if(tcnt >= ticks) break;//时间超过或等于要延迟的时间,则退出
}
}
OSSchedUnlock();//开启ucos任务调度
}
示例3: DelayUs
/***********************************************************************************************
功能:US级延时函数
形参:US 需要延时多少US
返回:0
详解:带操作系统下的延时US
************************************************************************************************/
void DelayUs(uint32_t us)
{
uint32_t temp;
uint32_t told;
told=SysTick->VAL; //刚进入时的计数器值
OSSchedLock(); //阻止ucos调度,防止打断us延时
SysTick->CTRL&=~(1<<1); //关闭SYSTICK中断
SysTick->LOAD=us*fac_us; //时间加载
SysTick->VAL=0x00; //清空计数器
SysTick->CTRL|=1<<0 ; //开始倒数
do
{
temp=SysTick->CTRL;
}
while(temp&0x01&&!(temp&(1<<16))); //等待时间到达
SysTick->LOAD=OS_ReloadValue; //恢复OS 延时值
SysTick->VAL=told; //恢复初值
SysTick->CTRL|=1<<1; //开启SYSTICK中断
OSSchedUnlock(); //开启ucos调度
}
示例4: OSTmrStop
CPU_BOOLEAN OSTmrStop (OS_TMR *p_tmr,
OS_OPT opt,
void *p_callback_arg,
OS_ERR *p_err)
{
OS_TMR_CALLBACK_PTR p_fnct;
OS_ERR err;
#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return (DEF_FALSE);
}
#endif
#if OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u
if (OSIntNestingCtr > (OS_NESTING_CTR)0) { /* See if trying to call from an ISR */
*p_err = OS_ERR_TMR_ISR;
return (DEF_FALSE);
}
#endif
#if OS_CFG_ARG_CHK_EN > 0u
if (p_tmr == (OS_TMR *)0) {
*p_err = OS_ERR_TMR_INVALID;
return (DEF_FALSE);
}
#endif
#if OS_CFG_OBJ_TYPE_CHK_EN > 0u
if (p_tmr->Type != OS_OBJ_TYPE_TMR) { /* Make sure timer was created */
*p_err = OS_ERR_OBJ_TYPE;
return (DEF_FALSE);
}
#endif
OSSchedLock(&err);
switch (p_tmr->State) {
case OS_TMR_STATE_RUNNING:
OS_TmrUnlink(p_tmr); /* Remove from current wheel spoke */
*p_err = OS_ERR_NONE;
switch (opt) {
case OS_OPT_TMR_CALLBACK:
p_fnct = p_tmr->CallbackPtr; /* Execute callback function ... */
if (p_fnct != (OS_TMR_CALLBACK_PTR)0) { /* ... if available */
(*p_fnct)((void *)p_tmr, p_tmr->CallbackPtrArg); /* Use callback arg when timer was created */
} else {
*p_err = OS_ERR_TMR_NO_CALLBACK;
}
break;
case OS_OPT_TMR_CALLBACK_ARG:
p_fnct = p_tmr->CallbackPtr; /* Execute callback function if available ... */
if (p_fnct != (OS_TMR_CALLBACK_PTR)0) {
(*p_fnct)((void *)p_tmr, p_callback_arg); /* .. using the 'callback_arg' provided in call */
} else {
*p_err = OS_ERR_TMR_NO_CALLBACK;
}
break;
case OS_OPT_TMR_NONE:
break;
default:
OSSchedUnlock(&err);
*p_err = OS_ERR_OPT_INVALID;
return (DEF_FALSE);
}
OSSchedUnlock(&err);
return (DEF_TRUE);
case OS_TMR_STATE_COMPLETED: /* Timer has already completed the ONE-SHOT or */
case OS_TMR_STATE_STOPPED: /* ... timer has not started yet. */
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_STOPPED;
return (DEF_TRUE);
case OS_TMR_STATE_UNUSED: /* Timer was not created */
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INACTIVE;
return (DEF_FALSE);
default:
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INVALID_STATE;
return (DEF_FALSE);
}
}
示例5: barcode_hid_send
/**
* @brief 通过USB HID发送条码
*/
static void barcode_hid_send(unsigned char* barcode)
{
unsigned int i,code_len;
unsigned char key_value_report[8];
code_len = strlen((char const*)barcode);
OSSchedLock();
for (i = 0; i < code_len; i++)
{
ascii_to_keyreport(barcode[i],key_value_report);
SendData_To_PC(key_value_report, 3);
SendData_To_PC("\x00\x00\x00", 3);
}
memcpy(key_value_report,"\x00\x00\x28",3); //换行
SendData_To_PC(key_value_report, 3);
SendData_To_PC("\x00\x00\x00", 3); //弹起
OSSchedUnlock();
}
示例6: delay_us
//延时nus
//nus为要延时的us数.
void delay_us(u32 nus)
{
u32 ticks;
u32 told,tnow,tcnt=0;
u32 reload=SysTick->LOAD; //LOAD的值
ticks=nus*fac_us; //需要的节拍数
tcnt=0;
OSSchedLock(); //阻止ucos调度,防止打断us延时
told=SysTick->VAL; //刚进入时的计数器值
while(1)
{
tnow=SysTick->VAL;
if(tnow!=told)
{
if(tnow<told)tcnt+=told-tnow;//这里注意一下SYSTICK是一个递减的计数器就可以了.
else tcnt+=reload-tnow+told;
told=tnow;
if(tcnt>=ticks)break;//时间超过/等于要延迟的时间,则退出.
}
};
OSSchedUnlock(); //开启ucos调度
}
示例7: OSTmr_Task
static void OSTmr_Task (void *p_arg)
{
INT8U err;
OS_TMR *ptmr;
OS_TMR *ptmr_next;
OS_TMR_CALLBACK pfnct;
OS_TMR_WHEEL *pspoke;
INT16U spoke;
p_arg = p_arg; /* Prevent compiler warning for not using 'p_arg' */
for (;;) {
OSSemPend(OSTmrSemSignal, 0u, &err); /* Wait for signal indicating time to update timers */
OSSchedLock();
OSTmrTime++; /* Increment the current time */
spoke = (INT16U)(OSTmrTime % OS_TMR_CFG_WHEEL_SIZE); /* Position on current timer wheel entry */
pspoke = &OSTmrWheelTbl[spoke];
ptmr = pspoke->OSTmrFirst;
while (ptmr != (OS_TMR *)0) {
ptmr_next = (OS_TMR *)ptmr->OSTmrNext; /* Point to next timer to update because current ... */
/* ... timer could get unlinked from the wheel. */
if (OSTmrTime == ptmr->OSTmrMatch) { /* Process each timer that expires */
OSTmr_Unlink(ptmr); /* Remove from current wheel spoke */
if (ptmr->OSTmrOpt == OS_TMR_OPT_PERIODIC) {
OSTmr_Link(ptmr, OS_TMR_LINK_PERIODIC); /* Recalculate new position of timer in wheel */
} else {
ptmr->OSTmrState = OS_TMR_STATE_COMPLETED; /* Indicate that the timer has completed */
}
pfnct = ptmr->OSTmrCallback; /* Execute callback function if available */
if (pfnct != (OS_TMR_CALLBACK)0) {
(*pfnct)((void *)ptmr, ptmr->OSTmrCallbackArg);
}
}
ptmr = ptmr_next;
}
OSSchedUnlock();
}
}
示例8: lcddisplaytime_task
/*
* This task is called once a second to update the LCD display with the
* current system time.
*/
void lcddisplaytime_task(void *pdata)
{
struct timeval time = {0, 0};
struct timezone zone = {0, 0};
struct tm time_struct;
struct tm *pt_time_struct = &time_struct;
alt_u8 char_array1[32];
alt_u8 char_array2[32];
INT8U ucos_retcode = OS_NO_ERR;
OSSemPend(lcd_sem, 0, &ucos_retcode);
while(1)
{
OSSchedLock();
if(gettimeofday(&time, &zone) < 0)
{
printf("Error get the time of day %s\n", strerror(errno));
exit(0);
}
OSSchedUnlock();
pt_time_struct = gmtime(&time.tv_sec);
strftime(char_array1, 32, "%a %b %d,%Y", pt_time_struct);
printf("DATE: %s\n", char_array1);
strftime(char_array2, 32, "%I:%M:%S %p GMT", pt_time_struct);
printf("TIME: %s\n", char_array2);
OSSemPost(lcd_sem);
OSTimeDlyHMSM(0,0,10,0);
}
}
示例9: OSTmrStart
CPU_BOOLEAN OSTmrStart (OS_TMR *p_tmr,
OS_ERR *p_err)
{
OS_ERR err;
#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return (DEF_FALSE);
}
#endif
#if OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u
if (OSIntNestingCtr > (OS_NESTING_CTR)0) { /* See if trying to call from an ISR */
*p_err = OS_ERR_TMR_ISR;
return (DEF_FALSE);
}
#endif
#if OS_CFG_ARG_CHK_EN > 0u
if (p_tmr == (OS_TMR *)0) {
*p_err = OS_ERR_TMR_INVALID;
return (DEF_FALSE);
}
#endif
#if OS_CFG_OBJ_TYPE_CHK_EN > 0u
if (p_tmr->Type != OS_OBJ_TYPE_TMR) { /* Make sure timer was created */
*p_err = OS_ERR_OBJ_TYPE;
return (DEF_FALSE);
}
#endif
OSSchedLock(&err);
switch (p_tmr->State) {
case OS_TMR_STATE_RUNNING: /* Restart the timer */
OS_TmrUnlink(p_tmr); /* ... Stop the timer */
OS_TmrLink(p_tmr, OS_OPT_LINK_DLY); /* ... Link timer to timer wheel (see Note #1). */
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (DEF_TRUE);
case OS_TMR_STATE_STOPPED: /* Start the timer */
case OS_TMR_STATE_COMPLETED:
OS_TmrLink(p_tmr, OS_OPT_LINK_DLY); /* ... Link timer to timer wheel (see Note #1). */
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (DEF_TRUE);
case OS_TMR_STATE_UNUSED: /* Timer not created */
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INACTIVE;
return (DEF_FALSE);
default:
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INVALID_STATE;
return (DEF_FALSE);
}
}
示例10: OSTmrDel
CPU_BOOLEAN OSTmrDel (OS_TMR *p_tmr,
OS_ERR *p_err)
{
OS_ERR err;
#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return (DEF_FALSE);
}
#endif
#if OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u
if (OSIntNestingCtr > (OS_NESTING_CTR)0) { /* See if trying to call from an ISR */
*p_err = OS_ERR_TMR_ISR;
return (DEF_FALSE);
}
#endif
#if OS_CFG_ARG_CHK_EN > 0u
if (p_tmr == (OS_TMR *)0) {
*p_err = OS_ERR_TMR_INVALID;
return (DEF_FALSE);
}
#endif
#if OS_CFG_OBJ_TYPE_CHK_EN > 0u
if (p_tmr->Type != OS_OBJ_TYPE_TMR) { /* Make sure timer was created */
*p_err = OS_ERR_OBJ_TYPE;
return (DEF_FALSE);
}
#endif
OSSchedLock(&err);
#if OS_CFG_DBG_EN > 0u
OS_TmrDbgListRemove(p_tmr);
#endif
OSTmrQty--; /* One less timer */
switch (p_tmr->State) {
case OS_TMR_STATE_RUNNING:
OS_TmrUnlink(p_tmr); /* Remove from current wheel spoke */
OS_TmrClr(p_tmr);
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (DEF_TRUE);
case OS_TMR_STATE_STOPPED: /* Timer has not started or ... */
case OS_TMR_STATE_COMPLETED: /* ... timer has completed the ONE-SHOT time */
OS_TmrClr(p_tmr); /* Clear timer fields */
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (DEF_TRUE);
case OS_TMR_STATE_UNUSED: /* Already deleted */
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INACTIVE;
return (DEF_FALSE);
default:
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INVALID_STATE;
return (DEF_FALSE);
}
}
示例11: OSTmrRemainGet
OS_TICK OSTmrRemainGet (OS_TMR *p_tmr,
OS_ERR *p_err)
{
OS_TICK remain;
OS_ERR err;
#ifdef OS_SAFETY_CRITICAL
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return ((OS_TICK)0);
}
#endif
#if OS_CFG_CALLED_FROM_ISR_CHK_EN > 0u
if (OSIntNestingCtr > (OS_NESTING_CTR)0) { /* See if trying to call from an ISR */
*p_err = OS_ERR_TMR_ISR;
return ((OS_TICK)0);
}
#endif
#if OS_CFG_ARG_CHK_EN > 0u
if (p_tmr == (OS_TMR *)0) {
*p_err = OS_ERR_TMR_INVALID;
return ((OS_TICK)0);
}
#endif
#if OS_CFG_OBJ_TYPE_CHK_EN > 0u
if (p_tmr->Type != OS_OBJ_TYPE_TMR) { /* Make sure timer was created */
*p_err = OS_ERR_OBJ_TYPE;
return ((OS_TICK)0);
}
#endif
OSSchedLock(&err);
switch (p_tmr->State) {
case OS_TMR_STATE_RUNNING:
remain = p_tmr->Match /* Determine how much time is left to timeout */
- OSTmrTickCtr;
p_tmr->Remain = remain;
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (remain);
case OS_TMR_STATE_STOPPED: /* It's assumed that the timer has not started yet */
if (p_tmr->Opt == OS_OPT_TMR_PERIODIC) {
if (p_tmr->Dly == 0u) {
remain = p_tmr->Period;
} else {
remain = p_tmr->Dly;
}
} else {
remain = p_tmr->Dly;
}
p_tmr->Remain = remain;
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return (remain);
case OS_TMR_STATE_COMPLETED: /* Only ONE-SHOT that timed out can be in this state */
OSSchedUnlock(&err);
*p_err = OS_ERR_NONE;
return ((OS_TICK)0);
case OS_TMR_STATE_UNUSED:
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INACTIVE;
return ((OS_TICK)0);
default:
OSSchedUnlock(&err);
*p_err = OS_ERR_TMR_INVALID_STATE;
return ((OS_TICK)0);
}
}
示例12: adi_osal_ThreadCreate
//.........这里部分代码省略.........
eHeapResult = _adi_osal_MemAlloc((void**) &pTLSBuffer, sizeof(ADI_OSAL_SLOT_VALUE) * _adi_osal_gnNumSlots);
#pragma diag(pop)
RESUME_PROFILING();
if (ADI_OSAL_SUCCESS != eHeapResult )
{
*phThread = ADI_OSAL_INVALID_THREAD;
/* Free the previously allocated memory because of a failure case */
_adi_osal_MemFree(hThreadNode);
return (ADI_OSAL_MEM_ALLOC_FAILED);
}
hThreadNode->pThreadLocalStorageBuffer = pTLSBuffer;
}
/* Creating a task by calling native OS call.*/
/* The scheduler needs to be locked so that the TaskCreation and the Name assignement
can be done atomically. It is important because the OSTaskNameSet takes the priority
as an argument, and the priority could have been changed within the task itself which
starts right after OSTaskCreateExt is called */
PAUSE_PROFILING();
OSSchedLock();
RESUME_PROFILING();
PAUSE_PROFILING();
/* the OSTCBExtPtr TCB entry (pext) is used for storing the pointer to the ADI_OSAL_THREAD_INFO structure so that
it can be found when given the Thread Priority (uCOS task handle) */
nRetValue = OSTaskCreateExt (pThreadAttr->pThreadFunc,
pThreadAttr->pParam,
pStackTop,
(INT8U) (nAssignedPrio & 0xFFu),
(INT16U) nAssignedPrio,
pStackStart,
nStkSize,
(void *)hThreadNode,
(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR) ) ;
RESUME_PROFILING();
switch (nRetValue)
{
case OS_ERR_NONE:
/* set the Name of the task. Maximum characters in the
name of the task allowed is "OS_TASK_NAME_SIZE".
If it exceeds, it will be truncated to OS_TASK_NAME_SIZE*/
#pragma diag(push)
#pragma diag(suppress:misra_rule_11_4 : "typecasting to the type expexted by uC/OS is necessary, also necessary for the return value")
#pragma diag(suppress:misra_rule_11_5 : "the API between the OSAL and uCOS force a const --> non-const conversion.")
/* converting from a const to non-const variable could be a risk, but since the data is getting
copied anyway it's not an issue here.*/
/* Supression since typecasting "szTaskName" which is char_t to INT8U */
PAUSE_PROFILING();
OSTaskNameSet((INT8U) nAssignedPrio,(INT8U*) pThreadAttr->szThreadName, &nErr);
RESUME_PROFILING();
if(nErr == OS_ERR_NONE)
{
/* The ADI_OSAL_THREAD_INFO structure is used as the thread handle */
*phThread = (ADI_OSAL_THREAD_HANDLE) hThreadNode;
eRetStatus = ADI_OSAL_SUCCESS;
}
else
{
eRetStatus = ADI_OSAL_FAILED;
}
break;
#pragma diag(pop)
/* Priority of the specified task is already exists */
case OS_ERR_PRIO_EXIST:
eRetStatus= ADI_OSAL_PRIORITY_IN_USE;
break;
/* Specified priority is out of range */
case OS_ERR_PRIO_INVALID:
eRetStatus = ADI_OSAL_BAD_PRIORITY;
break;
/* Not enough memory to create task */
case OS_ERR_TASK_NO_MORE_TCB:
eRetStatus = ADI_OSAL_MEM_ALLOC_FAILED;
break;
default:
eRetStatus = ADI_OSAL_FAILED;
break;
}
PAUSE_PROFILING();
OSSchedUnlock();
RESUME_PROFILING();
if(eRetStatus != ADI_OSAL_SUCCESS)
{
*phThread = ADI_OSAL_INVALID_THREAD;
if (hThreadNode != NULL)
{
_adi_osal_MemFree(hThreadNode->pThreadLocalStorageBuffer);
_adi_osal_MemFree(hThreadNode);
}
}
return(eRetStatus);
}
示例13: OS_SAFETY_CRITICAL_EXCEPTION
OS_TMR *OSTmrCreate (INT32U dly,
INT32U period,
INT8U opt,
OS_TMR_CALLBACK callback,
void *callback_arg,
INT8U *pname,
INT8U *perr)
{
OS_TMR *ptmr;
#ifdef OS_SAFETY_CRITICAL
if (perr == (INT8U *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
return ((OS_TMR *)0);
}
#endif
#ifdef OS_SAFETY_CRITICAL_IEC61508
if (OSSafetyCriticalStartFlag == OS_TRUE) {
OS_SAFETY_CRITICAL_EXCEPTION();
return ((OS_TMR *)0);
}
#endif
#if OS_ARG_CHK_EN > 0u
/* 检查参数 */
switch (opt) { /* Validate arguments */
/* 周期定时器的period不能是0 */
case OS_TMR_OPT_PERIODIC:
if (period == 0u) {
*perr = OS_ERR_TMR_INVALID_PERIOD;
return ((OS_TMR *)0);
}
break;
/* 单次定时器的dly不能是0 */
case OS_TMR_OPT_ONE_SHOT:
if (dly == 0u) {
*perr = OS_ERR_TMR_INVALID_DLY;
return ((OS_TMR *)0);
}
break;
default:
*perr = OS_ERR_TMR_INVALID_OPT;
return ((OS_TMR *)0);
}
#endif
if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
*perr = OS_ERR_TMR_ISR;
return ((OS_TMR *)0);
}
/* 关调度 */
OSSchedLock();
/* 从空闲定时器控制块链表中获得一个空闲定时器控制块 */
ptmr = OSTmr_Alloc(); /* Obtain a timer from the free pool */
/* 如果没有空闲定时器控制块,则返回错误信息 */
if (ptmr == (OS_TMR *)0) {
OSSchedUnlock();
*perr = OS_ERR_TMR_NON_AVAIL;
return ((OS_TMR *)0);
}
/* 设置获取到的定时器控制块 */
/* 创建定时器后,定时器是停止状态 */
ptmr->OSTmrState = OS_TMR_STATE_STOPPED; /* Indicate that timer is not running yet */
/* 设置第一次延时值 */
ptmr->OSTmrDly = dly;
/* 设置周期值 */
ptmr->OSTmrPeriod = period;
/* 设置定时器类型,单次或者周期 */
ptmr->OSTmrOpt = opt;
/* 设置定时器回调函数 */
ptmr->OSTmrCallback = callback;
/* 设置定时器回调函数的参数 */
ptmr->OSTmrCallbackArg = callback_arg;
#if OS_TMR_CFG_NAME_EN > 0u
if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
ptmr->OSTmrName = (INT8U *)(void *)"?";
} else {
ptmr->OSTmrName = pname;
}
#endif
/* 允许调度 */
OSSchedUnlock();
*perr = OS_ERR_NONE;
return (ptmr);
}
示例14: adi_osal_ThreadCreate
//.........这里部分代码省略.........
{
*phThread = ADI_OSAL_INVALID_THREAD;
return (eHeapResult);
}
/* save information about the thread into its structure */
hThreadNode->nThreadPrio = (ADI_OSAL_PRIORITY) nAssignedPrio;
/* Creating a task by calling native OS call.*/
/* The scheduler needs to be locked so that the TaskCreation and the Name
assignement can be done atomically. It is important because the
OSTaskNameSet takes the priority as an argument, and the priority could
have been changed within the task itself which starts right after
OSTaskCreateExt is called */
OSSchedLock();
/* the OSTCBExtPtr TCB entry (pext) is used for storing the pointer to the
* ADI_OSAL_THREAD_INFO structure so that
* it can be found when given the Thread Priority (uCOS task handle)
*/
nRetValue = OSTaskCreateExt (pThreadAttr->pThreadFunc,
pThreadAttr->pTaskAttrParam,
pStackTop,
(INT8U) (nAssignedPrio & 0xFFu),
(INT16U) nAssignedPrio,
pStackStart,
nStkSize,
(void *)hThreadNode,
(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR) ) ;
switch (nRetValue)
{
case OS_ERR_NONE:
/* set the Name of the task. Maximum characters in the
name of the task allowed is "OS_TASK_NAME_SIZE".
If it exceeds, it will be truncated to OS_TASK_NAME_SIZE*/
#pragma diag(push)
#pragma diag(suppress:misra_rule_11_4 : "typecasting to the type expexted by uC/OS is necessary, also necessary for the return value")
#pragma diag(suppress:misra_rule_11_5 : "the API between the OSAL and uCOS force a const --> non-const conversion.")
hThreadNode->nThreadSignature = ADI_OSAL_THREAD_SIGNATURE;
/* converting from a const to non-const variable could be a risk, but since the
data is getting copied anyway it's not an issue here.*/
/* Supression since typecasting "szTaskName" which is char_t to INT8U */
OSTaskNameSet((INT8U) nAssignedPrio,
(INT8U*) pThreadAttr->szThreadName,
&nErr);
if(nErr == OS_ERR_NONE)
{
/* The ADI_OSAL_THREAD_INFO structure is used as the thread handle */
*phThread = (ADI_OSAL_THREAD_HANDLE) hThreadNode;
eRetStatus = ADI_OSAL_SUCCESS;
}
else
{
eRetStatus = ADI_OSAL_FAILED;
}
break;
#pragma diag(pop)
#ifdef OSAL_DEBUG
/* Priority of the specified task is already exists */
case OS_ERR_PRIO_EXIST:
eRetStatus= ADI_OSAL_PRIORITY_IN_USE;
break;
/* Specified priority is out of range */
case OS_ERR_PRIO_INVALID:
eRetStatus = ADI_OSAL_BAD_PRIORITY;
break;
case OS_ERR_TASK_CREATE_ISR:
eRetStatus = ADI_OSAL_CALLER_ERROR;
break;
/* Not enough memory to create task */
case OS_ERR_TASK_NO_MORE_TCB:
eRetStatus = ADI_OSAL_MEM_ALLOC_FAILED;
break;
#endif
default:
eRetStatus = ADI_OSAL_FAILED;
break;
} /* end of switch */
OSSchedUnlock();
if(eRetStatus != ADI_OSAL_SUCCESS)
{
*phThread = ADI_OSAL_INVALID_THREAD;
if (NULL != hThreadNode)
{
hThreadNode->nThreadSignature=ADI_OSAL_INVALID_THREAD_SIGNATURE;
_adi_osal_MemFree(hThreadNode);
}
}
return(eRetStatus);
}
示例15: OSTmrRemainGet
INT32U OSTmrRemainGet (OS_TMR *ptmr,
INT8U *perr)
{
INT32U remain;
#ifdef OS_SAFETY_CRITICAL
if (perr == (INT8U *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
}
#endif
#if OS_ARG_CHK_EN > 0u
if (ptmr == (OS_TMR *)0) {
*perr = OS_ERR_TMR_INVALID;
return (0u);
}
#endif
if (ptmr->OSTmrType != OS_TMR_TYPE) { /* Validate timer structure */
*perr = OS_ERR_TMR_INVALID_TYPE;
return (0u);
}
if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
*perr = OS_ERR_TMR_ISR;
return (0u);
}
OSSchedLock();
switch (ptmr->OSTmrState) {
case OS_TMR_STATE_RUNNING:
remain = ptmr->OSTmrMatch - OSTmrTime; /* Determine how much time is left to timeout */
OSSchedUnlock();
*perr = OS_ERR_NONE;
return (remain);
case OS_TMR_STATE_STOPPED: /* It's assumed that the timer has not started yet */
switch (ptmr->OSTmrOpt) {
case OS_TMR_OPT_PERIODIC:
if (ptmr->OSTmrDly == 0u) {
remain = ptmr->OSTmrPeriod;
} else {
remain = ptmr->OSTmrDly;
}
OSSchedUnlock();
*perr = OS_ERR_NONE;
break;
case OS_TMR_OPT_ONE_SHOT:
default:
remain = ptmr->OSTmrDly;
OSSchedUnlock();
*perr = OS_ERR_NONE;
break;
}
return (remain);
case OS_TMR_STATE_COMPLETED: /* Only ONE-SHOT that timed out can be in this state */
OSSchedUnlock();
*perr = OS_ERR_NONE;
return (0u);
case OS_TMR_STATE_UNUSED:
OSSchedUnlock();
*perr = OS_ERR_TMR_INACTIVE;
return (0u);
default:
OSSchedUnlock();
*perr = OS_ERR_TMR_INVALID_STATE;
return (0u);
}
}