• Home
Name Date Size #Lines LOC

..--

BUILD.gnD22-Oct-2025764 2219

README.mdD22-Oct-20253.4 KiB8660

delay.cD22-Oct-20251.6 KiB5432

README.md

1# 润和星闪派物联网开发套件--延时(Delay)
2
3![hihope_illustration](https://gitee.com/hihopeorg/hispark-hm-pegasus/raw/master/docs/figures/hihope_illustration.png)
4
5[润和星闪派物联网开发套件](https://item.taobao.com/item.htm?abbucket=16&id=816685710481&ns=1&priceTId=214783b117346662457694855ed644&skuId=5533042544092&spm=a21n57.sem.item.49.46a639031zWytE&utparam=%7B%22aplus_abtest%22%3A%22b28048df8f009463834be6bdac2a3713%22%7D&xxc=taobaoSearch) 基于海思WS63E解决方案的一套软硬件组合的综合性开发套件。
6
7![wifi_iot](https://img.alicdn.com/imgextra/i4/3583112207/O1CN01SvRG981SAr7bdEg3i_!!3583112207.png)
8
9## 一、Delay API
10
11| API名称      | 说明                 |
12| ------------ | -------------------- |
13| osDelay      | 等待指定的ticks      |
14| osDelayUntil | 等待到指定的时钟周期 |
15
16## 二、代码分析
17
18使用`osDelay`让线程等待100个时钟周期,然后通过`osKernelGetTickCount`获取当前的时钟周期tick, 在此基础上增加100个时钟周期,之后调用`osDelayUntil`让线程等待tick + 100个时钟周期后恢复运行
19
20```
21void rtosv2_delay_main(void *arg) {
22    (void)arg;
23
24    printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
25    osStatus_t status = osDelay(100);
26    printf("[Delay Test] osDelay, status: %d.\r\n", status);
27    printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
28
29    uint32_t tick = osKernelGetTickCount();
30    tick += 100;
31    status = osDelayUntil(tick);
32    printf("[Delay Test] osDelayUntil, status: %d.\r\n", status);
33    printf("[Delay Test] Current system tick: %d.\r\n", osKernelGetTickCount());
34}
35```
36
37
38
39## 三、如何编译
40
411. 将02_delay目录复制到openharmony源码的`applications\sample\wifi-iot\app`目录下,
422. 修改openharmony源码的`applications\sample\wifi-iot\app\BUILD.gn`文件,将其中的 `features` 改为:
43
44```
45    features = [
46        ...
47        "02_delay:delay_demo",
48        ...
49    ]
50```
513. 在`device\soc\hisilicon\ws63v100\sdk\build\config\target_config\ws63\config.py`文件中,找到`'ws63-liteos-app'`部分,在其`'ram_component'`中,添加以下代码:
52```
53"delay_demo"
54```
55
564. 在`device\soc\hisilicon\ws63v100\sdk\libs_url\ws63\cmake\ohos.cmake`文件中,找到`"ws63-liteos-app"`部分,在其`set(COMPONENT_LIST`部分,添加以下代码:
57```
58"delay_demo"
59```
605. 在openharmony sdk根目录目录执行:`rm -rf out && hb set -p nearlink_dk_3863 && hb build -f`
61
62## 四、运行结果
63
64设置串口工具波特率为115200,复位开发板,查看打印结果
65
66```
67[Delay Test]  Current system tick: 248.
68[Delay Test]  osDelay, status: 0.
69[Delay Test]  Current system tick: 348.
70[Delay Test]  osDelayUntil, status: 0.
71[Delay Test]  Current system tick: 448.
72```
73
74### 【套件支持】
75
76##### 1. 套件购买  https://item.taobao.com/item.htm?abbucket=16&id=816685710481&ns=1&priceTId=214783b117346662457694855ed644&skuId=5533042544092&spm=a21n57.sem.item.49.46a639031zWytE&utparam=%7B%22aplus_abtest%22%3A%22b28048df8f009463834be6bdac2a3713%22%7D&xxc=taobaoSearch
77
78##### 2. 技术资料
79
80- Gitee码云网站(使用说明书、规格说明书、OpenHarmony开发案例等) **https://gitee.com/hihopeorg_group/near-link**
81- fbb_ws63代码仓(SDK包、技术文档下载)**https://gitee.com/HiSpark/fbb_ws63**
82
83##### 3. 互动交流
84- 海思社区星闪专区-论坛 **https://developer.hisilicon.com/forum/0133146886267870001**
85
86