Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos M
提交
a03c2bb6
K
Kernel Liteos M
项目概览
OpenHarmony
/
Kernel Liteos M
大约 1 年 前同步成功
通知
20
Star
28
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos M
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a03c2bb6
编写于
4月 15, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 15, 2021
浏览文件
操作
浏览文件
下载
差异文件
!68 支持osThreadNew函数attr为NULL时创建线程,同时修正线程优先级的转换
Merge pull request !68 from Caoruihong/osThreadNew
上级
f6151020
2b88a469
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
15 deletion
+19
-15
kal/cmsis/cmsis_liteos2.c
kal/cmsis/cmsis_liteos2.c
+19
-15
未找到文件。
kal/cmsis/cmsis_liteos2.c
浏览文件 @
a03c2bb6
...
@@ -58,7 +58,12 @@ static osKernelState_t g_kernelState;
...
@@ -58,7 +58,12 @@ static osKernelState_t g_kernelState;
extern
BOOL
g_taskScheduled
;
extern
BOOL
g_taskScheduled
;
#define LOS_PRIORITY_WIN 8
/* LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO <---> osPriorityNormal */
#define LOS_PRIORITY(cmsisPriority) (LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO - ((cmsisPriority) - osPriorityNormal))
#define CMSIS_PRIORITY(losPriority) (osPriorityNormal + (LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO - (losPriority)))
/* OS_TASK_PRIORITY_HIGHEST and OS_TASK_PRIORITY_LOWEST is reserved for internal TIMER and IDLE task use only. */
#define ISVALID_LOS_PRIORITY(losPrio) ((losPrio) > OS_TASK_PRIORITY_HIGHEST && (losPrio) < OS_TASK_PRIORITY_LOWEST)
const
osVersion_t
g_stLosVersion
=
{
001
,
001
};
const
osVersion_t
g_stLosVersion
=
{
001
,
001
};
...
@@ -74,8 +79,6 @@ const osVersion_t g_stLosVersion = { 001, 001 };
...
@@ -74,8 +79,6 @@ const osVersion_t g_stLosVersion = { 001, 001 };
#define KERNEL_ID "HUAWEI-LiteOS"
#define KERNEL_ID "HUAWEI-LiteOS"
// ==== Kernel Management Functions ====
// ==== Kernel Management Functions ====
uint32_t
osTaskStackWaterMarkGet
(
UINT32
taskID
);
osStatus_t
osKernelInitialize
(
void
)
osStatus_t
osKernelInitialize
(
void
)
{
{
...
@@ -303,27 +306,28 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
...
@@ -303,27 +306,28 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
UINT32
uwTid
;
UINT32
uwTid
;
UINT32
uwRet
;
UINT32
uwRet
;
LosTaskCB
*
pstTaskCB
=
NULL
;
LosTaskCB
*
pstTaskCB
=
NULL
;
TSK_INIT_PARAM_S
stTskInitParam
;
TSK_INIT_PARAM_S
stTskInitParam
=
{
NULL
};
UINT16
usPriority
;
if
(
OS_INT_ACTIVE
)
{
if
(
OS_INT_ACTIVE
||
(
func
==
NULL
)
)
{
return
NULL
;
return
(
osThreadId_t
)
NULL
;
}
}
if
((
attr
==
NULL
)
||
(
func
==
NULL
)
||
(
attr
->
priority
<
osPriorityLow1
)
||
usPriority
=
attr
?
LOS_PRIORITY
(
attr
->
priority
)
:
LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
;
(
attr
->
priority
>
osPriorityAboveNormal6
))
{
if
(
!
ISVALID_LOS_PRIORITY
(
usPriority
))
{
/* unsupported priority */
return
(
osThreadId_t
)
NULL
;
return
(
osThreadId_t
)
NULL
;
}
}
(
void
)
memset_s
(
&
stTskInitParam
,
sizeof
(
TSK_INIT_PARAM_S
),
0
,
sizeof
(
TSK_INIT_PARAM_S
));
stTskInitParam
.
pfnTaskEntry
=
(
TSK_ENTRY_FUNC
)
func
;
stTskInitParam
.
pfnTaskEntry
=
(
TSK_ENTRY_FUNC
)
func
;
#ifndef LITEOS_WIFI_IOT_VERSION
#ifndef LITEOS_WIFI_IOT_VERSION
stTskInitParam
.
uwArg
=
(
UINT32
)
argument
;
stTskInitParam
.
uwArg
=
(
UINT32
)
argument
;
#else
#else
stTskInitParam
.
auwArgs
[
0
]
=
(
UINT32
)
argument
;
stTskInitParam
.
auwArgs
[
0
]
=
(
UINT32
)
argument
;
#endif
#endif
stTskInitParam
.
uwStackSize
=
attr
->
stack_size
;
stTskInitParam
.
uwStackSize
=
attr
?
attr
->
stack_size
:
LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE
;
stTskInitParam
.
pcName
=
(
CHAR
*
)
attr
->
name
;
stTskInitParam
.
pcName
=
(
CHAR
*
)
(
attr
?
attr
->
name
:
"[NULL]"
)
;
stTskInitParam
.
usTaskPrio
=
OS_TASK_PRIORITY_LOWEST
-
((
UINT16
)(
attr
->
priority
)
-
LOS_PRIORITY_WIN
);
/* 0~31 */
stTskInitParam
.
usTaskPrio
=
usPriority
;
uwRet
=
LOS_TaskCreate
(
&
uwTid
,
&
stTskInitParam
);
uwRet
=
LOS_TaskCreate
(
&
uwTid
,
&
stTskInitParam
);
...
@@ -483,12 +487,12 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
...
@@ -483,12 +487,12 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
return
osErrorParameter
;
return
osErrorParameter
;
}
}
if
(
priority
<
osPriorityLow1
||
priority
>
osPriorityAboveNormal6
)
{
usPriority
=
LOS_PRIORITY
(
priority
);
if
(
!
ISVALID_LOS_PRIORITY
(
usPriority
))
{
return
osErrorParameter
;
return
osErrorParameter
;
}
}
pstTaskCB
=
(
LosTaskCB
*
)
thread_id
;
pstTaskCB
=
(
LosTaskCB
*
)
thread_id
;
usPriority
=
OS_TASK_PRIORITY_LOWEST
-
((
UINT16
)
priority
-
LOS_PRIORITY_WIN
);
uwRet
=
LOS_TaskPriSet
(
pstTaskCB
->
taskID
,
usPriority
);
uwRet
=
LOS_TaskPriSet
(
pstTaskCB
->
taskID
,
usPriority
);
switch
(
uwRet
)
{
switch
(
uwRet
)
{
case
LOS_ERRNO_TSK_PRIOR_ERROR
:
case
LOS_ERRNO_TSK_PRIOR_ERROR
:
...
@@ -521,7 +525,7 @@ osPriority_t osThreadGetPriority(osThreadId_t thread_id)
...
@@ -521,7 +525,7 @@ osPriority_t osThreadGetPriority(osThreadId_t thread_id)
return
osPriorityError
;
return
osPriorityError
;
}
}
return
(
osPriority_t
)
(
OS_TASK_PRIORITY_LOWEST
-
(
usRet
-
LOS_PRIORITY_WIN
)
);
return
(
osPriority_t
)
CMSIS_PRIORITY
(
usRet
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录