mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 06:32:06 +00:00
Make it possible to define TCXO and XTAL radio modules within one variant (#4492)
* Update main.cpp Add in TCXO_OPTIONAL variable for tcxoVoltage and a double-check for working in both modes. * Update SX126xInterface.cpp Make a change to the tcxoVoltage setting so that TCXO_OPTIONAL works if defined. * Update variant.h Added define for TCXO_OPTIONAL and the tcxoVoltage variable. Added detail on the compatible boards. --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
929b3e4f88
commit
ee9e46ec92
40
src/main.cpp
40
src/main.cpp
@ -112,6 +112,10 @@ AccelerometerThread *accelerometerThread = nullptr;
|
||||
AudioThread *audioThread = nullptr;
|
||||
#endif
|
||||
|
||||
#if defined(TCXO_OPTIONAL)
|
||||
float tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE; // if TCXO is optional, put this here so it can be changed further down.
|
||||
#endif
|
||||
|
||||
using namespace concurrency;
|
||||
|
||||
// We always create a screen object, but we only init it if we find the hardware
|
||||
@ -890,7 +894,7 @@ void setup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO)
|
||||
#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && !defined(TCXO_OPTIONAL)
|
||||
if (!rIf) {
|
||||
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
|
||||
if (!rIf->init()) {
|
||||
@ -904,6 +908,40 @@ void setup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && defined(TCXO_OPTIONAL)
|
||||
if (!rIf) {
|
||||
// Try using the specified TCXO voltage
|
||||
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
|
||||
if (!rIf->init()) {
|
||||
LOG_WARN("Failed to find SX1262 radio with TCXO using DIO3 reference voltage at %f V\n", tcxoVoltage);
|
||||
delete rIf;
|
||||
rIf = NULL;
|
||||
tcxoVoltage = 0; // if it fails, set the TCXO voltage to zero for the next attempt
|
||||
} else {
|
||||
LOG_INFO("SX1262 Radio init succeeded, using ");
|
||||
LOG_WARN("SX1262 Radio with TCXO");
|
||||
LOG_INFO(", reference voltage at %f V\n", tcxoVoltage);
|
||||
radioType = SX1262_RADIO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rIf) {
|
||||
// If specified TCXO voltage fails, attempt to use DIO3 as a reference instea
|
||||
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
|
||||
if (!rIf->init()) {
|
||||
LOG_WARN("Failed to find SX1262 radio with XTAL using DIO3 reference voltage at %f V\n", tcxoVoltage);
|
||||
delete rIf;
|
||||
rIf = NULL;
|
||||
tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE; // if it fails, set the TCXO voltage back for the next radio search
|
||||
} else {
|
||||
LOG_INFO("SX1262 Radio init succeeded, using ");
|
||||
LOG_WARN("SX1262 Radio with XTAL");
|
||||
LOG_INFO(", reference voltage at %f V\n", tcxoVoltage);
|
||||
radioType = SX1262_RADIO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_SX1268)
|
||||
if (!rIf) {
|
||||
rIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
|
||||
|
@ -40,7 +40,7 @@ template <typename T> bool SX126xInterface<T>::init()
|
||||
0; // "TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip." per
|
||||
// https://github.com/jgromes/RadioLib/blob/690a050ebb46e6097c5d00c371e961c1caa3b52e/src/modules/SX126x/SX126x.h#L471C26-L471C104
|
||||
// (DIO3 is free to be used as an IRQ)
|
||||
#else
|
||||
#elif !defined(TCXO_OPTIONAL)
|
||||
float tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
|
||||
// (DIO3 is not free to be used as an IRQ)
|
||||
#endif
|
||||
|
@ -128,22 +128,29 @@ NRF52 PRO MICRO PIN ASSIGNMENT
|
||||
#define SX126X_RXEN (0 + 17) // P0.17
|
||||
#define SX126X_TXEN RADIOLIB_NC // Assuming that DIO2 is connected to TXEN pin. If not, TXEN must be connected.
|
||||
|
||||
// #define SX126X_MAX_POWER 8 set this if using a high-power board!
|
||||
|
||||
/*
|
||||
On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, then this should not be used.
|
||||
On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, use TCXO_OPTIONAL to try both settings.
|
||||
|
||||
Ebyte
|
||||
e22-900mm22s has no TCXO
|
||||
e22-900m22s has TCXO
|
||||
e220-900mm22s has no TCXO, works with/without this definition, looks like DIO3 not connected at all
|
||||
|
||||
AI-thinker
|
||||
RA-01SH does not have TCXO
|
||||
|
||||
Waveshare
|
||||
Core1262 has TCXO
|
||||
| Mfr | Module | TCXO | RF Switch | Notes |
|
||||
| ---------- | ---------------- | ---- | --------- | -------------------------------------------- |
|
||||
| Ebyte | E22-900M22S | Yes | Ext | |
|
||||
| Ebyte | E22-900MM22S | No | Ext | |
|
||||
| Ebyte | E22-900M30S | Yes | Ext | |
|
||||
| Ebyte | E22-900M33S | Yes | Ext | MAX_POWER must be set to 8 for this |
|
||||
| Ebyte | E220-900M22S | No | Ext | LLCC68, looks like DIO3 not connected at all |
|
||||
| AI-Thinker | RA-01SH | No | Int | |
|
||||
| Heltec | HT-RA62 | Yes | Int | |
|
||||
| NiceRF | Lora1262 | yes | Int | |
|
||||
| Waveshare | Core1262-HF | yes | Ext | |
|
||||
| Waveshare | LoRa Node Module | yes | Int | |
|
||||
|
||||
*/
|
||||
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
#define TCXO_OPTIONAL // make it so that the firmware can try both TCXO and XTAL
|
||||
extern float tcxoVoltage; // make this available everywhere
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user