mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 12:20:43 +00:00
Merge pull request #2204 from meshtastic/rak-4631-fix
Potential fix for TX problem in RAK-4631 cores and other SX126X ant switch issues
This commit is contained in:
commit
d14bd652eb
@ -1,7 +1,7 @@
|
|||||||
#include "SX126xInterface.h"
|
#include "SX126xInterface.h"
|
||||||
#include "mesh/NodeDB.h"
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "mesh/NodeDB.h"
|
||||||
|
|
||||||
// Particular boards might define a different max power based on what their hardware can do
|
// Particular boards might define a different max power based on what their hardware can do
|
||||||
#ifndef SX126X_MAX_POWER
|
#ifndef SX126X_MAX_POWER
|
||||||
@ -26,15 +26,6 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // set not rx or tx mode
|
|
||||||
digitalWrite(SX126X_RXEN, LOW); // Set low before becoming an output
|
|
||||||
pinMode(SX126X_RXEN, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
|
||||||
digitalWrite(SX126X_TXEN, LOW);
|
|
||||||
pinMode(SX126X_TXEN, OUTPUT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SX126X_E22
|
#ifndef SX126X_E22
|
||||||
float tcxoVoltage = 0; // None - we use an XTAL
|
float tcxoVoltage = 0; // None - we use an XTAL
|
||||||
#else
|
#else
|
||||||
@ -67,11 +58,6 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
LOG_DEBUG("Current limit set to %f\n", currentLimit);
|
LOG_DEBUG("Current limit set to %f\n", currentLimit);
|
||||||
LOG_DEBUG("Current limit set result %d\n", res);
|
LOG_DEBUG("Current limit set result %d\n", res);
|
||||||
|
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
|
||||||
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
|
||||||
if (res == RADIOLIB_ERR_NONE)
|
|
||||||
res = lora.setDio2AsRfSwitch(false);
|
|
||||||
#endif
|
|
||||||
#ifdef SX126X_E22
|
#ifdef SX126X_E22
|
||||||
// E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines
|
// E22 Emulation explicitly requires DIO2 as RF switch, so set it to TRUE again for good measure. In case somebody defines
|
||||||
// SX126X_TX for an E22 Module
|
// SX126X_TX for an E22 Module
|
||||||
@ -79,13 +65,21 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
res = lora.setDio2AsRfSwitch(true);
|
res = lora.setDio2AsRfSwitch(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (config.lora.sx126x_rx_boosted_gain) {
|
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
||||||
uint16_t result = lora.setRxBoostedGainMode(true);
|
// lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX
|
||||||
LOG_INFO("Set Rx Boosted Gain mode; result: %d\n", result);
|
if (res == RADIOLIB_ERR_NONE) {
|
||||||
} else {
|
res = lora.setDio2AsRfSwitch(false);
|
||||||
uint16_t result = lora.setRxBoostedGainMode(false);
|
lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
||||||
LOG_INFO("Set Rx Power Saving Gain mode; result: %d\n", result);
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
|
if (config.lora.sx126x_rx_boosted_gain) {
|
||||||
|
uint16_t result = lora.setRxBoostedGainMode(true);
|
||||||
|
LOG_INFO("Set Rx Boosted Gain mode; result: %d\n", result);
|
||||||
|
} else {
|
||||||
|
uint16_t result = lora.setRxBoostedGainMode(false);
|
||||||
|
LOG_INFO("Set Rx Power Saving Gain mode; result: %d\n", result);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
// Read/write a register we are not using (only used for FSK mode) to test SPI comms
|
||||||
@ -185,13 +179,6 @@ template <typename T> void SX126xInterface<T>::setStandby()
|
|||||||
|
|
||||||
assert(err == RADIOLIB_ERR_NONE);
|
assert(err == RADIOLIB_ERR_NONE);
|
||||||
|
|
||||||
#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn off RX and TX power
|
|
||||||
digitalWrite(SX126X_RXEN, LOW);
|
|
||||||
#endif
|
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
|
||||||
digitalWrite(SX126X_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
|
||||||
@ -211,13 +198,6 @@ template <typename T> void SX126xInterface<T>::addReceiveMetadata(meshtastic_Mes
|
|||||||
*/
|
*/
|
||||||
template <typename T> void SX126xInterface<T>::configHardwareForSend()
|
template <typename T> void SX126xInterface<T>::configHardwareForSend()
|
||||||
{
|
{
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on TX power / off RX power
|
|
||||||
digitalWrite(SX126X_TXEN, HIGH);
|
|
||||||
#endif
|
|
||||||
#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC)
|
|
||||||
digitalWrite(SX126X_RXEN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RadioLibInterface::configHardwareForSend();
|
RadioLibInterface::configHardwareForSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,13 +212,6 @@ template <typename T> void SX126xInterface<T>::startReceive()
|
|||||||
|
|
||||||
setStandby();
|
setStandby();
|
||||||
|
|
||||||
#if defined(SX126X_RXEN) && (SX126X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on RX power / off TX power
|
|
||||||
digitalWrite(SX126X_RXEN, HIGH);
|
|
||||||
#endif
|
|
||||||
#if defined(SX126X_TXEN) && (SX126X_TXEN != RADIOLIB_NC)
|
|
||||||
digitalWrite(SX126X_TXEN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
||||||
// standby mostly.
|
// standby mostly.
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
#define RF95_RXEN 14
|
#define RF95_RXEN 14
|
||||||
#define RF95_TXEN 13
|
#define RF95_TXEN 13
|
||||||
|
|
||||||
|
// Set lora.tx_power to 13 for Hydra or other E22 900M30S target due to PA
|
||||||
|
#define SX126X_MAX_POWER 22
|
||||||
|
|
||||||
#ifdef EBYTE_E22
|
#ifdef EBYTE_E22
|
||||||
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
|
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
|
||||||
// (which is the default for the sx1262interface code)
|
// (which is the default for the sx1262interface code)
|
||||||
|
@ -206,6 +206,7 @@ SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
|||||||
#define SX126X_RESET (38)
|
#define SX126X_RESET (38)
|
||||||
// #define SX126X_TXEN (39)
|
// #define SX126X_TXEN (39)
|
||||||
// #define SX126X_RXEN (37)
|
// #define SX126X_RXEN (37)
|
||||||
|
#define SX126X_POWER_EN (37)
|
||||||
#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
||||||
|
|
||||||
// enables 3.3V periphery like GPS or IO Module
|
// enables 3.3V periphery like GPS or IO Module
|
||||||
|
@ -136,7 +136,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
|
|
||||||
// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON
|
// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON
|
||||||
// FIXME - I think this is actually just the board power enable - it enables power to the CPU also
|
// FIXME - I think this is actually just the board power enable - it enables power to the CPU also
|
||||||
//#define PIN_EINK_PWR_ON (-1)
|
// #define PIN_EINK_PWR_ON (-1)
|
||||||
|
|
||||||
#define USE_EINK
|
#define USE_EINK
|
||||||
|
|
||||||
@ -181,8 +181,9 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
#define SX126X_DIO1 (47)
|
#define SX126X_DIO1 (47)
|
||||||
#define SX126X_BUSY (46)
|
#define SX126X_BUSY (46)
|
||||||
#define SX126X_RESET (38)
|
#define SX126X_RESET (38)
|
||||||
#define SX126X_TXEN (39)
|
// #define SX126X_TXEN (39)
|
||||||
#define SX126X_RXEN (37)
|
// #define SX126X_RXEN (37)
|
||||||
|
#define SX126X_POWER_EN (37)
|
||||||
#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
|
||||||
|
|
||||||
// enables 3.3V periphery like GPS or IO Module
|
// enables 3.3V periphery like GPS or IO Module
|
||||||
|
Loading…
Reference in New Issue
Block a user