Skip to content

Commit 6d773f5

Browse files
committed
very early draft of silabs port
1 parent 1a1d5c6 commit 6d773f5

18 files changed

+1011
-0
lines changed

examples/valve/silabs/.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "arm"
25+
target_os = "freertos"
26+
chip_openthread_ftd = true
27+
28+
import("//openthread.gni")
29+
}

examples/valve/silabs/BUILD.gn

+235
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
import("//build_overrides/efr32_sdk.gni")
18+
import("//build_overrides/pigweed.gni")
19+
20+
import("${build_root}/config/defaults.gni")
21+
import("${efr32_sdk_build_root}/silabs_executable.gni")
22+
23+
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
24+
import("${chip_root}/src/platform/device.gni")
25+
import("${chip_root}/third_party/silabs/silabs_board.gni")
26+
27+
if (chip_enable_pw_rpc) {
28+
import("//build_overrides/pigweed.gni")
29+
import("$dir_pw_build/target_types.gni")
30+
}
31+
32+
assert(current_os == "freertos")
33+
34+
silabs_project_dir = "${chip_root}/examples/valve/silabs"
35+
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
36+
37+
if (wifi_soc) {
38+
import("${chip_root}/third_party/silabs/SiWx917_sdk.gni")
39+
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
40+
} else {
41+
import("${efr32_sdk_build_root}/efr32_sdk.gni")
42+
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
43+
}
44+
45+
import("${examples_common_plat_dir}/args.gni")
46+
47+
declare_args() {
48+
# Dump memory usage at link time.
49+
chip_print_memory_usage = false
50+
}
51+
52+
if (slc_generate) {
53+
# Generate Project Specific config (Board, hardware used etc..)
54+
print(exec_script("${chip_root}/third_party/silabs/slc_gen/run_slc.py",
55+
[
56+
rebase_path(chip_root),
57+
"${silabs_board}",
58+
"${disable_lcd}",
59+
"${use_wstk_buttons}",
60+
"${use_wstk_leds}",
61+
"${use_external_flash}",
62+
"${silabs_mcu}",
63+
rebase_path(slc_gen_path),
64+
],
65+
"list lines"))
66+
}
67+
68+
if (wifi_soc) {
69+
siwx917_sdk("sdk") {
70+
sources = [
71+
"${examples_common_plat_dir}/FreeRTOSConfig.h",
72+
"${silabs_project_dir}/include/CHIPProjectConfig.h",
73+
]
74+
75+
include_dirs = [
76+
"${chip_root}/src/platform/silabs/SiWx917",
77+
"${silabs_project_dir}/include",
78+
"${examples_plat_dir}",
79+
"${chip_root}/src/lib",
80+
"${examples_common_plat_dir}",
81+
]
82+
83+
defines = []
84+
if (chip_enable_pw_rpc) {
85+
defines += [
86+
"HAL_VCOM_ENABLE=1",
87+
"PW_RPC_ENABLED",
88+
]
89+
}
90+
}
91+
} else {
92+
efr32_sdk("sdk") {
93+
sources = [
94+
"${examples_common_plat_dir}/FreeRTOSConfig.h",
95+
"${silabs_project_dir}/include/CHIPProjectConfig.h",
96+
]
97+
98+
include_dirs = [
99+
"${chip_root}/src/platform/silabs/efr32",
100+
"${silabs_project_dir}/include",
101+
"${examples_plat_dir}",
102+
"${chip_root}/src/lib",
103+
"${examples_common_plat_dir}",
104+
]
105+
106+
if (use_wf200) {
107+
# TODO efr32_sdk should not need a header from this location
108+
include_dirs += [ "${examples_plat_dir}/wf200" ]
109+
}
110+
111+
if (chip_enable_ble_rs911x) {
112+
# TODO efr32_sdk should not need a header from this location
113+
include_dirs += [
114+
"${examples_plat_dir}/rs911x",
115+
"${examples_plat_dir}/rs911x/hal",
116+
]
117+
}
118+
119+
defines = []
120+
if (chip_enable_pw_rpc) {
121+
defines += [
122+
"HAL_VCOM_ENABLE=1",
123+
"PW_RPC_ENABLED",
124+
]
125+
}
126+
}
127+
}
128+
silabs_executable("drink-machine") {
129+
output_name = "drink-machine.out"
130+
include_dirs = [ "include" ]
131+
defines = []
132+
133+
if (silabs_board == "BRD2704A") {
134+
defines += [ "SL_STATUS_LED=0" ]
135+
}
136+
137+
sources = [
138+
"${examples_common_plat_dir}/main.cpp",
139+
"include/DrinksMachineDeviceDriver.h",
140+
"src/AppTask.cpp",
141+
"src/DrinksMachineDeviceDriver.cpp",
142+
"src/ZclCallbacks.cpp",
143+
]
144+
145+
deps = [
146+
":sdk",
147+
app_data_model,
148+
]
149+
150+
if (wifi_soc) {
151+
deps += [ "${examples_plat_dir}:siwx917-common" ]
152+
} else {
153+
deps += [ "${examples_plat_dir}:efr32-common" ]
154+
}
155+
156+
if (chip_enable_pw_rpc) {
157+
defines += [
158+
"PW_RPC_ENABLED",
159+
"PW_RPC_ATTRIBUTE_SERVICE=1",
160+
"PW_RPC_BUTTON_SERVICE=1",
161+
"PW_RPC_DESCRIPTOR_SERVICE=1",
162+
"PW_RPC_DEVICE_SERVICE=1",
163+
"PW_RPC_OTCLI_SERVICE=1",
164+
"PW_RPC_THREAD_SERVICE=1",
165+
"PW_RPC_TRACING_SERVICE=1",
166+
]
167+
168+
sources += [
169+
"${chip_root}/examples/common/pigweed/RpcService.cpp",
170+
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
171+
"${examples_common_plat_dir}/PigweedLogger.cpp",
172+
"${examples_common_plat_dir}/Rpc.cpp",
173+
]
174+
175+
deps += [
176+
"$dir_pw_hdlc:default_addresses",
177+
"$dir_pw_hdlc:rpc_channel_output",
178+
"$dir_pw_stream:sys_io_stream",
179+
"$dir_pw_trace",
180+
"$dir_pw_trace_tokenized",
181+
"$dir_pw_trace_tokenized:trace_rpc_service",
182+
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc",
183+
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
184+
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
185+
"${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc",
186+
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
187+
"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc",
188+
"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc",
189+
]
190+
191+
if (wifi_soc) {
192+
deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ]
193+
} else {
194+
deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ]
195+
}
196+
197+
deps += pw_build_LINK_DEPS
198+
199+
include_dirs += [
200+
"${chip_root}/examples/common",
201+
"${chip_root}/examples/common/pigweed/efr32",
202+
]
203+
}
204+
205+
ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld"
206+
207+
inputs = [ ldscript ]
208+
209+
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
210+
211+
if (chip_print_memory_usage) {
212+
ldflags += [
213+
"-Wl,--print-memory-usage",
214+
"-fstack-usage",
215+
]
216+
}
217+
218+
# WiFi Settings
219+
if (chip_enable_wifi) {
220+
ldflags += [
221+
"-Wl,--defsym",
222+
"-Wl,SILABS_WIFI=1",
223+
]
224+
}
225+
226+
output_dir = root_out_dir
227+
}
228+
229+
group("silabs") {
230+
deps = [ ":drink-machine" ]
231+
}
232+
233+
group("default") {
234+
deps = [ ":silabs" ]
235+
}

