E22 SX1262 module now works!

Thanks mostly to an old github comment by @beegee-tokyo the fix was easy
(comment here https://github.com/jgromes/RadioLib/issues/12#issuecomment-520450429)

We now set DIO3 to 2.4 volts to power the oscillator inside the E22
module (undocumented in the E22 docs)
1.2-legacy
geeksville 2020-06-15 14:38:09 -07:00
rodzic 82169d4115
commit 477c62082d
4 zmienionych plików z 56 dodań i 5 usunięć

Wyświetl plik

@ -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...
*

Wyświetl plik

@ -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

Wyświetl plik

@ -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
*/

Wyświetl plik

@ -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)