Merge branch 't3s3_sx1280'

This commit is contained in:
jacob.eva 2024-07-20 16:08:00 +01:00
commit 282815eb95
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E
7 changed files with 162 additions and 58 deletions

View File

@ -14,6 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Interfaces.h"
#include "ROM.h"
#ifndef BOARDS_H
#define BOARDS_H
@ -24,6 +25,7 @@
#define MCU_ESP32 0x81
#define MCU_NRF52 0x71
// Boards
#define BOARD_RNODE 0x31
#define BOARD_HMBRW 0x32
#define BOARD_TBEAM 0x33
@ -36,10 +38,11 @@
#define BOARD_HELTEC32_V3 0x3A
#define BOARD_RNODE_NG_20 0x40
#define BOARD_RNODE_NG_21 0x41
#define BOARD_RNODE_NG_22 0x42
#define BOARD_T3S3 0x42
#define BOARD_GENERIC_NRF52 0x50
#define BOARD_RAK4631 0x51
// Displays
#define OLED 0x01
#define EINK_BW 0x02
#define EINK_3C 0x03
@ -545,7 +548,7 @@
}
};
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
#define IS_ESP32S3 true
#define HAS_DISPLAY true
@ -585,7 +588,7 @@
#endif
#endif
#if BOARD_VARIANT == MODEL_A1
const uint8_t interfaces[INTERFACE_COUNT] = {SX1262};
const bool interface_cfg[INTERFACE_COUNT][3] = {
// SX1262
@ -595,6 +598,17 @@
true // DIO2_AS_RF_SWITCH
},
};
#elif BOARD_VARIANT == MODEL_A5 // SX1280 with PA
const uint8_t interfaces[INTERFACE_COUNT] = {SX1280};
const bool interface_cfg[INTERFACE_COUNT][3] = {
// SX1280
{
false, // DEFAULT_SPI
false, // HAS_TCXO
false // DIO2_AS_RF_SWITCH
},
};
#endif
const uint8_t interface_pins[INTERFACE_COUNT][10] = {
// SX1262
{
@ -610,7 +624,6 @@
-1 // pin_tcxo_enable
}
};
#else
#error An unsupported ESP32 board was selected. Cannot compile RNode firmware.
#endif
@ -689,6 +702,7 @@
#endif
#ifndef INTERFACE_SPI
// INTERFACE_SPI is only required on NRF52 platforms, as the SPI pins are set in the class constructor and not by a setter method.
// Even if custom SPI interfaces are not needed, the array must exist to prevent compilation errors.
#define INTERFACE_SPI
const SPIClass interface_spi[1];

View File