examples/valve/silabs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
./scripts/examples/gn_silabs_example.sh ./examples/valve/silabs/
2+
./out/drink-machine-efr BRD2703A
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2024 Google, all rights reserved
2+
#
3+
4+
import("//build_overrides/chip.gni")
5+
import("${chip_root}/config/standalone/args.gni")
6+
7+
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
8+
chip_enable_openthread = false
9+
import("${chip_root}/src/platform/silabs/wifi_args.gni")
10+
11+
chip_enable_read_client = false
12+
13+
chip_enable_ota_requestor = false
14+
app_data_model = "${chip_root}/examples/valve/valve-common:valve-common"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "arm"
25+
target_os = "freertos"
26+
chip_enable_wifi = true
27+
import("//build_for_wifi_args.gni")
28+
}

examples/valve/silabs/build_overrides

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build_overrides
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
*
3+
* Copyright (c) 2020 Project CHIP Authors
4+
* Copyright (c) 2019 Google LLC.
5+
* All rights reserved.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#pragma once
21+
22+
#include "silabs_utils.h"
23+
24+
#define APP_TASK_NAME "app_task"
25+
26+
#define BLE_DEV_NAME "DMDEV"
27+
28+
#define APP_EVENT_QUEUE_SIZE 30

0 commit comments

Comments
 (0)