Skip to content

Commit 62e8008

Browse files
committed
boards: seeed: xiao_esp32c6 external antenna support
This PR adds adds The RF switch node and support for the extenal antenna. Signed-off-by: Mario Paja <mariopaja@hotmail.com>
1 parent add9e60 commit 62e8008

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2025 Mario Paja
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
if(CONFIG_ESP32_EXT_ANTENNA)
8+
zephyr_library()
9+
zephyr_library_sources(board.c)
10+
endif()

boards/seeed/xiao_esp32c6/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ 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 configuration"
11+
default y if BOARD_XIAO_ESP32C6_ESP32C6_HPCORE && ESP32_EXT_ANTENNA
12+
select BOARD_LATE_INIT_HOOK

boards/seeed/xiao_esp32c6/board.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
void board_late_init_hook(void)
12+
{
13+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(rf_switch))
14+
const struct gpio_dt_spec rf_switch_en =
15+
GPIO_DT_SPEC_GET(DT_NODELABEL(rf_switch), enable_gpios);
16+
17+
if (gpio_is_ready_dt(&rf_switch_en)) {
18+
gpio_pin_configure_dt(&rf_switch_en, GPIO_OUTPUT_ACTIVE);
19+
}
20+
21+
const struct gpio_dt_spec ant_sel = GPIO_DT_SPEC_GET(DT_NODELABEL(rf_switch), select_gpios);
22+
23+
if (gpio_is_ready_dt(&ant_sel)) {
24+
#ifdef CONFIG_XIAO_ESP32C6_EXT_ANTENNA
25+
gpio_pin_configure_dt(&ant_sel, GPIO_OUTPUT_ACTIVE);
26+
#else
27+
gpio_pin_configure_dt(&ant_sel, GPIO_OUTPUT_INACTIVE);
28+
#endif /* XIAO_ESP32C6_EXT_ANTENNA */
29+
}
30+
31+
#endif /* DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(rf_switch)) */
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025 Mario Paja
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
Group of GPIO-controlled relays used to enable an RF switch and select the active antenna.
6+
7+
compatible: "seeed,xiao-gpio-rf-switch"
8+
9+
properties:
10+
enable-gpios:
11+
type: phandle-array
12+
required: true
13+
description: |
14+
GPIOs to enable the RF switch module.
15+
16+
select-gpios:
17+
type: phandle-array
18+
required: true
19+
description: |
20+
GPIOs to select the active antenna

boards/seeed/xiao_esp32c6/xiao_esp32c6_hpcore.dts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
watchdog0 = &wdt0;
3939
};
4040

41+
rf_switch: rf_switch {
42+
compatible = "seeed,xiao-gpio-rf-switch";
43+
enable-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>;
44+
select-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
45+
};
4146
};
4247

4348
&trng0 {

soc/espressif/common/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ config ESP32_SW_COEXIST_ENABLE
5858
If only Bluetooth is used, it is recommended to disable this option to reduce binary file
5959
size.
6060

61+
config ESP32_EXT_ANTENNA
62+
bool "ESP32 External Antenna Selector"
63+
help
64+
Select the external antenna of custom ESP32 boards.
65+
By default, the onboard antenna is used.
66+
A board late init hook is required to enable and select the external antenna.
67+
6168
endif
6269

6370
rsource "Kconfig.amp"

0 commit comments

Comments
 (0)