@ -68,7 +68,7 @@ void busyCallback(const void* p) {
#define DISP_RST -1
#define DISP_ADDR 0x3C
#endif
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
#if DISPLAY == OLED
#define DISP_RST 21
#define DISP_ADDR 0x3C
@ -200,7 +200,7 @@ bool display_init() {
digitalWrite(pin_display_en, LOW);
delay(50);
digitalWrite(pin_display_en, HIGH);
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
Wire.begin(SDA_OLED, SCL_OLED);
#elif BOARD_MODEL == BOARD_HELTEC32_V2
Wire.begin(SDA_OLED, SCL_OLED);

View File

@ -71,8 +71,11 @@ firmware-tbeam:
firmware-tbeam_sx126x:
arduino-cli compile --fqbn esp32:esp32:t-beam -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x33\" \"-DMODEM=0x03\""
firmware-t3s3:
arduino-cli compile --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x42\""
firmware-t3s3_sx1262:
arduino-cli compile --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x42\" \"-DBOARD_VARIANT=0xA1\""
firmware-t3s3_sx1280_pa:
arduino-cli compile --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x42\" \"-DBOARD_VARIANT=0xA5\""
firmware-lora32_v10:
arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\""

View File

@ -87,7 +87,7 @@ void setup() {
Serial.begin(serial_baudrate);
#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_RNODE_NG_22
#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_T3S3
// Some boards need to wait until the hardware UART is set up before booting
// the full firmware. In the case of the RAK4631, the line below will wait
// until a serial connection is actually established with a master. Thus, it
@ -1283,7 +1283,7 @@ void process_serial() {
void sleep_now() {
#if HAS_SLEEP == true
#if BOARD_MODEL == BOARD_RNODE_NG_22
#if BOARD_MODEL == BOARD_T3S3
display_intensity = 0;
update_display(true);
#endif

4
ROM.h
View File

@ -30,8 +30,10 @@
#define PRODUCT_FREENODE 0x20
#define MODEL_11 0x11
#define MODEL_12 0x12
#define MODEL_13 0x13 // RAK4631 with WisBlock SX1280 module (LIBSYS002)
#define MODEL_21 0x21 // European band, 868MHz
#define MODEL_A1 0xA1
#define MODEL_A1 0xA1
#define MODEL_A5 0xA5 // T3S3 SX1280 PA
#define MODEL_A6 0xA6
#define MODEL_A4 0xA4
#define MODEL_A9 0xA9

165
Radio.cpp
View File

@ -735,7 +735,7 @@ void sx126x::enableTCXO() {
uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF};
#elif BOARD_MODEL == BOARD_TBEAM
uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};
#else
uint8_t buf[4] = {0};
@ -2192,11 +2192,118 @@ void sx128x::disableTCXO() {
}
void sx128x::setTxPower(int level, int outputPin) {
// PA calculation currently only works for the LoRa1280F27. Support for
// other assemblies would be appreciated in a PR.
if (outputPin == PA_OUTPUT_PA_BOOST_PIN) {
if (level > 27) {
level = 27;
uint8_t tx_buf[2];
#if BOARD_VARIANT == MODEL_13
// RAK4631 with WisBlock SX1280 module (LIBSYS002)
if (level > 27) {
level = 27;
} else if (level < 0) {
level = 0;
}
_txp = level;
int reg_value;
switch (level) {
case 0:
reg_value = -18;
break;
case 1:
reg_value = -17;
break;
case 2:
reg_value = -16;
break;
case 3:
reg_value = -15;
break;
case 4:
reg_value = -14;
break;
case 5:
reg_value = -13;
break;
case 6:
reg_value = -12;
break;
case 7:
reg_value = -10;
break;
case 8:
reg_value = -9;
break;
case 9:
reg_value = -8;
break;
case 10:
reg_value = -7;
break;
case 11:
reg_value = -6;
break;
case 12:
reg_value = -5;
break;
case 13:
reg_value = -4;
break;
case 14:
reg_value = -3;
break;
case 15:
reg_value = -2;
break;
case 16:
reg_value = -1;
break;
case 17:
reg_value = 0;
break;
case 18:
reg_value = 1;
break;
case 19:
reg_value = 2;
break;
case 20:
reg_value = 3;
break;
case 21:
reg_value = 4;
break;
case 22:
reg_value = 5;
break;
case 23:
reg_value = 6;
break;
case 24:
reg_value = 8;
break;
case 25:
reg_value = 9;
break;
case 26:
reg_value = 12;
break;
case 27:
reg_value = 13;
break;
default:
reg_value = 0;
break;
}
tx_buf[0] = reg_value;
tx_buf[1] = 0xE0; // ramping time - 20 microseconds
executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2);
#elif BOARD_VARIANT == MODEL_A5
// T3S3 SX1280 PA
if (level > 20) {
level = 20;
} else if (level < 0) {
level = 0;
}
@ -2206,7 +2313,7 @@ void sx128x::setTxPower(int level, int outputPin) {
int reg_value;
switch (level) {
case 0:
/*case 0:
reg_value = -18;
break;
case 1:
@ -2265,57 +2372,31 @@ void sx128x::setTxPower(int level, int outputPin) {
break;
case 19:
reg_value = 2;
break;
break;*/
case 20:
reg_value = 3;
break;
case 21:
reg_value = 4;
break;
case 22:
reg_value = 5;
break;
case 23:
reg_value = 6;
break;
case 24:
reg_value = 8;
break;
case 25:
reg_value = 9;
break;
case 26:
reg_value = 12;
break;
case 27:
reg_value = 13;
default:
reg_value = 0;
break;
}
uint8_t tx_buf[2];
tx_buf[0] = reg_value;
tx_buf[0] = level;
tx_buf[1] = 0xE0; // ramping time - 20 microseconds
executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2);
} else {
#else
// For SX1280 boards with no specific PA requirements
if (level > 13) {
level = 13;
} else if (level < -18) {
level = -18;
}
_txp = level;
level = level + 18;
uint8_t tx_buf[2];
tx_buf[0] = level;
tx_buf[1] = 0xE0; // ramping time - 20 microseconds
executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2);
}
#endif
executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2);
}
uint8_t sx128x::getTxPower() {

View File

@ -65,9 +65,9 @@ uint8_t eeprom_read(uint32_t mapped_addr);
#if BOARD_MODEL == BOARD_HELTEC32_V3
//https://github.com/espressif/esp-idf/issues/8855
#include "hal/wdt_hal.h"
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
#include "hal/wdt_hal.h"
#else BOARD_MODEL != BOARD_RNODE_NG_22
#else BOARD_MODEL != BOARD_T3S3
#include "soc/rtc_wdt.h"
#endif
#define ISR_VECT IRAM_ATTR
@ -137,7 +137,7 @@ uint8_t boot_vector = 0x00;
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
#elif BOARD_MODEL == BOARD_RNODE_NG_22
#elif BOARD_MODEL == BOARD_T3S3
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
@ -965,6 +965,9 @@ void set_implicit_length(uint8_t len) {
}
void setTXPower(RadioInterface* radio, int txp) {
// Todo, revamp this function. The current parameters for setTxPower are
// suboptimal, as some chips have power amplifiers which means that the max
// dBm is not always the same.
if (model == MODEL_11) {
if (interfaces[radio->getIndex()] == SX128X) {
radio->setTxPower(txp, PA_OUTPUT_PA_BOOST_PIN);
@ -992,6 +995,7 @@ void setTXPower(RadioInterface* radio, int txp) {
if (model == MODEL_A2) radio->setTxPower(txp, PA_OUTPUT_PA_BOOST_PIN);
if (model == MODEL_A3) radio->setTxPower(txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_A4) radio->setTxPower(txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_A5) radio->setTxPower(txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_A6) radio->setTxPower(txp, PA_OUTPUT_PA_BOOST_PIN);
if (model == MODEL_A7) radio->setTxPower(txp, PA_OUTPUT_PA_BOOST_PIN);
if (model == MODEL_A8) radio->setTxPower(txp, PA_OUTPUT_PA_BOOST_PIN);
@ -1340,8 +1344,8 @@ bool eeprom_model_valid() {
if (model == MODEL_A3 || model == MODEL_A8) {
#elif BOARD_MODEL == BOARD_RNODE_NG_21
if (model == MODEL_A2 || model == MODEL_A7) {
#elif BOARD_MODEL == BOARD_RNODE_NG_22
if (model == MODEL_A1 || model == MODEL_A6) {
#elif BOARD_MODEL == BOARD_T3S3
if (model == MODEL_A1 || model == MODEL_A5 || model == MODEL_A6) {
#elif BOARD_MODEL == BOARD_HMBRW
if (model == MODEL_FF || model == MODEL_FE) {
#elif BOARD_MODEL == BOARD_TBEAM