diff --git a/docs/software/TODO.md b/docs/software/TODO.md index e01d525b4..07bfad429 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -1,19 +1,17 @@ # High priority -- why is the net so chatty now? - modem sleep should work if we lower serial rate to 115kb? - device wakes, turns BLE on and phone doesn't notice (while phone was sitting in auto-connect) -- E22 bringup - encryption review findings writeup - turn on modem-sleep mode - https://github.com/espressif/arduino-esp32/issues/1142#issuecomment-512428852 -last EDF release in arduino is: https://github.com/espressif/arduino-esp32/commit/1977370e6fc069e93ffd8818798fbfda27ae7d99 -IDF release/v3.3 46b12a560 -IDF release/v3.3 367c3c09c -https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html -kevinh@kevin-server:~/development/meshtastic/esp32-arduino-lib-builder$ python /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/build/bootloader/bootloader.bin -cp -a out/tools/sdk/* components/arduino/tools/sdk -cp -ar components/arduino/* ~/.platformio/packages/framework-arduinoespressif32@src-fba9d33740f719f712e9f8b07da6ea13/ + last EDF release in arduino is: https://github.com/espressif/arduino-esp32/commit/1977370e6fc069e93ffd8818798fbfda27ae7d99 + IDF release/v3.3 46b12a560 + IDF release/v3.3 367c3c09c + https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html + kevinh@kevin-server:~/development/meshtastic/esp32-arduino-lib-builder\$ python /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 /home/kevinh/development/meshtastic/esp32-arduino-lib-builder/build/bootloader/bootloader.bin + cp -a out/tools/sdk/_ components/arduino/tools/sdk + cp -ar components/arduino/_ ~/.platformio/packages/framework-arduinoespressif32@src-fba9d33740f719f712e9f8b07da6ea13/ # Medium priority diff --git a/docs/software/nrf52-TODO.md b/docs/software/nrf52-TODO.md index 55b781d23..1836f64bc 100644 --- a/docs/software/nrf52-TODO.md +++ b/docs/software/nrf52-TODO.md @@ -2,11 +2,19 @@ ## Misc work items +platform.json + + "framework-arduinoadafruitnrf52": { + "type": "framework", + "optional": true, + "version": "https://github.com/meshtastic/Adafruit_nRF52_Arduino.git" + }, + ## Initial work items Minimum items needed to make sure hardware is good. -- set power UICR per https://devzone.nordicsemi.com/f/nordic-q-a/28562/nrf52840-regulator-configuration +- DONE set power UICR per https://devzone.nordicsemi.com/f/nordic-q-a/28562/nrf52840-regulator-configuration - switch charge controller into / out of performance mode (see 8.3.1 in datasheet) - write UC1701 wrapper - Test hardfault handler for null ptrs (if one isn't already installed) diff --git a/platformio.ini b/platformio.ini index 791bfed20..f0f63bc31 100644 --- a/platformio.ini +++ b/platformio.ini @@ -156,8 +156,6 @@ debug_init_break = [env:nrf52dk] extends = nrf52_base board = nrf52840_dk_modified -lib_deps = - UC1701 ; for temp testing ; The PPR board [env:ppr] @@ -166,7 +164,7 @@ board = ppr lib_deps = ${env.lib_deps} UC1701 - https://github.com/meshtastic/BQ25703A.git + diff --git a/src/main.cpp b/src/main.cpp index ded027f51..e6820e841 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -152,7 +152,10 @@ void setup() #else Wire.begin(); #endif + // i2c still busted on new board +#ifndef ARDUINO_NRF52840_PPR scanI2Cdevice(); +#endif // Buttons & LED #ifdef BUTTON_PIN @@ -234,7 +237,7 @@ void setup() new SimRadio(); #endif - if (!rIf->init()) + if (!rIf || !rIf->init()) recordCriticalError(ErrNoRadio); else router.addInterface(rIf); diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h index 6619337ba..5f70d027d 100644 --- a/src/mesh/RadioLibInterface.h +++ b/src/mesh/RadioLibInterface.h @@ -91,9 +91,6 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask virtual void startReceive() = 0; private: - /** start an immediate transmit */ - void startSend(MeshPacket *txp); - /** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing * the transmit * @@ -113,7 +110,12 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask /// Make sure the Driver is properly configured before calling init(). /// \return true if initialisation succeeded. virtual bool init(); - + + /** start an immediate transmit + * This method is virtual so subclasses can hook as needed, subclasses should not call directly + */ + virtual void startSend(MeshPacket *txp); + /** * Convert our modemConfig enum into wf, sf, etc... * diff --git a/src/mesh/SX1262Interface.cpp b/src/mesh/SX1262Interface.cpp index 69e7f8ee7..628ec995f 100644 --- a/src/mesh/SX1262Interface.cpp +++ b/src/mesh/SX1262Interface.cpp @@ -14,7 +14,19 @@ bool SX1262Interface::init() { RadioLibInterface::init(); - float tcxoVoltage = 0; // None - we use an XTAL +#ifdef SX1262_RXEN // set not rx or tx mode + pinMode(SX1262_RXEN, OUTPUT); + pinMode(SX1262_TXEN, OUTPUT); + digitalWrite(SX1262_RXEN, LOW); + digitalWrite(SX1262_TXEN, LOW); +#endif + +#ifndef SX1262_E22 + float tcxoVoltage = 0; // None - we use an XTAL +#else + float tcxoVoltage = + 2.4; // E22 uses DIO3 to power tcxo per https://github.com/jgromes/RadioLib/issues/12#issuecomment-520695575 +#endif bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC? applyModemConfig(); @@ -23,6 +35,12 @@ bool SX1262Interface::init() int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO); DEBUG_MSG("LORA init result %d\n", res); +#ifdef SX1262_RXEN + // lora.begin assumes Dio2 is RF switch control, which is not true if we are manually controlling RX and TX + if (res == ERR_NONE) + res = lora.setDio2AsRfSwitch(false); +#endif + if (res == ERR_NONE) res = lora.setCRC(SX126X_LORA_CRC_ON); @@ -81,6 +99,11 @@ void SX1262Interface::setStandby() int err = lora.standby(); assert(err == ERR_NONE); +#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn off RX and TX power + digitalWrite(SX1262_RXEN, LOW); + digitalWrite(SX1262_TXEN, LOW); +#endif + isReceiving = false; // If we were receiving, not any more disableInterrupt(); completeSending(); // If we were sending, not anymore @@ -94,6 +117,19 @@ void SX1262Interface::addReceiveMetadata(MeshPacket *mp) mp->rx_snr = lora.getSNR(); } +/** start an immediate transmit + * We override to turn on transmitter power as needed. + */ +void SX1262Interface::startSend(MeshPacket *txp) +{ +#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn on TX power / off RX power + digitalWrite(SX1262_RXEN, LOW); + digitalWrite(SX1262_TXEN, HIGH); +#endif + + RadioLibInterface::startSend(txp); +} + // For power draw measurements, helpful to force radio to stay sleeping // #define SLEEP_ONLY @@ -102,6 +138,12 @@ void SX1262Interface::startReceive() #ifdef SLEEP_ONLY sleep(); #else + +#ifdef SX1262_RXEN // we have RXEN/TXEN control - turn on RX power / off TX power + digitalWrite(SX1262_RXEN, HIGH); + digitalWrite(SX1262_TXEN, LOW); +#endif + setStandby(); // int err = lora.startReceive(); int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in diff --git a/src/mesh/SX1262Interface.h b/src/mesh/SX1262Interface.h index 92b301bfc..1eee86a66 100644 --- a/src/mesh/SX1262Interface.h +++ b/src/mesh/SX1262Interface.h @@ -43,6 +43,12 @@ class SX1262Interface : public RadioLibInterface * Start waiting to receive a message */ virtual void startReceive(); + + /** start an immediate transmit + * We override to turn on transmitter power as needed. + */ + virtual void startSend(MeshPacket *txp); + /** * Add SNR data to received messages */ diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index ce3fe7e31..93798462a 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -59,12 +59,6 @@ void setBluetoothEnable(bool on) } } -#ifdef ARDUINO_NRF52840_PPR -#include "PmuBQ25703A.h" - -PmuBQ25703A pmu; -#endif - void nrf52Setup() { diff --git a/src/sleep.cpp b/src/sleep.cpp index 2dfee04fb..2d3ad4d31 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -129,7 +129,7 @@ static void waitEnterSleep() if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep recordCriticalError(ErrSleepEnterWait); - ESP.restart(); // FIXME - for now we just restart, need to fix bug #167 + assert(0); // FIXME - for now we just restart, need to fix bug #167 break; } } @@ -289,8 +289,6 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r return cause; } -#endif - // not legal on the stock android ESP build @@ -310,4 +308,4 @@ void enableModemSleep() config.light_sleep_enable = false; DEBUG_MSG("Sleep request result %x\n", esp_pm_configure(&config)); } - +#endif diff --git a/variants/ppr/variant.h b/variants/ppr/variant.h index 95b2803bd..bbdda3065 100644 --- a/variants/ppr/variant.h +++ b/variants/ppr/variant.h @@ -137,6 +137,7 @@ static const uint8_t SCK = PIN_SPI_SCK; // #define SX1262_ANT_SW (32 + 10) #define SX1262_RXEN (22) #define SX1262_TXEN (24) +#define SX1262_E22 // Indicates this SX1262 is inside of an ebyte E22 module and special config should be done for that // ERC12864-10 LCD #define ERC12864_CS (32 + 4)