wio-e5 : initial port

This commit is contained in:
Florent
2025-05-11 09:26:32 +02:00
parent d072e7b575
commit 35e1901d0e
28 changed files with 4865 additions and 15 deletions

View File

@@ -0,0 +1,31 @@
[lora_e5]
extends = stm32_base
board = lora_e5_dev_board
board_upload.maximum_size = 229376 ; 32kb for FS
build_flags = ${stm32_base.build_flags}
-D RADIO_CLASS=CustomSTM32WLx
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
-D SPI_INTERFACES_COUNT=0
-I variants/wio-e5
build_src_filter = ${stm32_base.build_src_filter}
+<../variants/wio-e5>
[env:wio-e5-repeater]
extends = lora_e5
build_flags = ${lora_e5.build_flags}
-D LORA_TX_POWER=20
-D ADVERT_NAME='"WIO-E5 Repeater"'
-D ADMIN_PASSWORD='"password"'
build_src_filter = ${lora_e5.build_src_filter}
+<../examples/simple_repeater/main.cpp>
[env:wio-e5_companion_radio_usb]
extends = lora_e5
build_flags = ${lora_e5.build_flags}
-D LORA_TX_POWER=20
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
build_src_filter = ${lora_e5.build_src_filter}
+<../examples/companion_radio/*.cpp>
lib_deps = ${lora_e5.lib_deps}
densaugeo/base64 @ ~1.4.0

View File

@@ -0,0 +1,69 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
STM32Board board;
RADIO_CLASS radio = new STM32WLx_Module();
WRAPPER_CLASS radio_driver(radio, board);
static const uint32_t rfswitch_pins[] = {PA4, PA5, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
{STM32WLx::MODE_IDLE, {LOW, LOW}},
{STM32WLx::MODE_RX, {HIGH, LOW}},
{STM32WLx::MODE_TX_HP, {LOW, HIGH}}, // for LoRa-E5 mini
// {STM32WLx::MODE_TX_LP, {HIGH, HIGH}}, // for LoRa-E5-LE mini
END_OF_MODE_TABLE,
};
VolatileRTCClock rtc_clock;
SensorManager sensors;
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
// rtc_clock.begin(Wire);
// #ifdef SX126X_DIO3_TCXO_VOLTAGE
// float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
// #else
// float tcxo = 1.6f;
// #endif
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, 1.7, 0);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
return true; // success
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}

20
variants/wio-e5/target.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/RadioLibWrappers.h>
#include <helpers/stm32/STM32Board.h>
#include <helpers/CustomSTM32WLxWrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/SensorManager.h>
extern STM32Board board;
extern WRAPPER_CLASS radio_driver;
extern VolatileRTCClock rtc_clock;
extern SensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
mesh::LocalIdentity radio_new_identity();

10
variants/wio-e5/variant.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
// UART Definitions
#ifndef SERIAL_UART_INSTANCE
#define SERIAL_UART_INSTANCE 101
#endif
#include <variant_LORA_E5_MINI.h>
#undef RNG