Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
Docs
提交
1a32ca3a
D
Docs
项目概览
XKZJ_WCL
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a32ca3a
编写于
9月 10, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
!626 修复社区资料内核开发指南示例代码问题
Merge pull request !626 from kenneth/demo_code_fix
上级
30365b62
d072fa03
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
63 deletion
+69
-63
en/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
en/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
+8
-9
en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
+3
-0
en/device-dev/kernel/kernel-mini-basic-soft-guide.md
en/device-dev/kernel/kernel-mini-basic-soft-guide.md
+26
-25
zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
+8
-9
zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
+3
-0
zh-cn/device-dev/kernel/kernel-mini-basic-soft-guide.md
zh-cn/device-dev/kernel/kernel-mini-basic-soft-guide.md
+21
-20
未找到文件。
en/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
浏览文件 @
1a32ca3a
...
@@ -131,8 +131,6 @@ VOID RecvEntry(VOID)
...
@@ -131,8 +131,6 @@ VOID RecvEntry(VOID)
CHAR readBuf[BUFFER_LEN] = {0};
CHAR readBuf[BUFFER_LEN] = {0};
UINT32 readLen = BUFFER_LEN;
UINT32 readLen = BUFFER_LEN;
// Sleep for 1s.
usleep(1000000);
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
if(ret != LOS_OK) {
if(ret != LOS_OK) {
printf("recv message failure, error: %x\n", ret);
printf("recv message failure, error: %x\n", ret);
...
@@ -145,12 +143,12 @@ VOID RecvEntry(VOID)
...
@@ -145,12 +143,12 @@ VOID RecvEntry(VOID)
printf("delete the queue failure, error: %x\n", ret);
printf("delete the queue failure, error: %x\n", ret);
}
}
printf("delete the queue success
!
\n");
printf("delete the queue success
.
\n");
}
}
UINT32 ExampleQueue(VOID)
UINT32 ExampleQueue(VOID)
{
{
printf("start queue example\n");
printf("start queue example
.
\n");
UINT32 ret = 0;
UINT32 ret = 0;
UINT32 task1, task2;
UINT32 task1, task2;
TSK_INIT_PARAM_S initParam = {0};
TSK_INIT_PARAM_S initParam = {0};
...
@@ -169,6 +167,7 @@ UINT32 ExampleQueue(VOID)
...
@@ -169,6 +167,7 @@ UINT32 ExampleQueue(VOID)
initParam.pcName = "RecvQueue";
initParam.pcName = "RecvQueue";
initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry;
initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry;
initParam.usTaskPrio = 10;
ret = LOS_TaskCreate(&task2, &initParam);
ret = LOS_TaskCreate(&task2, &initParam);
if(ret != LOS_OK) {
if(ret != LOS_OK) {
printf("create task2 failed, error: %x\n", ret);
printf("create task2 failed, error: %x\n", ret);
...
@@ -180,7 +179,7 @@ UINT32 ExampleQueue(VOID)
...
@@ -180,7 +179,7 @@ UINT32 ExampleQueue(VOID)
printf("create queue failure, error: %x\n", ret);
printf("create queue failure, error: %x\n", ret);
}
}
printf("create the queue success
!
\n");
printf("create the queue success
.
\n");
LOS_TaskUnlock();
LOS_TaskUnlock();
return ret;
return ret;
}
}
...
@@ -191,9 +190,9 @@ UINT32 ExampleQueue(VOID)
...
@@ -191,9 +190,9 @@ UINT32 ExampleQueue(VOID)
The development is successful if the return result is as follows:
The development is successful if the return result is as follows:
```
```
start
test example
start
queue example.
create the queue success
!
create the queue success
.
recv message: test message
recv message: test message
.
delete the queue success
!
delete the queue success
.
```
```
en/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
浏览文件 @
1a32ca3a
...
@@ -176,6 +176,9 @@ The sample code is as follows:
...
@@ -176,6 +176,9 @@ The sample code is as follows:
```
```
#include "los_memory.h"
#include "los_memory.h"
#define TEST_POOL_SIZE (2*1024)
__attribute__((aligned(4))) UINT8 g_testPool[TEST_POOL_SIZE];
VOID Example_DynMem(VOID)
VOID Example_DynMem(VOID)
{
{
UINT32 *mem = NULL;
UINT32 *mem = NULL;
...
...
en/device-dev/kernel/kernel-mini-basic-soft-guide.md
浏览文件 @
1a32ca3a
...
@@ -112,57 +112,58 @@ UINT32 g_timerCount2 = 0;
...
@@ -112,57 +112,58 @@ UINT32 g_timerCount2 = 0;
/* Task ID*/
/* Task ID*/
UINT32 g_testTaskId01;
UINT32 g_testTaskId01;
void Timer1_Callback(UINT32 arg) //Callback function 1
void Timer1_Callback(UINT32 arg) //
Callback function 1
{
{
UINT32 tick_last1;
UINT32 tick_last1;
g_timerCount1++;
g_timerCount1++;
tick_last1
=
(UINT32)LOS_TickCountGet(); //Obtain the current number of ticks.
tick_last1
=
(UINT32)LOS_TickCountGet(); //Obtain the current number of ticks.
printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1);
printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1);
}
}
void Timer2_Callback(UINT32 arg) //Callback function 2
void Timer2_Callback(UINT32 arg) //
Callback function 2
{
{
UINT32 tick_last2;
UINT32 tick_last2;
tick_last2
=
(UINT32)LOS_TickCountGet();
tick_last2
=
(UINT32)LOS_TickCountGet();
g_timerCount2++;
g_timerCount2++;
printf("g_timerCount2=%d tick_last2=%d\n", g_timerCount2, tick_last2);
printf("g_timerCount2=%d tick_last2=%d\n", g_timerCount2, tick_last2);
}
}
void Timer_example(void)
void Timer_example(void)
{
{
UINT32 id1; // timer id
UINT32 ret;
UINT32 id2; // timer id
UINT32 id1; // timer id1
UINT32 uwTick;
UINT32 id2; // timer id2
UINT32 tickCount;
/* Create a one-shot software timer, with the number of ticks set to 1000. When the number of ticks reaches 1000, callback function 1 is executed. */
/* Create a one-shot software timer, with the number of ticks set to 1000. When the number of ticks reaches 1000, callback function 1 is executed. */
LOS_SwtmrCreate
(1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1);
LOS_SwtmrCreate(1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1);
/* Create a periodic software timer and execute callback function 2 every 100 ticks. */
/* Create a periodic software timer and execute callback function 2 every 100 ticks. */
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
printf("create Timer1 success\n");
printf("create Timer1 success\n");
LOS_SwtmrStart
(id1); // Start the one-shot software timer.
LOS_SwtmrStart(id1); // Start the one-shot software timer.
printf("start Timer1 sucess\n");
printf("start Timer1 suc
c
ess\n");
LOS_TaskDelay(200); // Delay 200 ticks.
LOS_TaskDelay(200); // Delay 200 ticks.
LOS_SwtmrTimeGet(id1, &
uwTick
); // Obtain the number of remaining ticks of the one-short software timer.
LOS_SwtmrTimeGet(id1, &
tickCount
); // Obtain the number of remaining ticks of the one-short software timer.
printf("
uwTick =%d\n", uwTick
);
printf("
tickCount=%d\n", tickCount
);
LOS_SwtmrStop(id1); // Stop the software timer.
LOS_SwtmrStop(id1); // Stop the software timer.
printf("stop Timer1 sucess\n");
printf("stop Timer1 suc
c
ess\n");
LOS_SwtmrStart(id1);
LOS_SwtmrStart(id1);
LOS_TaskDelay(1000);
LOS_TaskDelay(1000);
LOS_SwtmrDelete(id1); // Delete the software timer.
printf("delete Timer1 sucess\n");
LOS_SwtmrStart(id2); // Start the periodic software timer.
LOS_SwtmrStart(id2); // Start the periodic software timer.
printf("start Timer2\n");
printf("start Timer2\n");
LOS_TaskDelay(1000);
LOS_TaskDelay(1000);
LOS_SwtmrStop(id2);
LOS_SwtmrStop(id2);
LOS_SwtmrDelete(id2);
ret = LOS_SwtmrDelete(id2); // Delete the software timer.
if (ret == LOS_OK) {
printf("delete Timer2 success\n");
}
}
}
UINT32 Example_TaskEntry(VOID)
UINT32 Example_TaskEntry(VOID)
...
@@ -170,11 +171,11 @@ UINT32 Example_TaskEntry(VOID)
...
@@ -170,11 +171,11 @@ UINT32 Example_TaskEntry(VOID)
UINT32 ret;
UINT32 ret;
TSK_INIT_PARAM_S task1;
TSK_INIT_PARAM_S task1;
/* Lock task scheduling.*/
/* Lock task scheduling.
*/
LOS_TaskLock();
LOS_TaskLock();
/* Create task 1.*/
/* Create task 1.
*/
memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
(VOID)
memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)Timer_example;
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)Timer_example;
task1.pcName = "TimerTsk";
task1.pcName = "TimerTsk";
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
...
@@ -185,7 +186,7 @@ UINT32 Example_TaskEntry(VOID)
...
@@ -185,7 +186,7 @@ UINT32 Example_TaskEntry(VOID)
return LOS_NOK;
return LOS_NOK;
}
}
/* Unlock task scheduling.*/
/* Unlock task scheduling.
*/
LOS_TaskUnlock();
LOS_TaskUnlock();
return LOS_OK;
return LOS_OK;
...
@@ -198,11 +199,10 @@ The output is as follows:
...
@@ -198,11 +199,10 @@ The output is as follows:
```
```
create Timer1 success
create Timer1 success
start Timer1 sucess
start Timer1 suc
c
ess
uwTick
=798
tickCount
=798
stop Timer1 sucess
stop Timer1 suc
c
ess
g_timerCount1=1, tick_last1=1208
g_timerCount1=1, tick_last1=1208
delete Timer1 sucess
start Timer2
start Timer2
g_timerCount2=1 tick_last2=1313
g_timerCount2=1 tick_last2=1313
g_timerCount2=2 tick_last2=1413
g_timerCount2=2 tick_last2=1413
...
@@ -214,5 +214,6 @@ g_timerCount2=7 tick_last2=1913
...
@@ -214,5 +214,6 @@ g_timerCount2=7 tick_last2=1913
g_timerCount2=8 tick_last2=2013
g_timerCount2=8 tick_last2=2013
g_timerCount2=9 tick_last2=2113
g_timerCount2=9 tick_last2=2113
g_timerCount2=10 tick_last2=2213
g_timerCount2=10 tick_last2=2213
delete Timer2 success
```
```
zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue-guide.md
浏览文件 @
1a32ca3a
...
@@ -131,8 +131,6 @@ VOID RecvEntry(VOID)
...
@@ -131,8 +131,6 @@ VOID RecvEntry(VOID)
CHAR readBuf[BUFFER_LEN] = {0};
CHAR readBuf[BUFFER_LEN] = {0};
UINT32 readLen = BUFFER_LEN;
UINT32 readLen = BUFFER_LEN;
//休眠1s
usleep(1000000);
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
if(ret != LOS_OK) {
if(ret != LOS_OK) {
printf("recv message failure, error: %x\n", ret);
printf("recv message failure, error: %x\n", ret);
...
@@ -145,12 +143,12 @@ VOID RecvEntry(VOID)
...
@@ -145,12 +143,12 @@ VOID RecvEntry(VOID)
printf("delete the queue failure, error: %x\n", ret);
printf("delete the queue failure, error: %x\n", ret);
}
}
printf("delete the queue success
!
\n");
printf("delete the queue success
.
\n");
}
}
UINT32 ExampleQueue(VOID)
UINT32 ExampleQueue(VOID)
{
{
printf("start queue example\n");
printf("start queue example
.
\n");
UINT32 ret = 0;
UINT32 ret = 0;
UINT32 task1, task2;
UINT32 task1, task2;
TSK_INIT_PARAM_S initParam = {0};
TSK_INIT_PARAM_S initParam = {0};
...
@@ -169,6 +167,7 @@ UINT32 ExampleQueue(VOID)
...
@@ -169,6 +167,7 @@ UINT32 ExampleQueue(VOID)
initParam.pcName = "RecvQueue";
initParam.pcName = "RecvQueue";
initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry;
initParam.pfnTaskEntry = (TSK_ENTRY_FUNC)RecvEntry;
initParam.usTaskPrio = 10;
ret = LOS_TaskCreate(&task2, &initParam);
ret = LOS_TaskCreate(&task2, &initParam);
if(ret != LOS_OK) {
if(ret != LOS_OK) {
printf("create task2 failed, error: %x\n", ret);
printf("create task2 failed, error: %x\n", ret);
...
@@ -180,7 +179,7 @@ UINT32 ExampleQueue(VOID)
...
@@ -180,7 +179,7 @@ UINT32 ExampleQueue(VOID)
printf("create queue failure, error: %x\n", ret);
printf("create queue failure, error: %x\n", ret);
}
}
printf("create the queue success
!
\n");
printf("create the queue success
.
\n");
LOS_TaskUnlock();
LOS_TaskUnlock();
return ret;
return ret;
}
}
...
@@ -191,9 +190,9 @@ UINT32 ExampleQueue(VOID)
...
@@ -191,9 +190,9 @@ UINT32 ExampleQueue(VOID)
编译运行得到的结果为:
编译运行得到的结果为:
```
```
start
test example
start
queue example.
create the queue success
!
create the queue success
.
recv message: test message
recv message: test message
.
delete the queue success
!
delete the queue success
.
```
```
zh-cn/device-dev/kernel/kernel-mini-basic-memory-dynamic.md
浏览文件 @
1a32ca3a
...
@@ -197,6 +197,9 @@ OpenHarmony LiteOS-M的动态内存管理主要为用户提供以下功能,接
...
@@ -197,6 +197,9 @@ OpenHarmony LiteOS-M的动态内存管理主要为用户提供以下功能,接
```
```
#include "los_memory.h"
#include "los_memory.h"
#define TEST_POOL_SIZE (2*1024)
__attribute__((aligned(4))) UINT8 g_testPool[TEST_POOL_SIZE];
VOID Example_DynMem(VOID)
VOID Example_DynMem(VOID)
{
{
UINT32 *mem = NULL;
UINT32 *mem = NULL;
...
...
zh-cn/device-dev/kernel/kernel-mini-basic-soft-guide.md
浏览文件 @
1a32ca3a
...
@@ -116,53 +116,54 @@ void Timer1_Callback(UINT32 arg) // 回调函数1
...
@@ -116,53 +116,54 @@ void Timer1_Callback(UINT32 arg) // 回调函数1
{
{
UINT32 tick_last1;
UINT32 tick_last1;
g_timerCount1++;
g_timerCount1++;
tick_last1
=
(UINT32)LOS_TickCountGet(); // 获取当前Tick数
tick_last1
=
(UINT32)LOS_TickCountGet(); // 获取当前Tick数
printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1);
printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1);
}
}
void Timer2_Callback(UINT32 arg) // 回调函数2
void Timer2_Callback(UINT32 arg) // 回调函数2
{
{
UINT32 tick_last2;
UINT32 tick_last2;
tick_last2
=
(UINT32)LOS_TickCountGet();
tick_last2
=
(UINT32)LOS_TickCountGet();
g_timerCount2++;
g_timerCount2++;
printf("g_timerCount2=%d tick_last2=%d\n", g_timerCount2, tick_last2);
printf("g_timerCount2=%d tick_last2=%d\n", g_timerCount2, tick_last2);
}
}
void Timer_example(void)
void Timer_example(void)
{
{
UINT32 id1; // timer id
UINT32 ret;
UINT32 id2; // timer id
UINT32 id1; // timer id1
UINT32 uwTick;
UINT32 id2; // timer id2
UINT32 tickCount;
/*创建单次软件定时器,Tick数为1000,启动到1000Tick数时执行回调函数1 */
/*创建单次软件定时器,Tick数为1000,启动到1000Tick数时执行回调函数1 */
LOS_SwtmrCreate
(1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1);
LOS_SwtmrCreate(1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1);
/*创建周期性软件定时器,每100Tick数执行回调函数2 */
/*创建周期性软件定时器,每100Tick数执行回调函数2 */
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
printf("create Timer1 success\n");
printf("create Timer1 success\n");
LOS_SwtmrStart
(id1); //启动单次软件定时器
LOS_SwtmrStart(id1); //启动单次软件定时器
printf("start Timer1 sucess\n");
printf("start Timer1 suc
c
ess\n");
LOS_TaskDelay(200); //延时200Tick数
LOS_TaskDelay(200); //延时200Tick数
LOS_SwtmrTimeGet(id1, &
uwTick
); // 获得单次软件定时器剩余Tick数
LOS_SwtmrTimeGet(id1, &
tickCount
); // 获得单次软件定时器剩余Tick数
printf("
uwTick =%d\n", uwTick
);
printf("
tickCount=%d\n", tickCount
);
LOS_SwtmrStop(id1); // 停止软件定时器
LOS_SwtmrStop(id1); // 停止软件定时器
printf("stop Timer1 sucess\n");
printf("stop Timer1 suc
c
ess\n");
LOS_SwtmrStart(id1);
LOS_SwtmrStart(id1);
LOS_TaskDelay(1000);
LOS_TaskDelay(1000);
LOS_SwtmrDelete(id1); // 删除软件定时器
printf("delete Timer1 sucess\n");
LOS_SwtmrStart(id2); // 启动周期性软件定时器
LOS_SwtmrStart(id2); // 启动周期性软件定时器
printf("start Timer2\n");
printf("start Timer2\n");
LOS_TaskDelay(1000);
LOS_TaskDelay(1000);
LOS_SwtmrStop(id2);
LOS_SwtmrStop(id2);
LOS_SwtmrDelete(id2);
ret = LOS_SwtmrDelete(id2); // 删除软件定时器
if (ret == LOS_OK) {
printf("delete Timer2 success\n");
}
}
}
UINT32 Example_TaskEntry(VOID)
UINT32 Example_TaskEntry(VOID)
...
@@ -174,7 +175,7 @@ UINT32 Example_TaskEntry(VOID)
...
@@ -174,7 +175,7 @@ UINT32 Example_TaskEntry(VOID)
LOS_TaskLock();
LOS_TaskLock();
/* 创建任务1 */
/* 创建任务1 */
memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
(VOID)
memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)Timer_example;
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)Timer_example;
task1.pcName = "TimerTsk";
task1.pcName = "TimerTsk";
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
...
@@ -198,11 +199,10 @@ UINT32 Example_TaskEntry(VOID)
...
@@ -198,11 +199,10 @@ UINT32 Example_TaskEntry(VOID)
```
```
create Timer1 success
create Timer1 success
start Timer1 sucess
start Timer1 suc
c
ess
uwTick
=798
tickCount
=798
stop Timer1 sucess
stop Timer1 suc
c
ess
g_timerCount1=1, tick_last1=1208
g_timerCount1=1, tick_last1=1208
delete Timer1 sucess
start Timer2
start Timer2
g_timerCount2=1 tick_last2=1313
g_timerCount2=1 tick_last2=1313
g_timerCount2=2 tick_last2=1413
g_timerCount2=2 tick_last2=1413
...
@@ -214,5 +214,6 @@ g_timerCount2=7 tick_last2=1913
...
@@ -214,5 +214,6 @@ g_timerCount2=7 tick_last2=1913
g_timerCount2=8 tick_last2=2013
g_timerCount2=8 tick_last2=2013
g_timerCount2=9 tick_last2=2113
g_timerCount2=9 tick_last2=2113
g_timerCount2=10 tick_last2=2213
g_timerCount2=10 tick_last2=2213
delete Timer2 success
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录