Skip to content

Commit 22f751f

Browse files
committed
boards: seeed: xioa_esp32c6 external antenna support
This PR adds adds The RF switch node and support for the extenal antenna. Signed-off-by: Mario Paja <[email protected]>
1 parent 3c7e43f commit 22f751f

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2025 Mario Paja
2+
# SPDX-License-Identifier: Apache-2.0
3+
zephyr_library()
4+
zephyr_library_sources(xiao_esp32c6_hpcore_init.c)

boards/seeed/xiao_esp32c6/Kconfig

+7
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ config HEAP_MEM_POOL_ADD_SIZE_BOARD
55
int
66
default 4096 if BOARD_XIAO_ESP32C6_ESP32C6_HPCORE
77
default 256 if BOARD_XIAO_ESP32C6_ESP32C6_LPCORE
8+
9+
config XIAO_ESP32C6_EXT_ANTENNA
10+
bool "XIAO ESP32C6 External Antenna"
11+
default n
12+
help
13+
Select the external antenna of the XIAO ESP32-C6.
14+
By default, the onboard antenna is used.

boards/seeed/xiao_esp32c6/xiao_esp32c6_hpcore.dts

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
watchdog0 = &wdt0;
3838
};
3939

40+
rf_switch {
41+
compatible = "gpio-keys";
42+
rf_switch_en: rf_switch_en {
43+
gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
44+
label = "Activate RF switch control";
45+
};
46+
ext_ant: ext_ant {
47+
gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
48+
label = "External Antenna Selector";
49+
};
50+
};
4051
};
4152

4253
&trng0 {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2025 Mario Paja
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/drivers/gpio.h>
9+
#include <zephyr/init.h>
10+
11+
static int board_init(void)
12+
{
13+
const struct gpio_dt_spec rf_switch_en =
14+
GPIO_DT_SPEC_GET(DT_NODELABEL(rf_switch_en), gpios);
15+
const struct gpio_dt_spec ext_ant_sel = GPIO_DT_SPEC_GET(DT_NODELABEL(ext_ant), gpios);
16+
17+
if (!device_is_ready(rf_switch_en.port)) {
18+
return -ENODEV;
19+
}
20+
gpio_pin_configure_dt(&rf_switch_en, GPIO_OUTPUT);
21+
22+
if (!device_is_ready(ext_ant_sel.port)) {
23+
return -ENODEV;
24+
}
25+
gpio_pin_configure_dt(&ext_ant_sel, GPIO_OUTPUT);
26+
27+
gpio_pin_set_dt(&rf_switch_en, 1);
28+
29+
#ifdef CONFIG_XIAO_ESP32C6_EXT_ANTENNA
30+
gpio_pin_set_dt(&ext_ant_sel, 1);
31+
#else
32+
gpio_pin_set_dt(&ext_ant_sel, 0);
33+
#endif
34+
35+
return 0;
36+
}
37+
38+
SYS_INIT(board_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

0 commit comments

Comments
 (0)