Update main.cpp

This commit is contained in:
S5NC 2024-09-12 19:27:45 +01:00 committed by Tom Fifield
parent cd6bd1e9a3
commit af30485611

View File

@ -765,7 +765,7 @@ void setup()
screen->print("Started...\n");
// FIXME: move to SX126XInterface.cpp
// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually dealt in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to the RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself. One solution would be to set that pin as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=0 has the opposite and stable RF path effect as CTRL=1 and ¬CTRL=1, this depends on the RF switch, but for the cases where this works, this pin can be used. Better hardware design, which is done most the time, prevents this issue.
// Typically, the RF switch on SX126x boards is controlled by two signals, which are negations of each other (switched RFIO paths). The negation is usually performed in hardware, or (suboptimal design) TXEN and RXEN are the two inputs to this style of RF switch. On some boards, there is no hardware negation between CTRL and ¬CTRL, but CTRL is internally connected to DIO2, and DIO2's switching is done by the SX126X itself, so the MCU can't control ¬CTRL at exactly the same time. One solution would be to set ¬CTRL as SX126X_TXEN or SX126X_RXEN, but they may already be used for another purpose, such as controlling another PA/LNA. Keeping ¬CTRL high seems to work, as long CTRL=1, ¬CTRL=1 has the opposite and stable RF path effect as CTRL=0 and ¬CTRL=1, this depends on the RF switch, but it seems this usually works. Better hardware design, which is done most the time, means this workaround is not necessary.
#ifdef SX126X_ANT_SW // Add RADIOLIB_NC check, and beforehand define as such if it is undefined.
digitalWrite(SX126X_ANT_SW, HIGH);
pinMode(SX126X_ANT_SW, OUTPUT);