Compare commits
10 Commits
fe50c2cac9
...
a3f952b47c
Author | SHA1 | Date | |
---|---|---|---|
|
a3f952b47c | ||
|
40b8b8a8b3 | ||
|
f137e5cf35 | ||
|
09b0c2a488 | ||
|
c046918329 | ||
|
10c58e16b0 | ||
|
a388669eaf | ||
|
39718693e6 | ||
|
c31cba0fd8 | ||
|
cec979997e |
@ -217,7 +217,6 @@ bool bt_setup_hw() {
|
||||
Bluefruit.Security.setPairPasskeyCallback(bt_passkey_callback);
|
||||
Bluefruit.Periph.setConnectCallback(bt_connect_callback);
|
||||
Bluefruit.Periph.setDisconnectCallback(bt_disconnect_callback);
|
||||
Bluefruit.Security.setIOCaps(true, true, false);
|
||||
Bluefruit.Security.setPairCompleteCallback(bt_pairing_complete);
|
||||
const ble_gap_addr_t gap_addr = Bluefruit.getAddr();
|
||||
char *data = (char*)malloc(BT_DEV_ADDR_LEN+1);
|
||||
@ -253,7 +252,6 @@ void bt_start() {
|
||||
|
||||
blebas.begin();
|
||||
|
||||
// non-connectable advertising
|
||||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
||||
Bluefruit.Advertising.addTxPower();
|
||||
|
||||
|
17
Boards.h
17
Boards.h
@ -52,6 +52,7 @@
|
||||
#define PLATFORM PLATFORM_ESP32
|
||||
#define MCU_VARIANT MCU_ESP32
|
||||
#elif defined(NRF52840_XXAA)
|
||||
#include <variant.h>
|
||||
#define PLATFORM PLATFORM_NRF52
|
||||
#define MCU_VARIANT MCU_NRF52
|
||||
#else
|
||||
@ -293,27 +294,33 @@
|
||||
#elif BOARD_MODEL == BOARD_RNODE_NG_22
|
||||
#define IS_ESP32S3 true
|
||||
#define MODEM SX1262
|
||||
#define DIO2_AS_RF_SWITCH true
|
||||
#define HAS_BUSY true
|
||||
#define HAS_TCXO true
|
||||
|
||||
#define HAS_DISPLAY true
|
||||
#define HAS_BLE true
|
||||
#define HAS_BLUETOOTH false // TODO: Implement
|
||||
#define HAS_CONSOLE false // TODO: Implement
|
||||
#define HAS_PMU true
|
||||
#define HAS_NP true
|
||||
#define HAS_NP false
|
||||
#define HAS_SD false
|
||||
#define HAS_EEPROM true
|
||||
#define HAS_RF_SWITCH_RX_TX true
|
||||
#define HAS_BUSY true
|
||||
|
||||
const int pin_cs = 7;
|
||||
const int pin_reset = 8;
|
||||
const int pin_sclk = 5;
|
||||
const int pin_mosi = 6;
|
||||
const int pin_miso = 3;
|
||||
const int pin_reset = 8;
|
||||
const int pin_rxen = 21;
|
||||
const int pin_tcxo_enable = -1;
|
||||
|
||||
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;
|
||||
|
||||
const int SD_MISO = 2;
|
||||
const int SD_MOSI = 11;
|
||||
const int SD_CLK = 14;
|
||||
|
@ -4,7 +4,7 @@ import sys
|
||||
import shutil
|
||||
|
||||
packages = {
|
||||
"rns": "rns-0.7.0-py3-none-any.whl",
|
||||
"rns": "rns-0.7.1-py3-none-any.whl",
|
||||
"nomadnet": "nomadnet-0.4.6-py3-none-any.whl",
|
||||
"lxmf": "lxmf-0.3.9-py3-none-any.whl",
|
||||
"rnsh": "rnsh-0.1.3-py3-none-any.whl",
|
||||
|
@ -9,12 +9,12 @@ Please take part in keeping the continued development, maintenance and distribut
|
||||
<br/><br/>
|
||||
- Ethereum<br/>
|
||||
```
|
||||
0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
|
||||
0xFDabC71AC4c0C78C95aDDDe3B4FA19d6273c5E73
|
||||
```
|
||||
<br/><br/>
|
||||
- Bitcoin<br/>
|
||||
```
|
||||
3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
|
||||
35G9uWVzrpJJibzUwpNUQGQNFzLirhrYAH
|
||||
```
|
||||
<br/><br/>
|
||||
- Ko-Fi<br/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
[title]: <> (Sell RNodes)
|
||||
## Build & Sell RNodes
|
||||
Creating any number of RNodes is completely free and unrestricted for all personal, non-commercial and humanitarian purposes. Feel free to use all the resources provided here, and on the [unsigned.io](https://unsigned.io/) website. If doing so provides value to you or your community, you are encouraged to [contribute]({ASSET_PATH}donate.html) whatever you find to be reasonable.
|
||||
Creating any number of RNodes is completely free and unrestricted for all personal, non-commercial and humanitarian purposes. Feel free to use all the resources provided here, and on the [unsigned.io](https://unsigned.io/) website. If doing so provides value to you or your community, you are encouraged to [contribute]({ASSET_PATH}contribute.html) whatever you find to be reasonable.
|
||||
|
||||
The RNode Ecosystem is free and non-proprietary, and actively seeks to distribute it's ownership and control. If you want to build RNodes for commercial purposes, including selling them, you must do so adhering to the Open Source licenses that the various parts of the RNode project is released under, and under your own responsibility.
|
||||
|
||||
|
45
Makefile
45
Makefile
@ -66,6 +66,9 @@ 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-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\""
|
||||
|
||||
@ -96,9 +99,6 @@ firmware-rnode_ng_20:
|
||||
firmware-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\""
|
||||
|
||||
firmware-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\""
|
||||
|
||||
firmware-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\""
|
||||
|
||||
@ -118,8 +118,8 @@ upload-tbeam:
|
||||
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:t-beam
|
||||
@sleep 1
|
||||
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.t-beam/RNode_Firmware.ino.bin)
|
||||
# @sleep 3
|
||||
# python ./Release/esptool/esptool.py --chip esp32 --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
|
||||
@sleep 3
|
||||
python ./Release/esptool/esptool.py --chip esp32 --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
|
||||
|
||||
upload-lora32_v10:
|
||||
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32
|
||||
@ -163,7 +163,7 @@ upload-rnode_ng_21:
|
||||
@sleep 3
|
||||
python ./Release/esptool/esptool.py --chip esp32 --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
|
||||
|
||||
upload-rnode_ng_22:
|
||||
upload-t3s3:
|
||||
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
|
||||
@sleep 1
|
||||
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
|
||||
@ -184,7 +184,7 @@ upload-rak4630:
|
||||
|
||||
release: release-all
|
||||
|
||||
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-all: console-site spiffs-image release-rnode release-tbeam release-tbeam_sx1262 release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled release-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v2_extled release-rnode_ng_20 release-rnode_ng_21 release-t3s3 release-hashes
|
||||
|
||||
release-hashes:
|
||||
python ./release_hashes.py > ./Release/release.json
|
||||
@ -203,6 +203,15 @@ release-tbeam:
|
||||
zip --junk-paths ./Release/rnode_firmware_tbeam.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_tbeam.boot_app0 build/rnode_firmware_tbeam.bin build/rnode_firmware_tbeam.bootloader build/rnode_firmware_tbeam.partitions
|
||||
rm -r build
|
||||
|
||||
release-tbeam_sx1262:
|
||||
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\""
|
||||
cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_tbeam_sx1262.boot_app0
|
||||
cp build/esp32.esp32.t-beam/RNode_Firmware.ino.bin build/rnode_firmware_tbeam_sx1262.bin
|
||||
cp build/esp32.esp32.t-beam/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_tbeam_sx1262.bootloader
|
||||
cp build/esp32.esp32.t-beam/RNode_Firmware.ino.partitions.bin build/rnode_firmware_tbeam_sx1262.partitions
|
||||
zip --junk-paths ./Release/rnode_firmware_tbeam_sx1262.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_tbeam_sx1262.boot_app0 build/rnode_firmware_tbeam_sx1262.bin build/rnode_firmware_tbeam_sx1262.bootloader build/rnode_firmware_tbeam_sx1262.partitions
|
||||
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\""
|
||||
cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v10.boot_app0
|
||||
@ -259,11 +268,11 @@ release-lora32_v21_extled:
|
||||
|
||||
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\""
|
||||
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
|
||||
cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.partitions.bin build/rnode_firmware_lora32v21.partitions
|
||||
zip --junk-paths ./Release/rnode_firmware_lora32v21_tcxo.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_lora32v21.boot_app0 build/rnode_firmware_lora32v21.bin build/rnode_firmware_lora32v21.bootloader build/rnode_firmware_lora32v21.partitions
|
||||
cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_lora32v21_tcxo.boot_app0
|
||||
cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin build/rnode_firmware_lora32v21_tcxo.bin
|
||||
cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_lora32v21_tcxo.bootloader
|
||||
cp build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.partitions.bin build/rnode_firmware_lora32v21_tcxo.partitions
|
||||
zip --junk-paths ./Release/rnode_firmware_lora32v21_tcxo.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_lora32v21_tcxo.boot_app0 build/rnode_firmware_lora32v21_tcxo.bin build/rnode_firmware_lora32v21_tcxo.bootloader build/rnode_firmware_lora32v21_tcxo.partitions
|
||||
rm -r build
|
||||
|
||||
release-heltec32_v2:
|
||||
@ -302,13 +311,13 @@ 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:
|
||||
release-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\""
|
||||
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
|
||||
cp ~/.arduino15/packages/esp32/hardware/esp32/2.0.*/tools/partitions/boot_app0.bin build/rnode_firmware_t3s3.boot_app0
|
||||
cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin build/rnode_firmware_t3s3.bin
|
||||
cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_t3s3.bootloader
|
||||
cp build/esp32.esp32.esp32s3/RNode_Firmware.ino.partitions.bin build/rnode_firmware_t3s3.partitions
|
||||
zip --junk-paths ./Release/rnode_firmware_t3s3.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_t3s3.boot_app0 build/rnode_firmware_t3s3.bin build/rnode_firmware_t3s3.bootloader build/rnode_firmware_t3s3.partitions
|
||||
rm -r build
|
||||
|
||||
release-featheresp32:
|
||||
|
@ -113,16 +113,16 @@ You can help support the continued development of open, free and private communi
|
||||
```
|
||||
- Ethereum
|
||||
```
|
||||
0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
|
||||
0xFDabC71AC4c0C78C95aDDDe3B4FA19d6273c5E73
|
||||
```
|
||||
- Bitcoin
|
||||
```
|
||||
3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
|
||||
35G9uWVzrpJJibzUwpNUQGQNFzLirhrYAH
|
||||
```
|
||||
- Ko-Fi: https://ko-fi.com/markqvist
|
||||
|
||||
## License & Use
|
||||
The RNode Firmware is Copyright © 2023 Mark Qvist / [unsigned.io](https://unsigned.io), and is made available under the **GNU General Public License v3.0**. The source code includes an SX1276 driver that is released under MIT License, and Copyright © 2018 Sandeep Mistry / Mark Qvist.
|
||||
The RNode Firmware is Copyright © 2024 Mark Qvist / [unsigned.io](https://unsigned.io), and is made available under the **GNU General Public License v3.0**. The source code includes an SX1276 driver that is released under MIT License, and Copyright © 2018 Sandeep Mistry / Mark Qvist.
|
||||
|
||||
You can obtain the source code from [git.unsigned.io](https://git.unsigned.io/markqvist/RNode_Firmware) or [GitHub](https://github.com/markqvist/rnode_firmware).
|
||||
|
||||
|
@ -138,7 +138,11 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_DISPLAY
|
||||
#if HAS_EEPROM
|
||||
if (EEPROM.read(eeprom_addr(ADDR_CONF_DSET)) != CONF_OK_BYTE) {
|
||||
#elif MCU_VARIANT == MCU_NRF52
|
||||
if (eeprom_read(eeprom_addr(ADDR_CONF_DSET)) != CONF_OK_BYTE) {
|
||||
#endif
|
||||
eeprom_update(eeprom_addr(ADDR_CONF_DSET), CONF_OK_BYTE);
|
||||
eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF);
|
||||
}
|
||||
@ -1106,6 +1110,7 @@ void validate_status() {
|
||||
}
|
||||
#else
|
||||
hw_ready = true;
|
||||
device_init_done = true;
|
||||
#endif
|
||||
} else {
|
||||
hw_ready = false;
|
||||
|
2
ROM.h
2
ROM.h
@ -43,6 +43,8 @@
|
||||
#define MODEL_C9 0xC9
|
||||
#define MODEL_E4 0xE4
|
||||
#define MODEL_E9 0xE9
|
||||
#define MODEL_E3 0xE3
|
||||
#define MODEL_E8 0xE8
|
||||
#define MODEL_FE 0xFE
|
||||
#define MODEL_FF 0xFF
|
||||
|
||||
|
Binary file not shown.
@ -146,6 +146,11 @@ 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
|
||||
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); }
|
||||
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
|
||||
#elif BOARD_MODEL == BOARD_TBEAM
|
||||
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
|
||||
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
|
||||
@ -1058,6 +1063,8 @@ void setTXPower() {
|
||||
|
||||
if (model == MODEL_E4) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
|
||||
if (model == MODEL_E9) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
|
||||
if (model == MODEL_E3) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
|
||||
if (model == MODEL_E8) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
|
||||
|
||||
if (model == MODEL_FE) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN);
|
||||
if (model == MODEL_FF) LoRa->setTxPower(lora_txp, PA_OUTPUT_RFO_PIN);
|
||||
@ -1295,7 +1302,7 @@ bool eeprom_model_valid() {
|
||||
#elif BOARD_MODEL == BOARD_HMBRW
|
||||
if (model == MODEL_FF || model == MODEL_FE) {
|
||||
#elif BOARD_MODEL == BOARD_TBEAM
|
||||
if (model == MODEL_E4 || model == MODEL_E9) {
|
||||
if (model == MODEL_E4 || model == MODEL_E9 || model == MODEL_E3 || model == MODEL_E8) {
|
||||
#elif BOARD_MODEL == BOARD_LORA32_V1_0
|
||||
if (model == MODEL_BA || model == MODEL_BB) {
|
||||
#elif BOARD_MODEL == BOARD_LORA32_V2_0
|
||||
|
107
sx126x.cpp
107
sx126x.cpp
@ -43,12 +43,20 @@
|
||||
#define OP_WRITE_REGISTER_6X 0x0D
|
||||
#define OP_DIO3_TCXO_CTRL_6X 0x97
|
||||
#define OP_DIO2_RF_CTRL_6X 0x9D
|
||||
#define OP_CAD_PARAMS 0x88
|
||||
#define OP_CALIBRATE_6X 0x89
|
||||
#define OP_RX_TX_FALLBACK_MODE_6X 0x93
|
||||
#define OP_REGULATOR_MODE_6X 0x96
|
||||
#define OP_CALIBRATE_IMAGE_6X 0x98
|
||||
|
||||
#define MASK_CALIBRATE_ALL 0x7f
|
||||
|
||||
#define IRQ_TX_DONE_MASK_6X 0x01
|
||||
#define IRQ_RX_DONE_MASK_6X 0x02
|
||||
#define IRQ_HEADER_DET_MASK_6X 0x10
|
||||
#define IRQ_PREAMBLE_DET_MASK_6X 0x04
|
||||
#define IRQ_PAYLOAD_CRC_ERROR_MASK_6X 0x40
|
||||
#define IRQ_ALL_MASK_6X 0b0100001111111111
|
||||
|
||||
#define MODE_LONG_RANGE_MODE_6X 0x01
|
||||
|
||||
@ -70,6 +78,12 @@
|
||||
#define MODE_TCXO_1_7V_6X 0x01
|
||||
#define MODE_TCXO_1_6V_6X 0x00
|
||||
|
||||
#define MODE_STDBY_RC_6X 0x00
|
||||
#define MODE_STDBY_XOSC_6X 0x01
|
||||
#define MODE_FALLBACK_STDBY_RC_6X 0x20
|
||||
#define MODE_IMPLICIT_HEADER 0x01
|
||||
#define MODE_EXPLICIT_HEADER 0x00
|
||||
|
||||
#define SYNC_WORD_6X 0x1424
|
||||
|
||||
#define XTAL_FREQ_6X (double)32000000
|
||||
@ -331,6 +345,46 @@ void sx126x::reset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void sx126x::calibrate(void) {
|
||||
// Put in STDBY_RC mode before calibration
|
||||
uint8_t mode_byte = MODE_STDBY_RC_6X;
|
||||
executeOpcode(OP_STANDBY_6X, &mode_byte, 1);
|
||||
|
||||
// calibrate RC64k, RC13M, PLL, ADC and image
|
||||
uint8_t calibrate = MASK_CALIBRATE_ALL;
|
||||
executeOpcode(OP_CALIBRATE_6X, &calibrate, 1);
|
||||
|
||||
delay(5);
|
||||
waitOnBusy();
|
||||
}
|
||||
|
||||
void sx126x::calibrate_image(long frequency) {
|
||||
uint8_t image_freq[2] = {0};
|
||||
|
||||
if (frequency >= 430E6 && frequency <= 440E6) {
|
||||
image_freq[0] = 0x6B;
|
||||
image_freq[1] = 0x6F;
|
||||
}
|
||||
else if (frequency >= 470E6 && frequency <= 510E6) {
|
||||
image_freq[0] = 0x75;
|
||||
image_freq[1] = 0x81;
|
||||
}
|
||||
else if (frequency >= 779E6 && frequency <= 787E6) {
|
||||
image_freq[0] = 0xC1;
|
||||
image_freq[1] = 0xC5;
|
||||
}
|
||||
else if (frequency >= 863E6 && frequency <= 870E6) {
|
||||
image_freq[0] = 0xD7;
|
||||
image_freq[1] = 0xDB;
|
||||
}
|
||||
else if (frequency >= 902E6 && frequency <= 928E6) {
|
||||
image_freq[0] = 0xE1;
|
||||
image_freq[1] = 0xE9;
|
||||
}
|
||||
|
||||
executeOpcode(OP_CALIBRATE_IMAGE_6X, image_freq, 2);
|
||||
waitOnBusy();
|
||||
}
|
||||
|
||||
int sx126x::begin(long frequency)
|
||||
{
|
||||
@ -350,20 +404,13 @@ int sx126x::begin(long frequency)
|
||||
pinMode(_rxen, OUTPUT);
|
||||
}
|
||||
|
||||
// Put in STDBY_RC mode before calibration
|
||||
uint8_t mode_byte = 0x00;
|
||||
executeOpcode(OP_STANDBY_6X, &mode_byte, 1);
|
||||
calibrate();
|
||||
calibrate_image(frequency);
|
||||
|
||||
// calibrate RC64k, RC13M, PLL, ADC and image
|
||||
uint8_t calibrate = 0x7F;
|
||||
executeOpcode(OP_CALIBRATE_6X, &calibrate, 1);
|
||||
|
||||
#if HAS_TCXO
|
||||
enableTCXO();
|
||||
#endif
|
||||
enableTCXO();
|
||||
|
||||
loraMode();
|
||||
idle();
|
||||
standby();
|
||||
|
||||
// Set sync word
|
||||
setSyncWord(SYNC_WORD_6X);
|
||||
@ -408,8 +455,7 @@ void sx126x::end()
|
||||
|
||||
int sx126x::beginPacket(int implicitHeader)
|
||||
{
|
||||
// put in standby mode
|
||||
idle();
|
||||
standby();
|
||||
|
||||
if (implicitHeader) {
|
||||
implicitHeaderMode();
|
||||
@ -654,12 +700,12 @@ void sx126x::receive(int size)
|
||||
executeOpcode(OP_RX_6X, mode, 3);
|
||||
}
|
||||
|
||||
void sx126x::idle()
|
||||
void sx126x::standby()
|
||||
{
|
||||
// STDBY_XOSC
|
||||
uint8_t byte = 0x01;
|
||||
uint8_t byte = MODE_STDBY_XOSC_6X;
|
||||
// STDBY_RC
|
||||
// uint8_t byte = 0x00;
|
||||
// uint8_t byte = MODE_STDBY_RC_6X;
|
||||
executeOpcode(OP_STANDBY_6X, &byte, 1);
|
||||
}
|
||||
|
||||
@ -670,19 +716,20 @@ void sx126x::sleep()
|
||||
}
|
||||
|
||||
void sx126x::enableTCXO() {
|
||||
// only tested for RAK4630, voltage may be different on other platforms
|
||||
#if HAS_TCXO
|
||||
#if BOARD_MODEL == BOARD_RAK4630
|
||||
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
|
||||
uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};
|
||||
#endif
|
||||
|
||||
executeOpcode(OP_DIO3_TCXO_CTRL_6X, buf, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sx126x::disableTCXO() {
|
||||
// currently cannot disable on SX1262?
|
||||
}
|
||||
// TODO: Once enabled, SX1262 needs a complete reset to disable TCXO
|
||||
void sx126x::disableTCXO() { }
|
||||
|
||||
void sx126x::setTxPower(int level, int outputPin) {
|
||||
// currently no low power mode for SX1262 implemented, assuming PA boost
|
||||
@ -693,26 +740,22 @@ void sx126x::setTxPower(int level, int outputPin) {
|
||||
|
||||
uint8_t pa_buf[4];
|
||||
|
||||
pa_buf[0] = 0x04;
|
||||
pa_buf[1] = 0x07;
|
||||
pa_buf[2] = 0x00;
|
||||
pa_buf[3] = 0x01;
|
||||
pa_buf[0] = 0x04; // PADutyCycle needs to be 0x04 to achieve 22dBm output, but can be lowered for better efficiency at lower outputs
|
||||
pa_buf[1] = 0x07; // HPMax at 0x07 is maximum supported for SX1262
|
||||
pa_buf[2] = 0x00; // DeviceSel 0x00 for SX1262 (0x01 for SX1261)
|
||||
pa_buf[3] = 0x01; // PALut always 0x01 (reserved according to datasheet)
|
||||
|
||||
executeOpcode(OP_PA_CONFIG_6X, pa_buf, 4); // set pa_config for high power
|
||||
|
||||
if (level > 22) {
|
||||
level = 22;
|
||||
}
|
||||
else if (level < -9) {
|
||||
level = -9;
|
||||
}
|
||||
if (level > 22) { level = 22; }
|
||||
else if (level < -9) { level = -9; }
|
||||
|
||||
writeRegister(REG_OCP_6X, 0x38); // 160mA limit, overcurrent protection
|
||||
|
||||
uint8_t tx_buf[2];
|
||||
|
||||
tx_buf[0] = level;
|
||||
tx_buf[1] = 0x02; // ramping time - 40 microseconds
|
||||
tx_buf[1] = 0x02; // PA ramping time - 40 microseconds
|
||||
|
||||
executeOpcode(OP_TX_PARAMS_6X, tx_buf, 2);
|
||||
|
||||
|
4
sx126x.h
4
sx126x.h
@ -55,7 +55,7 @@ public:
|
||||
void onReceive(void(*callback)(int));
|
||||
|
||||
void receive(int size = 0);
|
||||
void idle();
|
||||
void standby();
|
||||
void sleep();
|
||||
|
||||
bool preInit();
|
||||
@ -113,6 +113,8 @@ private:
|
||||
void optimizeModemSensitivity();
|
||||
|
||||
void reset(void);
|
||||
void calibrate(void);
|
||||
void calibrate_image(long frequency);
|
||||
|
||||
private:
|
||||
SPISettings _spiSettings;
|
||||
|
@ -90,7 +90,7 @@ void sx127x::setSPIFrequency(uint32_t frequency) { _spiSettings = SPISettings(fr
|
||||
void sx127x::setPins(int ss, int reset, int dio0, int busy) { _ss = ss; _reset = reset; _dio0 = dio0; _busy = busy; }
|
||||
uint8_t ISR_VECT sx127x::readRegister(uint8_t address) { return singleTransfer(address & 0x7f, 0x00); }
|
||||
void sx127x::writeRegister(uint8_t address, uint8_t value) { singleTransfer(address | 0x80, value); }
|
||||
void sx127x::idle() { writeRegister(REG_OP_MODE_7X, MODE_LONG_RANGE_MODE_7X | MODE_STDBY_7X); }
|
||||
void sx127x::standby() { writeRegister(REG_OP_MODE_7X, MODE_LONG_RANGE_MODE_7X | MODE_STDBY_7X); }
|
||||
void sx127x::sleep() { writeRegister(REG_OP_MODE_7X, MODE_LONG_RANGE_MODE_7X | MODE_SLEEP_7X); }
|
||||
uint8_t sx127x::modemStatus() { return readRegister(REG_MODEM_STAT_7X); }
|
||||
void sx127x::setSyncWord(uint8_t sw) { writeRegister(REG_SYNC_WORD_7X, sw); }
|
||||
@ -168,7 +168,7 @@ int sx127x::begin(long frequency) {
|
||||
enableCrc();
|
||||
setTxPower(2);
|
||||
|
||||
idle();
|
||||
standby();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -180,7 +180,7 @@ void sx127x::end() {
|
||||
}
|
||||
|
||||
int sx127x::beginPacket(int implicitHeader) {
|
||||
idle();
|
||||
standby();
|
||||
|
||||
if (implicitHeader) {
|
||||
implicitHeaderMode();
|
||||
|
2
sx127x.h
2
sx127x.h
@ -53,7 +53,7 @@ public:
|
||||
void onReceive(void(*callback)(int));
|
||||
|
||||
void receive(int size = 0);
|
||||
void idle();
|
||||
void standby();
|
||||
void sleep();
|
||||
|
||||
bool preInit();
|
||||
|
@ -467,13 +467,13 @@ uint8_t sx128x::modemStatus() {
|
||||
|
||||
uint8_t byte = 0x00;
|
||||
|
||||
if (buf[0] & IRQ_PREAMBLE_DET_MASK_8X != 0) {
|
||||
if ((buf[0] & IRQ_PREAMBLE_DET_MASK_8X) != 0) {
|
||||
byte = byte | 0x01 | 0x04;
|
||||
// clear register after reading
|
||||
clearbuf[0] = 0xFF;
|
||||
}
|
||||
|
||||
if (buf[1] & IRQ_HEADER_DET_MASK_8X != 0) {
|
||||
if ((buf[1] & IRQ_HEADER_DET_MASK_8X) != 0) {
|
||||
byte = byte | 0x02 | 0x04;
|
||||
// clear register after reading
|
||||
clearbuf[1] = 0xFF;
|
||||
|
Loading…
Reference in New Issue
Block a user