diff --git a/Boards.h b/Boards.h index 10544fb..ffce6e9 100644 --- a/Boards.h +++ b/Boards.h @@ -47,6 +47,10 @@ #define MODEM SX1262 #elif BOARD_MODEL == BOARD_RNODE_NG_22 #define MODEM SX1262 + const int pin_cs = 7; + const int pin_sclk = 5; + const int pin_mosi = 6; + const int pin_miso = 3; #elif BOARD_MODEL == BOARD_GENERIC_NRF52 #define MODEM SX1262 #else diff --git a/Config.h b/Config.h index 57255c9..ce7aaad 100644 --- a/Config.h +++ b/Config.h @@ -285,9 +285,13 @@ #define HAS_NP true #define HAS_SD false #define HAS_EEPROM true - const int pin_cs = 7; + #define HAS_RF_SWITCH_RX_TX true + #define HAS_BUSY true const int pin_reset = 8; + const int pin_rxen = 21; const int pin_dio = 33; + const int pin_busy = 34; + const int pin_np = 38; const int pin_dac = 25; const int pin_adc = 1; diff --git a/Makefile b/Makefile index 2d2fb5a..0b38bea 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ upload-rnode_ng_22: @sleep 1 rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin) @sleep 3 - python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before hard_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-featheresp32: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:featheresp32 @@ -184,18 +184,18 @@ upload-rak4630: release: release-all -release-all: console-site spiffs-image release-rnode release-mega2560 release-tbeam release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled firmware-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v2_extled release-rnode_ng_20 release-rnode_ng_21 release-hashes +release-all: console-site spiffs-image release-rnode release-tbeam release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled firmware-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v2_extled release-rnode_ng_20 release-rnode_ng_21 release-hashes release-hashes: python ./release_hashes.py > ./Release/release.json release-rnode: - arduino-cli compile --fqbn unsignedio:avr:rnode -e --build-property "compiler.cpp.extra_flags=\"-DMODEM=0x01\"" + arduino-cli compile --fqbn unsignedio:avr:rnode -e cp build/unsignedio.avr.rnode/RNode_Firmware.ino.hex Release/rnode_firmware.hex rm -r build release-tbeam: - 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=0x01\"" + 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\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_tbeam.boot_app0 cp build/esp32.esp32.t-beam/RNode_Firmware.ino.bin build/rnode_firmware_tbeam.bin cp build/esp32.esp32.t-beam/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_tbeam.bootloader @@ -204,7 +204,7 @@ release-tbeam: rm -r build release-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\" \"-DMODEM=0x01\"" + 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\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v10.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v10.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v10.bootloader @@ -213,7 +213,7 @@ release-lora32_v10: rm -r build release-lora32_v20: - 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=0x36\" \"-DMODEM=0x01\"" + 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=0x36\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v20.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v20.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v20.bootloader @@ -222,7 +222,7 @@ release-lora32_v20: rm -r build release-lora32_v21: - 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=0x37\" \"-DMODEM=0x01\"" + 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=0x37\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v21.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v21.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v21.bootloader @@ -231,7 +231,7 @@ release-lora32_v21: rm -r build release-lora32_v10_extled: - 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\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\"" + 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\" \"-DEXTERNAL_LEDS=true\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v10.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v10.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v10.bootloader @@ -240,7 +240,7 @@ release-lora32_v10_extled: rm -r build release-lora32_v20_extled: - 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=0x36\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\"" + 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=0x36\" \"-DEXTERNAL_LEDS=true\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v20.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v20.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v20.bootloader @@ -249,7 +249,7 @@ release-lora32_v20_extled: rm -r build release-lora32_v21_extled: - 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=0x37\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\"" + 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=0x37\" \"-DEXTERNAL_LEDS=true\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v21.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v21.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v21.bootloader @@ -258,7 +258,7 @@ release-lora32_v21_extled: rm -r build release-lora32_v21_tcxo: - 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=0x37\" \"-DENABLE_TCXO=true\" \"-DMODEM=0x01\"" + 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=0x37\" \"-DENABLE_TCXO=true\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v21.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v21.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v21.bootloader @@ -267,7 +267,7 @@ release-lora32_v21_tcxo: rm -r build release-heltec32_v2: - arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DMODEM=0x01\"" + arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_heltec32v2.boot_app0 cp build/esp32.esp32.heltec_wifi_lora_32_V2/RNode_Firmware.ino.bin build/rnode_firmware_heltec32v2.bin cp build/esp32.esp32.heltec_wifi_lora_32_V2/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_heltec32v2.bootloader @@ -276,7 +276,7 @@ release-heltec32_v2: rm -r build release-heltec32_v2_extled: - arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\"" + arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_heltec32v2.boot_app0 cp build/esp32.esp32.heltec_wifi_lora_32_V2/RNode_Firmware.ino.bin build/rnode_firmware_heltec32v2.bin cp build/esp32.esp32.heltec_wifi_lora_32_V2/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_heltec32v2.bootloader @@ -285,7 +285,7 @@ release-heltec32_v2_extled: rm -r build release-rnode_ng_20: - 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=0x40\" \"-DMODEM=0x01\"" + 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=0x40\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_ng20.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_ng20.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_ng20.bootloader @@ -294,7 +294,7 @@ release-rnode_ng_20: rm -r build release-rnode_ng_21: - 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=0x41\" \"-DMODEM=0x01\"" + 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=0x41\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_ng21.boot_app0 cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_ng21.bin cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_ng21.bootloader @@ -302,8 +302,17 @@ release-rnode_ng_21: zip --junk-paths ./Release/rnode_firmware_ng21.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_ng21.boot_app0 build/rnode_firmware_ng21.bin build/rnode_firmware_ng21.bootloader build/rnode_firmware_ng21.partitions rm -r build +release-rnode_ng_22: + 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\"" + cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_ng22.boot_app0 + cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin build/rnode_firmware_ng22.bin + cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_ng22.bootloader + cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.partitions.bin build/rnode_firmware_ng22.partitions + zip --junk-paths ./Release/rnode_firmware_ng22.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_ng22.boot_app0 build/rnode_firmware_ng22.bin build/rnode_firmware_ng22.bootloader build/rnode_firmware_ng22.partitions + rm -r build + release-featheresp32: - arduino-cli compile --fqbn esp32:esp32:featheresp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x34\" \"-DMODEM=0x01\"" + arduino-cli compile --fqbn esp32:esp32:featheresp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x34\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_featheresp32.boot_app0 cp build/esp32.esp32.featheresp32/RNode_Firmware.ino.bin build/rnode_firmware_featheresp32.bin cp build/esp32.esp32.featheresp32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_featheresp32.bootloader @@ -312,7 +321,7 @@ release-featheresp32: rm -r build release-genericesp32: - arduino-cli compile --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\" \"-DMODEM=0x01\"" + arduino-cli compile --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\"" cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_esp32_generic.boot_app0 cp build/esp32.esp32.esp32/RNode_Firmware.ino.bin build/rnode_firmware_esp32_generic.bin cp build/esp32.esp32.esp32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_esp32_generic.bootloader diff --git a/ROM.h b/ROM.h index 1f96168..78e8b08 100644 --- a/ROM.h +++ b/ROM.h @@ -25,6 +25,8 @@ #define PRODUCT_T32_20 0xB0 #define PRODUCT_T32_21 0xB1 #define PRODUCT_H32_V2 0xC0 + #define MODEL_A1 0xA1 + #define MODEL_A6 0xA6 #define MODEL_A4 0xA4 #define MODEL_A9 0xA9 #define MODEL_A3 0xA3 @@ -48,7 +50,7 @@ #define ADDR_MODEL 0x01 #define ADDR_HW_REV 0x02 #define ADDR_SERIAL 0x03 - #define ADDR_MADE 0x07 + #define ADDR_MADE 0x07 #define ADDR_CHKSUM 0x0B #define ADDR_SIGNATURE 0x1B #define ADDR_INFO_LOCK 0x9B diff --git a/Release/console_image.bin b/Release/console_image.bin index 271d7c1..b02795a 100644 Binary files a/Release/console_image.bin and b/Release/console_image.bin differ diff --git a/Utilities.h b/Utilities.h index b93e70e..df39762 100644 --- a/Utilities.h +++ b/Utilities.h @@ -1034,9 +1034,11 @@ int getTxPower() { void setTXPower() { if (radio_online) { + if (model == MODEL_A1) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_A2) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_A3) LoRa->setTxPower(lora_txp, PA_OUTPUT_RFO_PIN); if (model == MODEL_A4) LoRa->setTxPower(lora_txp, PA_OUTPUT_RFO_PIN); + if (model == MODEL_A6) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_A7) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_A8) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_A9) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); @@ -1252,6 +1254,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_HMBRW if (model == MODEL_FF || model == MODEL_FE) { #elif BOARD_MODEL == BOARD_TBEAM diff --git a/sx126x.cpp b/sx126x.cpp index 4324e69..6389a76 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -5,6 +5,7 @@ // Obviously still under the MIT license. #include "sx126x.h" +#include "Boards.h" #define MCU_1284P 0x91 #define MCU_2560 0x92 @@ -29,7 +30,9 @@ #endif #if MCU_VARIANT == MCU_ESP32 - #include "soc/rtc_wdt.h" + #if MCU_VARIANT == MCU_ESP32 and !defined(CONFIG_IDF_TARGET_ESP32S3) + #include "soc/rtc_wdt.h" + #endif #define ISR_VECT IRAM_ATTR #else #define ISR_VECT @@ -83,8 +86,11 @@ #define XTAL_FREQ_6X (double)32000000 #define FREQ_DIV_6X (double)pow(2.0, 25.0) #define FREQ_STEP_6X (double)(XTAL_FREQ_6X / FREQ_DIV_6X) -extern SPIClass spiModem; -#define SPI spiModem + +#if defined(NRF52840_XXAA) + extern SPIClass spiModem; + #define SPI spiModem +#endif extern SPIClass SPI; @@ -120,24 +126,34 @@ bool sx126x::preInit() { // set SS high digitalWrite(_ss, HIGH); - SPI.begin(); + Serial.println("SPI INIT"); + #if BOARD_MODEL == BOARD_RNODE_NG_22 + SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); + #else + SPI.begin(); + #endif + Serial.println("DONE"); // check version (retry for up to 2 seconds) long start = millis(); uint8_t syncmsb; uint8_t synclsb; + Serial.println("TRYING REGISTER READ"); while (((millis() - start) < 2000) && (millis() >= start)) { syncmsb = readRegister(REG_SYNC_WORD_MSB_6X); synclsb = readRegister(REG_SYNC_WORD_LSB_6X); if ( uint16_t(syncmsb << 8 | synclsb) == 0x1424 || uint16_t(syncmsb << 8 | synclsb) == 0x4434) { + Serial.println("CORRECT VALUE RETURNED"); break; } delay(100); } if ( uint16_t(syncmsb << 8 | synclsb) != 0x1424 && uint16_t(syncmsb << 8 | synclsb) != 0x4434) { + Serial.println("REG READ FAILED"); return false; } + Serial.println("MODEM PREINIT SUCCESS"); _preinit_done = true; return true; } diff --git a/sx127x.cpp b/sx127x.cpp index f0ae16e..403808d 100644 --- a/sx127x.cpp +++ b/sx127x.cpp @@ -5,6 +5,7 @@ // Obviously still under the MIT license. #include "sx127x.h" +#include "Boards.h" #define MCU_1284P 0x91 #define MCU_2560 0x92 @@ -29,7 +30,9 @@ #endif #if MCU_VARIANT == MCU_ESP32 - #include "soc/rtc_wdt.h" + #if MCU_VARIANT == MCU_ESP32 and !defined(CONFIG_IDF_TARGET_ESP32S3) + #include "soc/rtc_wdt.h" + #endif #define ISR_VECT IRAM_ATTR #else #define ISR_VECT diff --git a/sx128x.cpp b/sx128x.cpp index 17e0775..759b73a 100644 --- a/sx128x.cpp +++ b/sx128x.cpp @@ -5,6 +5,7 @@ // Obviously still under the MIT license. #include "sx128x.h" +#include "Boards.h" #define MCU_1284P 0x91 #define MCU_2560 0x92 @@ -29,7 +30,9 @@ #endif #if MCU_VARIANT == MCU_ESP32 - #include "soc/rtc_wdt.h" + #if MCU_VARIANT == MCU_ESP32 and !defined(CONFIG_IDF_TARGET_ESP32S3) + #include "soc/rtc_wdt.h" + #endif #define ISR_VECT IRAM_ATTR #else #define ISR_VECT @@ -77,8 +80,10 @@ #define FREQ_DIV_8X (double)pow(2.0, 18.0) #define FREQ_STEP_8X (double)(XTAL_FREQ_8X / FREQ_DIV_8X) -extern SPIClass spiModem; -#define SPI spiModem +#if defined(NRF52840_XXAA) + extern SPIClass spiModem; + #define SPI spiModem +#endif extern SPIClass SPI;