mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-01 11:25:44 +00:00
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)
This commit is contained in:
parent
82169d4115
commit
477c62082d
@ -91,9 +91,6 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask
|
|||||||
virtual void startReceive() = 0;
|
virtual void startReceive() = 0;
|
||||||
|
|
||||||
private:
|
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
|
/** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing
|
||||||
* the transmit
|
* the transmit
|
||||||
*
|
*
|
||||||
@ -114,6 +111,11 @@ class RadioLibInterface : public RadioInterface, private PeriodicTask
|
|||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
virtual bool init();
|
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...
|
* Convert our modemConfig enum into wf, sf, etc...
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,19 @@ bool SX1262Interface::init()
|
|||||||
{
|
{
|
||||||
RadioLibInterface::init();
|
RadioLibInterface::init();
|
||||||
|
|
||||||
|
#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
|
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?
|
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
|
||||||
|
|
||||||
applyModemConfig();
|
applyModemConfig();
|
||||||
@ -23,6 +35,12 @@ bool SX1262Interface::init()
|
|||||||
int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO);
|
int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO);
|
||||||
DEBUG_MSG("LORA init result %d\n", res);
|
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)
|
if (res == ERR_NONE)
|
||||||
res = lora.setCRC(SX126X_LORA_CRC_ON);
|
res = lora.setCRC(SX126X_LORA_CRC_ON);
|
||||||
|
|
||||||
@ -81,6 +99,11 @@ void SX1262Interface::setStandby()
|
|||||||
int err = lora.standby();
|
int err = lora.standby();
|
||||||
assert(err == ERR_NONE);
|
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
|
isReceiving = false; // If we were receiving, not any more
|
||||||
disableInterrupt();
|
disableInterrupt();
|
||||||
completeSending(); // If we were sending, not anymore
|
completeSending(); // If we were sending, not anymore
|
||||||
@ -94,6 +117,19 @@ void SX1262Interface::addReceiveMetadata(MeshPacket *mp)
|
|||||||
mp->rx_snr = lora.getSNR();
|
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
|
// For power draw measurements, helpful to force radio to stay sleeping
|
||||||
// #define SLEEP_ONLY
|
// #define SLEEP_ONLY
|
||||||
|
|
||||||
@ -102,6 +138,12 @@ void SX1262Interface::startReceive()
|
|||||||
#ifdef SLEEP_ONLY
|
#ifdef SLEEP_ONLY
|
||||||
sleep();
|
sleep();
|
||||||
#else
|
#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();
|
setStandby();
|
||||||
// int err = lora.startReceive();
|
// 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
|
int err = lora.startReceiveDutyCycleAuto(); // We use a 32 bit preamble so this should save some power by letting radio sit in
|
||||||
|
@ -43,6 +43,12 @@ class SX1262Interface : public RadioLibInterface
|
|||||||
* Start waiting to receive a message
|
* Start waiting to receive a message
|
||||||
*/
|
*/
|
||||||
virtual void startReceive();
|
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
|
* Add SNR data to received messages
|
||||||
*/
|
*/
|
||||||
|
@ -137,6 +137,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
// #define SX1262_ANT_SW (32 + 10)
|
// #define SX1262_ANT_SW (32 + 10)
|
||||||
#define SX1262_RXEN (22)
|
#define SX1262_RXEN (22)
|
||||||
#define SX1262_TXEN (24)
|
#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
|
// ERC12864-10 LCD
|
||||||
#define ERC12864_CS (32 + 4)
|
#define ERC12864_CS (32 + 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user