• Home
Name Date Size #Lines LOC

..--

gr5515_sk_iotlink_demo/07-Sep-2024-1,646794

gr5515_sk_xts_demo/07-Sep-2024-1,210912

CODEOWNERSD07-Sep-2024630 1715

LICENSED07-Sep-20249.9 KiB177150

OAT.xmlD07-Sep-20241.8 KiB3920

README.en.mdD07-Sep-2024982 3725

README.mdD07-Sep-20245.2 KiB197142

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