久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標(biāo)題:
uCOSIII源碼分享
[打印本頁(yè)]
作者:
wyjx2009
時(shí)間:
2018-10-31 09:41
標(biāo)題:
uCOSIII源碼分享
分享uCOSIII源碼
0.png
(8.31 KB, 下載次數(shù): 16)
下載附件
2018-10-31 13:20 上傳
源程序如下:
/*
************************************************************************************************************************
* uC/OS-III
* The Real-Time Kernel
*
* (c) Copyright 2009, Micrium, Weston, FL
* All Rights Reserved
* www.Micrium.com
*
* ISR QUEUE MANAGEMENT
*
* File : OS_ISR.C
* By : JJL
* Version : V3.00.4
*
* LICENSING TERMS:
* ---------------
* uC/OS-III is provided in source form to registered licensees. It is illegal to distribute this source
* code to any third party unless you receive written permission by an authorized Micrium officer.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest software available. Your
* honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
************************************************************************************************************************
*/
#include <os.h>
#if OS_CFG_ISR_POST_DEFERRED_EN > 0u
/*$PAGE*/
/*
************************************************************************************************************************
* POST TO ISR QUEUE
*
* Description: This function places contents of posts into an intermediate queue to help defer processing of interrupts
* at the task level.
*
* Arguments : type is the type of kernel object the post is destined to:
*
* OS_OBJ_TYPE_SEM
* OS_OBJ_TYPE_Q
* OS_OBJ_TYPE_FLAG
* OS_OBJ_TYPE_TASK_MSG
* OS_OBJ_TYPE_TASK_SIGNAL
*
* p_obj is a pointer to the kernel object to post to. This can be a pointer to a semaphore,
* ----- a message queue or a task control clock.
*
* p_void is a pointer to a message that is being posted. This is used when posting to a message
* queue or directly to a task.
*
* msg_size is the size of the message being posted
*
* flags if the post is done to an event flag group then this corresponds to the falgs being
* posted
*
* ts is a timestamp as to when the post was done
*
* opt this corresponds to post options and applies to:
*
* OSFlagPost()
* OSSemPost()
* OSQPost()
* OSTaskQPost()
*
* p_err is a pointer to a variable that will contain an error code returned by this function.
*
* OS_ERR_NONE if the post to the ISR queue was successful
* OS_ERR_INT)Q_FULL if the ISR queue is full and cannot accepts any further posts. This
* generally indicates that you are receiving interrupts faster than you
* can process them or, that you didn't make the ISR queue large enough.
*
* Returns : none
*
* Note(s) : none
************************************************************************************************************************
*/
void OS_IntQPost (OS_OBJ_TYPE type,
void *p_obj,
void *p_void,
OS_MSG_SIZE msg_size,
OS_FLAGS flags,
OS_OPT opt,
CPU_TS ts,
OS_ERR *p_err)
{
CPU_SR_ALLOC();
#ifdef OS_SAFETY_CRITICAL_RELEASE
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
}
#endif
CPU_CRITICAL_ENTER();
if (OSIntQNbrEntries < OSCfg_IntQSize) { /* Make sure we haven't already filled the ISR queue */
OSIntQNbrEntries++;
OSIntQInPtr->Type = type;
OSIntQInPtr->ObjPtr = p_obj;
OSIntQInPtr->MsgPtr = p_void;
OSIntQInPtr->MsgSize = msg_size;
OSIntQInPtr->Flags = flags;
OSIntQInPtr->Opt = opt;
OSIntQInPtr->TS = ts;
OSIntQInPtr = OSIntQInPtr->NextPtr;
OSRdyList[0].NbrEntries = (OS_OBJ_QTY)1; /* Add to ready list */
OSRdyList[0].HeadPtr = &OSIntQTaskTCB;
OSRdyList[0].TailPtr = &OSIntQTaskTCB;
OS_PrioInsert(0u); /* Add task priority 0 in the priority table */
OSPrioSaved = OSPrioCur; /* Save current priority */
*p_err = OS_ERR_NONE;
} else {
OSIntQOvfCtr++; /* Count the number of ISR queue overflows */
*p_err = OS_ERR_INT_Q_FULL;
}
CPU_CRITICAL_EXIT();
}
/*$PAGE*/
/*
************************************************************************************************************************
* INTERRUPT QUEUE MANAGEMENT TASK
*
* Description: This task is created by OS_IntQTaskInit().
*
* Arguments : p_arg is a pointer to an optional argument that is passed during task creation. For this function
* the argument is not used and will be a NULL pointer.
*
* Returns : none
************************************************************************************************************************
*/
void OS_IntQRePost (void)
{
void *p_obj;
void *p_void;
OS_ERR err;
OS_FLAGS flags;
CPU_TS ts;
OS_OBJ_TYPE type;
OS_OPT opt;
OS_MSG_SIZE msg_size;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
type = OSIntQOutPtr->Type; /* Get local copy of queue item contents */
p_obj = OSIntQOutPtr->ObjPtr;
p_void = OSIntQOutPtr->MsgPtr;
msg_size = OSIntQOutPtr->MsgSize;
flags = OSIntQOutPtr->Flags;
opt = OSIntQOutPtr->Opt;
ts = OSIntQOutPtr->TS;
OSIntQOutPtr = OSIntQOutPtr->NextPtr; /* Point to next item in the ISR queue */
CPU_CRITICAL_EXIT();
switch (type) { /* Re-post to task */
case OS_OBJ_TYPE_FLAG:
#if OS_CFG_FLAG_EN > 0u
(void)OS_FlagPost((OS_FLAG_GRP *)p_obj,
(OS_FLAGS )flags,
(OS_OPT )opt,
(CPU_TS )ts,
(OS_ERR *)&err);
#endif
break;
case OS_OBJ_TYPE_Q:
#if OS_CFG_Q_EN > 0u
OS_QPost((OS_Q *)p_obj,
(void *)p_void,
(OS_MSG_SIZE)msg_size,
(OS_OPT )opt,
(CPU_TS )ts,
(OS_ERR *)&err);
#endif
break;
case OS_OBJ_TYPE_SEM:
#if OS_CFG_SEM_EN > 0u
(void)OS_SemPost((OS_SEM *)p_obj,
(OS_OPT )opt,
(CPU_TS )ts,
(OS_ERR *)&err);
#endif
break;
case OS_OBJ_TYPE_TASK_MSG:
#if OS_CFG_TASK_Q_EN > 0u
OS_TaskQPost((OS_TCB *)p_obj,
(void *)p_void,
(OS_MSG_SIZE)msg_size,
(OS_OPT )opt,
(CPU_TS )ts,
(OS_ERR *)&err);
#endif
break;
case OS_OBJ_TYPE_TASK_SIGNAL:
(void)OS_TaskSemPost((OS_TCB *)p_obj,
(OS_OPT )opt,
(CPU_TS )ts,
(OS_ERR *)&err);
break;
case OS_OBJ_TYPE_TICK:
#if OS_CFG_SCHED_ROUND_ROBIN_EN > 0u
OS_SchedRoundRobin(&OSRdyList[OSPrioSaved]);
#endif
(void)OS_TaskSemPost((OS_TCB *)&OSTickTaskTCB, /* Signal tick task */
(OS_OPT )OS_OPT_POST_NONE,
(CPU_TS )ts,
(OS_ERR *)&err);
#if OS_CFG_TMR_EN > 0u
OSTmrUpdateCtr--;
if (OSTmrUpdateCtr == (OS_CTR)0) {
OSTmrUpdateCtr = OSTmrUpdateCnt;
ts = OS_TS_GET(); /* Get timestamp */
(void)OS_TaskSemPost((OS_TCB *)&OSTmrTaskTCB, /* Signal timer task */
(OS_OPT )OS_OPT_POST_NONE,
(CPU_TS )ts,
(OS_ERR *)&err);
}
#endif
break;
default:
break;
}
}
/*$PAGE*/
/*
************************************************************************************************************************
* INTERRUPT QUEUE MANAGEMENT TASK
*
* Description: This task is created by OS_IntQTaskInit().
*
* Arguments : p_arg is a pointer to an optional argument that is passed during task creation. For this function
* the argument is not used and will be a NULL pointer.
*
* Returns : none
************************************************************************************************************************
*/
void OS_IntQTask (void *p_arg)
{
CPU_BOOLEAN done;
CPU_TS ts_start;
CPU_TS ts_end;
CPU_SR_ALLOC();
p_arg = p_arg; /* Not using 'p_arg', prevent compiler warning */
while (DEF_TRUE) {
done = DEF_FALSE;
while (done == DEF_FALSE) {
if (OSIntQNbrEntries == (OS_OBJ_QTY)0) {
CPU_CRITICAL_ENTER();
OSRdyList[0].NbrEntries = (OS_OBJ_QTY)0; /* Remove from ready list */
OSRdyList[0].HeadPtr = (OS_TCB *)0;
OSRdyList[0].TailPtr = (OS_TCB *)0;
OS_PrioRemove(0u); /* Remove from the priority table */
CPU_CRITICAL_EXIT();
OSSched();
done = DEF_TRUE; /* No more entries in the queue, we are done */
} else {
ts_start = OS_TS_GET();
OS_IntQRePost();
ts_end = OS_TS_GET() - ts_start; /* Measure execution time of tick task */
if (ts_end > OSIntQTaskTimeMax) {
OSIntQTaskTimeMax = ts_end;
}
CPU_CRITICAL_ENTER();
OSIntQNbrEntries--;
CPU_CRITICAL_EXIT();
}
}
}
}
/*$PAGE*/
/*
************************************************************************************************************************
* INITIALIZE THE ISR QUEUE
*
* Description: This function is called by OSInit() to initialize the ISR queue.
*
* Arguments : p_err is a pointer to a variable that will contain an error code returned by this function.
*
* OS_ERR_INT_Q If you didn't provide an ISR queue in OS_CFG.C
* OS_ERR_INT_Q_SIZE If you didn't specify a large enough ISR queue.
* OS_ERR_STK_INVALID If you specified a NULL pointer for the task of the ISR task
* handler
* OS_ERR_STK_SIZE_INVALID If you didn't specify a stack sise greate than the minimum
* specified by OS_CFG_STK_SIZE_MIN
* OS_ERR_??? An error code returned by OSTaskCreate().
*
* Returns : none
*
* Note(s) : none
************************************************************************************************************************
*/
void OS_IntQTaskInit (OS_ERR *p_err)
{
OS_INT_Q *p_int_q;
OS_INT_Q *p_int_q_next;
OS_OBJ_QTY i;
#ifdef OS_SAFETY_CRITICAL_RELEASE
if (p_err == (OS_ERR *)0) {
OS_SAFETY_CRITICAL_EXCEPTION();
}
#endif
OSIntQOvfCtr = (OS_QTY)0; /* Clear the ISR queue overflow counter */
if (OSCfg_IntQBasePtr == (OS_INT_Q *)0) {
*p_err = OS_ERR_INT_Q;
return;
}
if (OSCfg_IntQSize < (OS_OBJ_QTY)2) {
*p_err = OS_ERR_INT_Q_SIZE;
return;
}
OSIntQTaskTimeMax = (CPU_TS)0;
p_int_q = OSCfg_IntQBasePtr; /* Initialize the circular ISR queue */
p_int_q_next = p_int_q;
p_int_q_next++;
for (i = 0u; i < OSCfg_IntQSize; i++) {
p_int_q->Type = OS_OBJ_TYPE_NONE;
p_int_q->ObjPtr = (void *)0;
……………………
…………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
UCOS-III.zip
(115.27 KB, 下載次數(shù): 22)
2018-10-31 09:40 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
wliuxiaoxiaow
時(shí)間:
2019-9-6 23:21
這是哪個(gè)單片機(jī)的源碼
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
国产精品免费在线
|
午夜网
|
国产一级片免费在线观看
|
综合一区二区三区
|
超碰精品在线
|
国产亚洲精品久久午夜玫瑰园
|
成人黄色在线
|
99精品免费视频
|
国产一区二区在线免费视频
|
国产区精品视频
|
色欧美日韩
|
www日本在线
|
久久aⅴ乱码一区二区三区 亚洲国产成人精品久久久国产成人一区
|
成人视屏在线观看
|
国产黄色网址在线观看
|
久久精品欧美一区二区三区不卡
|
日本精品视频一区二区三区四区
|
毛片免费观看视频
|
日日操夜夜操天天操
|
国产精品久久久久久久模特
|
免费观看一级特黄欧美大片
|
色婷婷国产精品
|
中文字幕亚洲专区
|
91在线观
|
中文字幕在线中文
|
中文字幕免费中文
|
香蕉视频黄色
|
国产一区999
|
超碰国产在线
|
日本淫视频
|
欧美一级电影免费
|
久久久蜜桃
|
亚洲欧美日韩在线不卡
|
亚洲成人av
|
久久黄色网
|
紧缚调教一区二区三区视频
|
日韩中文字幕一区
|
欧美一级特黄aaa大片在线观看
|
美女爽到呻吟久久久久
|
久久久精品网站
|
日韩精品在线播放
|