From 38d6ed5f12745bb990daa2e9802c91dc11e580bb Mon Sep 17 00:00:00 2001 From: CIncinnatus <95961533+Cincinnatu@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:36:46 +0800 Subject: [PATCH] Enabled the onboard ceramic antenna by default when creating a new project with XIAO_ESP32C6 (#10066) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create variant.cpp * Update variant.cpp * Update variant.cpp * Update pins_arduino.h * Update variant.cpp * Update variant.cpp * Update variant.cpp * Update variants/XIAO_ESP32C6/variant.cpp Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- variants/XIAO_ESP32C6/pins_arduino.h | 3 +++ variants/XIAO_ESP32C6/variant.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 variants/XIAO_ESP32C6/variant.cpp diff --git a/variants/XIAO_ESP32C6/pins_arduino.h b/variants/XIAO_ESP32C6/pins_arduino.h index 4eb07fb2ac7..c90a3394237 100644 --- a/variants/XIAO_ESP32C6/pins_arduino.h +++ b/variants/XIAO_ESP32C6/pins_arduino.h @@ -41,4 +41,7 @@ static const uint8_t D8 = 19; static const uint8_t D9 = 20; static const uint8_t D10 = 18; +static const uint8_t WIFI_ENABLE = 3; +static const uint8_t WIFI_ANT_CONFIG = 14; + #endif /* Pins_Arduino_h */ diff --git a/variants/XIAO_ESP32C6/variant.cpp b/variants/XIAO_ESP32C6/variant.cpp new file mode 100644 index 00000000000..07bd8489c72 --- /dev/null +++ b/variants/XIAO_ESP32C6/variant.cpp @@ -0,0 +1,21 @@ +/* +*By setting the WIFI_ENABLE and WIFI_ANT_CONFIG pins, +* +*the XIAO_ESP32C6 will turn on the on-board antenna by default after power-on +* +*https://wiki.seeedstudio.com/xiao_esp32c6_getting_started/ +*/ + +#include "esp32-hal-gpio.h" +#include "pins_arduino.h" + +extern "C" { + +void initVariant(void) { + pinMode(WIFI_ENABLE, OUTPUT); + digitalWrite(WIFI_ENABLE, LOW); //turn on this function + + pinMode(WIFI_ANT_CONFIG, OUTPUT); + digitalWrite(WIFI_ANT_CONFIG, LOW); //use built-in antenna, set HIGH to use external antenna +} +}