• Home
Name Date Size #Lines LOC

..--

gr5515_sk_iotlink_demo/12-May-2024-1,697841

gr5515_sk_xts_demo/12-May-2024-1,266965

LICENSED12-May-20249.9 KiB177150

OAT.xmlD12-May-20241.8 KiB3920

README.en.mdD12-May-2024982 3725

README.mdD12-May-20245 KiB189136

README.en.md

1# devboard_vendor_goodix_gr5515_sk_basic
2
3#### Description
4{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
5
6#### Software Architecture
7Software architecture description
8
9#### Installation
10
111.  xxxx
122.  xxxx
133.  xxxx
14
15#### Instructions
16
171.  xxxx
182.  xxxx
193.  xxxx
20
21#### Contribution
22
231.  Fork the repository
242.  Create Feat_xxx branch
253.  Commit your code
264.  Create Pull Request
27
28
29#### Gitee Feature
30
311.  You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
322.  Gitee blog [blog.gitee.com](https://blog.gitee.com)
333.  Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
344.  The most valuable open source project [GVP](https://gitee.com/gvp)
355.  The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
366.  The most popular members  [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
37

README.md

1# vendor_goodix
2
3## 介绍
4
5该仓库托管Goodix开发的基于GR551x BLE产品样例代码。
6
7## 产品样例
8
9支持基于Goodix GR5515 SoC的Starter Kit单板进行开发的BLE应用、XTS测试样例。
10
11代码路径:
12
13```
14device/                               --- 硬件单板相关仓库
15├── boards/goodix                     --- Goodix相关单板
16├── soc/goodix                        --- Goodix相关SoC代码
17vendor/goodix/                        --- vendor_goodix 仓库路径
18├── gr5515_sk_iotlink_demo            --- BLE应用样例
19└── gr5515_sk_xts_demo                --- XTS测试样例
20```
21
22## 新建样例
23
24用户可以将提供的XTS样例复制一份,然后进行裁剪或者修改,实现自己的产品工程,下面举例说明如何新建一个工程,并实现"点灯"。
25
26### 新建工程
27
281. 复制一份"gr5515_sk_xts_demo"放在同级目录下,并改名为"gr5515_sk_led_demo";
292. 进入gr5515_sk_led_demo目录, 编辑config.json文件,修改product_name和product_adapter_dir:
30
31```
32"product_name": "gr5515_sk_led_demo"
33"product_adapter_dir": "//vendor/goodix/gr5515_sk_led_demo/hals"
34```
353. 此工程业务逻辑简单,一些用不到的组件可以去掉,减少源码编译时间,在config.json中可删除xts、security子系统,保留kernel、startup、hiviewdfx、distributedschedule等必要的子系统,可移除如下代码段:
36
37```
38{
39"subsystem": "xts",
40"components": [
41    { "component": "xts_acts", "features":[] },
42    { "component": "xts_tools", "features":[] }
43    ]
44},
45{
46"subsystem": "security",
47"components": [
48    { "component": "huks", "features":
49    [
50        "disable_huks_binary  = true",
51        "disable_authenticate = false",
52        "huks_use_lite_storage = false",
53        "huks_use_hardware_root_key = false",
54        "huks_config_file = \"hks_config_lite.h\""
55    ]
56    }
57]
58}
59```
60
614. 编辑"gr5515_sk_led_demo/BUILD.gn",修改固件名(这里取名为app_led),group名:
62
63```
64# Set firmware name
65fw_img_name = "app_led"
66
67...
68
69group("gr5515_sk_led_demo") {
70}
71
72```
73
74### 实现业务
75
761. 在gr5515_sk_led_demo目录下新建一个led文件夹,用于存放应用源码,并在led目录下新建led.cBUILD.gn77
782. 编辑led.c,调用Harmony OS标准API创建任务,调用HDF驱动接口驱动LED灯,示例如下代码段所示:
79
80```
81#include "ohos_init.h"
82#include "cmsis_os2.h"
83#include "gpio_if.h"
84
85#define LED_TASK_STACK_SIZE   4096
86#define LED_TASK_PRIO         25
87#define LED0                  4
88
89static void *LedTask(const char *arg)
90{
91    (void)arg;
92
93    GpioSetDir(LED0, GPIO_DIR_OUT);
94
95    while (1) {
96        GpioWrite(LED0, GPIO_VAL_LOW);
97        osDelay(1000);
98        GpioWrite(LED0, GPIO_VAL_HIGH);
99        osDelay(1000);
100    }
101}
102
103void LedTaskEntry(void)
104{
105    osThreadAttr_t attr;
106
107    attr.name = "LedTask";
108    attr.attr_bits = 0U;
109    attr.cb_mem = NULL;
110    attr.cb_size = 0U;
111    attr.stack_mem = NULL;
112    attr.stack_size = LED_TASK_STACK_SIZE;
113    attr.priority = LED_TASK_PRIO;
114
115    if (osThreadNew((osThreadFunc_t)LedTask, NULL, &attr) == NULL) {
116        printf("Falied to create LedTask!\n");
117    }
118}
119
120SYS_RUN(LedTaskEntry);
121
122```
123
1243. 编辑"led/BUILD.gn"将led.c业务代码加入编译,参考示例如下:
125
126```
127import("//device/board/goodix/${board_name}/liteos_m/config.gni")
128
129static_library("led_demo") {
130   configs = []
131
132   sources = [
133      "led.c",
134   ]
135
136   cflags = board_cflags
137   include_dirs = board_include_dirs
138}
139```
140led.c编译后,会在libs目录下生成"libled_demo.a"静态库。
141
1424. 编辑"gr5515_sk_led_demo/BUILD.gn", 将"led_demo"加入工程依赖,移除XTS相关的静态库,并添加"libled_demo.a"静态,如下示例代码所示:
143
144```
145executable("${fw_img_name}.elf") {
146    deps = [
147        "//build/lite:ohos",
148        "led:led_demo",
149    ]
150
151    ldflags = [
152        "-Wl,--whole-archive",
153        "-lled_demo",
154        "-Wl,--no-whole-archive",
155    ]
156}
157```
158
159### 编译烧录
160
161在OpenHarmony源码根目录下,执行`hb set`, 选中"gr5515_sk_led_demo"工程:
162
163```
164goodix
165   gr5515_sk_xts_demo
166 ❯ gr5515_sk_led_demo
167```
168
169继续执行 `hb build -f`, 开始构建工程,待工程构建完毕,生成的固件存放在"**/out/gr5515_sk/gr5515_sk_led_demo/bin/app_led/app_led_fw.bin**", 可使用GProgrammer软件烧录到Flash。
170
171更详细的编译和烧录过程,请参考 [编译烧录教程](https://gitee.com/openharmony-sig/device_soc_goodix/blob/master/README.md)
172
173如果用户使用的是GR5515 Starter Kit开发板,固件烧录成功后,程序启动将观察到开发板上LED0间隔1S闪烁。
174
175至此,基于OpenHarmony的一个简单的示例工程搭建完成,用户可按此方法,搭建自己产品工程。
176
177## 贡献
178
179[如何参与](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
180
181[Commit message规范](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83?sort_id=4042860)
182
183
184## 相关仓库
185
186[device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)
187
188[device_board_goodix](https://gitee.com/openharmony/device_board_goodix)
189