-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add heltec-v4.3 board #9753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add heltec-v4.3 board #9753
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
717c6e2
Add heltec-v4.3 board
Quency-D aa66dd1
Modify LNA control display content
Quency-D 788725c
Fix Heltec Tracker v2 FEM control
Quency-D fc9651c
Use trunk to fix formatting issues.
Quency-D 2be5225
Merge branch 'develop' into heltec-v4.3
Quency-D 1116217
Optimize the fem initialization control logic.
Quency-D 1612abe
Merge branch 'develop' into heltec-v4.3
caveman99 609694e
Update src/mesh/RadioInterface.h change #ifdef to #if
Quency-D 09ba527
Change LORA_PA_EN to LORA_GC1109_PA_EN.
Quency-D f2720fa
Remove the NodeDB.h include.
Quency-D 5285c43
Change tx_gain to a const variable.
Quency-D 81a5ef5
Fixed the issue where ARCH_PORTDUINO lacked the NUM_PA_POINTS macro.
Quency-D 020e95f
Remove the comment.
Quency-D c06afb3
Move #pragma once to the first line.
Quency-D 984658d
Merge branch 'develop' into heltec-v4.3
caveman99 fc467bf
Remove the FEM LNA control menu.
Quency-D 5464984
Add description for KCT8103L.
Quency-D f96d035
Merge branch 'develop' into heltec-v4.3
Quency-D 3d8a066
Merge branch 'develop' into heltec-v4.3
thebentern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| #if HAS_LORA_FEM | ||
| #include "LoRaFEMInterface.h" | ||
|
|
||
| #if defined(ARCH_ESP32) | ||
| #include <driver/rtc_io.h> | ||
| #include <esp_sleep.h> | ||
| #endif | ||
|
|
||
| LoRaFEMInterface loraFEMInterface; | ||
| void LoRaFEMInterface::init(void) | ||
| { | ||
| setLnaCanControl(false); // Default is uncontrollable | ||
| #ifdef HELTEC_V4 | ||
| pinMode(LORA_PA_POWER, OUTPUT); | ||
| digitalWrite(LORA_PA_POWER, HIGH); | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_PA_POWER); | ||
| delay(1); | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_KCT8103L_PA_CSD); | ||
| pinMode(LORA_KCT8103L_PA_CSD, INPUT); // detect which FEM is used | ||
| delay(1); | ||
| if (digitalRead(LORA_KCT8103L_PA_CSD) == HIGH) { | ||
| // FEM is KCT8103L | ||
| fem_type = KCT8103L_PA; | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_KCT8103L_PA_CTX); | ||
| pinMode(LORA_KCT8103L_PA_CSD, OUTPUT); | ||
| digitalWrite(LORA_KCT8103L_PA_CSD, HIGH); | ||
| pinMode(LORA_KCT8103L_PA_CTX, OUTPUT); | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, HIGH); | ||
| setLnaCanControl(true); | ||
| } else if (digitalRead(LORA_KCT8103L_PA_CSD) == LOW) { | ||
| // FEM is GC1109 | ||
| fem_type = GC1109_PA; | ||
| // LORA_GC1109_PA_EN and LORA_KCT8103L_PA_CSD are the same pin and do not need to be repeatedly turned off and held. | ||
| // rtc_gpio_hold_dis((gpio_num_t)LORA_GC1109_PA_EN); | ||
| pinMode(LORA_GC1109_PA_EN, OUTPUT); | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); | ||
| pinMode(LORA_GC1109_PA_TX_EN, OUTPUT); | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| } else { | ||
| fem_type = OTHER_FEM_TYPES; | ||
| } | ||
| #elif defined(USE_GC1109_PA) | ||
| fem_type = GC1109_PA; | ||
| #if defined(ARCH_ESP32) | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_PA_POWER); | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_GC1109_PA_EN); | ||
| rtc_gpio_hold_dis((gpio_num_t)LORA_GC1109_PA_TX_EN); | ||
| #endif | ||
| pinMode(LORA_PA_POWER, OUTPUT); | ||
| digitalWrite(LORA_PA_POWER, HIGH); | ||
| delay(1); | ||
| pinMode(LORA_GC1109_PA_EN, OUTPUT); | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); | ||
| pinMode(LORA_GC1109_PA_TX_EN, OUTPUT); | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| #endif | ||
| } | ||
|
|
||
| void LoRaFEMInterface::setSleepModeEnable(void) | ||
| { | ||
| #ifdef HELTEC_V4 | ||
| if (fem_type == GC1109_PA) { | ||
| /* | ||
| * Do not switch the power on and off frequently. | ||
| * After turning off LORA_GC1109_PA_EN, the power consumption has dropped to the uA level. | ||
| */ | ||
| digitalWrite(LORA_GC1109_PA_EN, LOW); | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| } else if (fem_type == KCT8103L_PA) { | ||
| // shutdown the PA | ||
| digitalWrite(LORA_KCT8103L_PA_CSD, LOW); | ||
| } | ||
| #elif defined(USE_GC1109_PA) | ||
| digitalWrite(LORA_GC1109_PA_EN, LOW); | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| #endif | ||
| } | ||
|
|
||
| void LoRaFEMInterface::setTxModeEnable(void) | ||
| { | ||
| #ifdef HELTEC_V4 | ||
| if (fem_type == GC1109_PA) { | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, HIGH); // CPS: 1=full PA, 0=bypass (for RX, CPS is don't care) | ||
| } else if (fem_type == KCT8103L_PA) { | ||
| digitalWrite(LORA_KCT8103L_PA_CSD, HIGH); | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, HIGH); | ||
| } | ||
| #elif defined(USE_GC1109_PA) | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, HIGH); // CPS: 1=full PA, 0=bypass (for RX, CPS is don't care) | ||
| #endif | ||
| } | ||
|
|
||
| void LoRaFEMInterface::setRxModeEnable(void) | ||
| { | ||
| #ifdef HELTEC_V4 | ||
| if (fem_type == GC1109_PA) { | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| } else if (fem_type == KCT8103L_PA) { | ||
| digitalWrite(LORA_KCT8103L_PA_CSD, HIGH); | ||
| if (lna_enabled) { | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, LOW); | ||
| } else { | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, HIGH); | ||
| } | ||
| } | ||
| #elif defined(USE_GC1109_PA) | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(LORA_GC1109_PA_TX_EN, LOW); | ||
| #endif | ||
| } | ||
|
|
||
| void LoRaFEMInterface::setRxModeEnableWhenMCUSleep(void) | ||
| { | ||
|
|
||
| #ifdef HELTEC_V4 | ||
| // Keep GC1109 FEM powered during deep sleep so LNA remains active for RX wake. | ||
| // Set PA_POWER and PA_EN HIGH (overrides SX126xInterface::sleep() shutdown), | ||
| // then latch with RTC hold so the state survives deep sleep. | ||
| digitalWrite(LORA_PA_POWER, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_PA_POWER); | ||
| if (fem_type == GC1109_PA) { | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_GC1109_PA_EN); | ||
| gpio_pulldown_en((gpio_num_t)LORA_GC1109_PA_TX_EN); | ||
| } else if (fem_type == KCT8103L_PA) { | ||
| digitalWrite(LORA_KCT8103L_PA_CSD, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_KCT8103L_PA_CSD); | ||
| if (lna_enabled) { | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, LOW); | ||
| } else { | ||
| digitalWrite(LORA_KCT8103L_PA_CTX, HIGH); | ||
| } | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_KCT8103L_PA_CTX); | ||
| } | ||
| #elif defined(USE_GC1109_PA) | ||
| digitalWrite(LORA_PA_POWER, HIGH); | ||
| digitalWrite(LORA_GC1109_PA_EN, HIGH); | ||
| #if defined(ARCH_ESP32) | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_PA_POWER); | ||
| rtc_gpio_hold_en((gpio_num_t)LORA_GC1109_PA_EN); | ||
| gpio_pulldown_en((gpio_num_t)LORA_GC1109_PA_TX_EN); | ||
| #endif | ||
| #endif | ||
| } | ||
|
|
||
| void LoRaFEMInterface::setLNAEnable(bool enabled) | ||
| { | ||
| lna_enabled = enabled; | ||
| } | ||
|
|
||
| int8_t LoRaFEMInterface::powerConversion(int8_t loraOutputPower) | ||
| { | ||
| #ifdef HELTEC_V4 | ||
| const uint16_t gc1109_tx_gain[] = {11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7}; | ||
| const uint16_t kct8103l_tx_gain[] = {13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 7}; | ||
| const uint16_t *tx_gain; | ||
| uint16_t tx_gain_num; | ||
| if (fem_type == GC1109_PA) { | ||
| tx_gain = gc1109_tx_gain; | ||
| tx_gain_num = sizeof(gc1109_tx_gain) / sizeof(gc1109_tx_gain[0]); | ||
| } else if (fem_type == KCT8103L_PA) { | ||
| tx_gain = kct8103l_tx_gain; | ||
| tx_gain_num = sizeof(kct8103l_tx_gain) / sizeof(kct8103l_tx_gain[0]); | ||
| } else { | ||
| return loraOutputPower; | ||
| } | ||
| #else | ||
| #ifdef ARCH_PORTDUINO | ||
| size_t num_pa_points = portduino_config.num_pa_points; | ||
| const uint16_t *tx_gain = portduino_config.tx_gain_lora; | ||
| uint16_t tx_gain_num = num_pa_points; | ||
| #else | ||
| size_t num_pa_points = NUM_PA_POINTS; | ||
| const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA}; | ||
| uint16_t tx_gain_num = NUM_PA_POINTS; | ||
| #endif | ||
| #endif | ||
| for (int radio_dbm = 0; radio_dbm < tx_gain_num; radio_dbm++) { | ||
| if (((radio_dbm + tx_gain[radio_dbm]) > loraOutputPower) || | ||
| ((radio_dbm == (tx_gain_num - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= loraOutputPower))) { | ||
| // we've exceeded the power limit, or hit the max we can do | ||
| LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", loraOutputPower, tx_gain[radio_dbm]); | ||
| loraOutputPower -= tx_gain[radio_dbm]; | ||
| break; | ||
| } | ||
| } | ||
| return loraOutputPower; | ||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #pragma once | ||
| #if HAS_LORA_FEM | ||
| #include "configuration.h" | ||
| #include <stdint.h> | ||
|
|
||
| typedef enum { GC1109_PA, KCT8103L_PA, OTHER_FEM_TYPES } LoRaFEMType; | ||
|
|
||
| class LoRaFEMInterface | ||
| { | ||
| public: | ||
| LoRaFEMInterface() {} | ||
| virtual ~LoRaFEMInterface() {} | ||
| void init(void); | ||
| void setSleepModeEnable(void); | ||
| void setTxModeEnable(void); | ||
| void setRxModeEnable(void); | ||
| void setRxModeEnableWhenMCUSleep(void); | ||
| void setLNAEnable(bool enabled); | ||
| int8_t powerConversion(int8_t loraOutputPower); | ||
| bool isLnaCanControl(void) { return lna_can_control; } | ||
| void setLnaCanControl(bool can_control) { lna_can_control = can_control; } | ||
|
|
||
| private: | ||
| LoRaFEMType fem_type; | ||
| bool lna_enabled = false; | ||
| bool lna_can_control = false; | ||
| }; | ||
| extern LoRaFEMInterface loraFEMInterface; | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -915,6 +915,12 @@ void RadioInterface::limitPower(int8_t loraMaxPower) | |||
| power = maxPower; | ||||
| } | ||||
|
|
||||
| #if HAS_LORA_FEM | ||||
| if (!devicestate.owner.is_licensed) { | ||||
| power = loraFEMInterface.powerConversion(power); | ||||
| } | ||||
|
Quency-D marked this conversation as resolved.
|
||||
| #else | ||||
| // todo:All entries containing "lora fem" are grouped together above. | ||||
|
||||
| // todo:All entries containing "lora fem" are grouped together above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.