Skip to content

Commit 5d85ed4

Browse files
authored
Merge pull request #407 from fdlamotte/seeed_xiao_c6
Seeed xiao c6 support
2 parents 7f0f3b7 + 4579aa2 commit 5d85ed4

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

variants/xiao_c6/platformio.ini

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[Xiao_C6]
2+
extends = esp32c6_base
3+
board = esp32-c6-devkitm-1
4+
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
5+
build_flags =
6+
${esp32c6_base.build_flags}
7+
-I variants/xiao_c6
8+
-D ARDUINO_USB_CDC_ON_BOOT=1
9+
-D ARDUINO_USB_MODE=1
10+
-D P_LORA_TX_LED=15
11+
-D P_LORA_SCLK=19
12+
-D P_LORA_MISO=20
13+
-D P_LORA_MOSI=18
14+
-D P_LORA_NSS=22
15+
-D P_LORA_DIO_1=1
16+
-D P_LORA_BUSY=21
17+
-D P_LORA_RESET=2
18+
-D PIN_BOARD_SDA=16
19+
-D PIN_BOARD_SCL=17
20+
-D SX126X_RXEN=23
21+
-D SX126X_DIO2_AS_RF_SWITCH=true
22+
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
23+
-D SX126X_CURRENT_LIMIT=140
24+
-D SX126X_RX_BOOSTED_GAIN=1
25+
-D RADIO_CLASS=CustomSX1262
26+
-D WRAPPER_CLASS=CustomSX1262Wrapper
27+
-D LORA_TX_POWER=22
28+
-D DISABLE_WIFI_OTA=1
29+
build_src_filter = ${esp32c6_base.build_src_filter}
30+
+<../variants/xiao_c6>
31+
32+
[env:Xiao_C6_Repeater]
33+
extends = Xiao_C6
34+
build_src_filter = ${Xiao_C6.build_src_filter}
35+
+<../examples/simple_repeater/main.cpp>
36+
build_flags =
37+
${Xiao_C6.build_flags}
38+
-D ADVERT_NAME='"Xiao C6 Repeater"'
39+
-D ADVERT_LAT=0.0
40+
-D ADVERT_LON=0.0
41+
-D ADMIN_PASSWORD='"password"'
42+
-D MAX_NEIGHBOURS=8
43+
; -D MESH_PACKET_LOGGING=1
44+
; -D MESH_DEBUG=1
45+
lib_deps =
46+
${Xiao_C6.lib_deps}
47+
; ${esp32_ota.lib_deps}
48+
49+
[env:Xiao_C6_companion_radio_ble]
50+
extends = Xiao_C6
51+
build_flags = ${Xiao_C6.build_flags}
52+
-D MAX_CONTACTS=100
53+
-D MAX_GROUP_CHANNELS=8
54+
-D BLE_PIN_CODE=123456
55+
-D BLE_DEBUG_LOGGING=1
56+
-D OFFLINE_QUEUE_SIZE=256
57+
-D ENABLE_PRIVATE_KEY_IMPORT=1
58+
-D ENABLE_PRIVATE_KEY_EXPORT=1
59+
; -D MESH_PACKET_LOGGING=1
60+
; -D MESH_DEBUG=1
61+
build_src_filter = ${Xiao_C6.build_src_filter}
62+
+<helpers/esp32/*.cpp>
63+
-<helpers/esp32/ESPNOWRadio.cpp>
64+
+<../examples/companion_radio>
65+
lib_deps =
66+
${Xiao_C6.lib_deps}
67+
densaugeo/base64 @ ~1.4.0

variants/xiao_c6/target.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <Arduino.h>
2+
#include "target.h"
3+
4+
ESP32Board board;
5+
6+
#if defined(P_LORA_SCLK)
7+
static SPIClass spi(0);
8+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
9+
#else
10+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
11+
#endif
12+
13+
WRAPPER_CLASS radio_driver(radio, board);
14+
15+
ESP32RTCClock fallback_clock;
16+
AutoDiscoverRTCClock rtc_clock(fallback_clock);
17+
SensorManager sensors;
18+
19+
bool radio_init() {
20+
fallback_clock.begin();
21+
rtc_clock.begin(Wire);
22+
23+
#if defined(P_LORA_SCLK)
24+
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
25+
return radio.std_init(&spi);
26+
#else
27+
return radio.std_init();
28+
#endif
29+
}
30+
31+
uint32_t radio_get_rng_seed() {
32+
return radio.random(0x7FFFFFFF);
33+
}
34+
35+
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
36+
radio.setFrequency(freq);
37+
radio.setSpreadingFactor(sf);
38+
radio.setBandwidth(bw);
39+
radio.setCodingRate(cr);
40+
}
41+
42+
void radio_set_tx_power(uint8_t dbm) {
43+
radio.setOutputPower(dbm);
44+
}
45+
46+
mesh::LocalIdentity radio_new_identity() {
47+
RadioNoiseListener rng(radio);
48+
return mesh::LocalIdentity(&rng); // create new random identity
49+
}

variants/xiao_c6/target.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#define RADIOLIB_STATIC_ONLY 1
4+
#include <RadioLib.h>
5+
#include <helpers/RadioLibWrappers.h>
6+
#include <helpers/ESP32Board.h>
7+
#include <helpers/CustomSX1262Wrapper.h>
8+
#include <helpers/AutoDiscoverRTCClock.h>
9+
#include <helpers/SensorManager.h>
10+
11+
extern ESP32Board board;
12+
extern WRAPPER_CLASS radio_driver;
13+
extern AutoDiscoverRTCClock rtc_clock;
14+
extern SensorManager sensors;
15+
16+
bool radio_init();
17+
uint32_t radio_get_rng_seed();
18+
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
19+
void radio_set_tx_power(uint8_t dbm);
20+
mesh::LocalIdentity radio_new_identity();

0 commit comments

Comments
 (0)