Skip to content

Commit f869dea

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 7235bbd commit f869dea

File tree

6 files changed

+69
-18
lines changed

6 files changed

+69
-18
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2025 Mario Paja
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if(CONFIG_ESP32_EXT_ANTENNA)
5+
zephyr_library()
6+
zephyr_library_sources(board.c)
7+
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 konfiguration"
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: "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
@@ -37,6 +37,11 @@
3737
watchdog0 = &wdt0;
3838
};
3939

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

4247
&trng0 {

dts/bindings/net/wireless/gpio-rf-switch.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)