Added support for LoRa32 v2.1 boards

This commit is contained in:
Mark Qvist 2022-01-22 21:43:52 +01:00
parent 01babb84f1
commit 044cb33948
5 changed files with 83 additions and 23 deletions

View File

@ -4,7 +4,7 @@
#define CONFIG_H
#define MAJ_VERS 0x01
#define MIN_VERS 0x18
#define MIN_VERS 0x19
#define PLATFORM_AVR 0x90
#define PLATFORM_ESP32 0x80
@ -109,8 +109,13 @@
const int pin_cs = 18;
const int pin_reset = 23;
const int pin_dio = 26;
const int pin_led_rx = 2;
#if defined(EXTERNAL_LEDS)
const int pin_led_rx = 15;
const int pin_led_tx = 4;
#else
const int pin_led_rx = 25;
const int pin_led_tx = 25;
#endif
#else
#error An unsupported board was selected. Cannot compile RNode firmware.
#endif

View File

@ -24,6 +24,9 @@ firmware-lora32_v20:
firmware-lora32_v21:
arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\""
firmware-lora32_v21_extled:
arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DEXTERNAL_LEDS=true\""
firmware-featheresp32:
arduino-cli compile --fqbn esp32:esp32:featheresp32 --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x34\""
@ -53,6 +56,8 @@ upload-featheresp32:
upload-mega2560:
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:mega
release-all: release-rnode release-tbeam release-lora32_v21 release-featheresp32 release-genericesp32
release-rnode:

View File

@ -250,6 +250,7 @@ bool startRadio() {
// Flash an info pattern to indicate
// that the radio is now on
kiss_indicate_radiostate();
led_indicate_info(3);
return true;
}
@ -258,12 +259,15 @@ bool startRadio() {
// Flash a warning pattern to indicate
// that the radio was locked, and thus
// not started
radio_online = false;
kiss_indicate_radiostate();
led_indicate_warning(3);
return false;
}
} else {
// If radio is already on, we silently
// ignore the request.
kiss_indicate_radiostate();
return true;
}
}

6
ROM.h
View File

@ -6,8 +6,14 @@
#define PRODUCT_RNODE 0x03
#define PRODUCT_HMBRW 0xF0
#define PRODUCT_TBEAM 0xE0
#define PRODUCT_T32_20 0xB0
#define PRODUCT_T32_21 0xB1
#define MODEL_A4 0xA4
#define MODEL_A9 0xA9
#define MODEL_B3 0xB3
#define MODEL_B8 0xB8
#define MODEL_B4 0xB4
#define MODEL_B9 0xB9
#define MODEL_E4 0xE4
#define MODEL_E9 0xE9
#define MODEL_FF 0xFF

View File

@ -49,8 +49,8 @@ uint8_t boot_vector = 0x00;
#elif BOARD_MODEL == BOARD_LORA32_V2_1
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, LOW); }
void led_tx_off() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
#elif BOARD_MODEL == BOARD_HUZZAH32
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
@ -130,6 +130,20 @@ void led_indicate_warning(int cycles) {
led_rx_off();
}
#elif MCU_VARIANT == MCU_ESP32
#if BOARD_MODEL == BOARD_LORA32_V2_1
void led_indicate_info(int cycles) {
bool forever = (cycles == 0) ? true : false;
cycles = forever ? 1 : cycles;
while(cycles > 0) {
led_rx_off();
delay(100);
led_rx_on();
delay(100);
if (!forever) cycles--;
}
led_rx_off();
}
#else
void led_indicate_info(int cycles) {
bool forever = (cycles == 0) ? true : false;
cycles = forever ? 1 : cycles;
@ -143,6 +157,7 @@ void led_indicate_warning(int cycles) {
led_tx_off();
}
#endif
#endif
unsigned long led_standby_ticks = 0;
@ -195,7 +210,13 @@ int8_t led_standby_direction = 0;
} else {
led_tx_off();
}
#if BOARD_MODEL == BOARD_LORA32_V2_1
#if defined(EXTERNAL_LEDS)
led_rx_off();
#endif
#else
led_rx_off();
#endif
}
}
@ -564,7 +585,14 @@ bool eeprom_lock_set() {
bool eeprom_product_valid() {
uint8_t rval = EEPROM.read(eeprom_addr(ADDR_PRODUCT));
if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM) {
#if PLATFORM == PLATFORM_AVR
if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW) {
#elif PLATFORM == PLATFORM_ESP32
if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21) {
#else
if (false) {
#endif
return true;
} else {
return false;
@ -573,7 +601,19 @@ bool eeprom_product_valid() {
bool eeprom_model_valid() {
model = EEPROM.read(eeprom_addr(ADDR_MODEL));
if (model == MODEL_A4 || model == MODEL_A9 || model == MODEL_FF || model == MODEL_E4 || model == MODEL_E9) {
#if BOARD_MODEL == BOARD_RNODE
if (model == MODEL_A4 || model == MODEL_A9) {
#elif BOARD_MODEL == BOARD_HMBRW
if (model == MODEL_FF) {
#elif BOARD_MODEL == BOARD_TBEAM
if (model == MODEL_E4 || model == MODEL_E9) {
#elif BOARD_MODEL == BOARD_LORA32_V2_0
if (model == MODEL_B3 || model == MODEL_B8) {
#elif BOARD_MODEL == BOARD_LORA32_V2_1
if (model == MODEL_B4 || model == MODEL_B9) {
#else
if (false) {
#endif
return true;
} else {
return false;