-
Notifications
You must be signed in to change notification settings - Fork 599
add heltec v4.3 board #1867
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
Open
Quency-D
wants to merge
9
commits into
meshcore-dev:dev
Choose a base branch
from
Quency-D:dev-heltec-v4.3
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−33
Open
add heltec v4.3 board #1867
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9312fe7
add heltec v4.3
Quency-D f0d37e5
Added version identification.
Quency-D 8b7fed6
default lna_enabled=true
weebl2000 14f066b
Fix sleep
weebl2000 70d3b96
Update variants/heltec_v4/LoRaFEMControl.cpp init function
Quency-D bab650f
LNA is enabled by default.
Quency-D 3b5139a
Update variants/heltec_v4/LoRaFEMControl.cpp
Quency-D c6d5301
Merge pull request #3 from weebl2000/dev-heltec-v4.3
Quency-D 8769c4b
Merge branch 'dev' into dev-heltec-v4.3
Quency-D 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
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
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,108 @@ | ||
| #include "LoRaFEMControl.h" | ||
| #include <driver/rtc_io.h> | ||
| #include <esp_sleep.h> | ||
| #include <Arduino.h> | ||
|
|
||
| void LoRaFEMControl::init(void) | ||
| { | ||
| // Power on FEM LDO — set registers before releasing RTC hold for | ||
| // atomic transition (no glitch on deep sleep wake). | ||
| pinMode(P_LORA_PA_POWER, OUTPUT); | ||
| digitalWrite(P_LORA_PA_POWER, HIGH); | ||
| rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER); | ||
|
|
||
| esp_reset_reason_t reason = esp_reset_reason(); | ||
| if (reason != ESP_RST_DEEPSLEEP) { | ||
| delay(1); // FEM startup time after cold power-on | ||
| } | ||
|
|
||
| // Auto-detect FEM type via shared GPIO2 default pull level. | ||
| // GC1109 CSD: internal pull-down → reads LOW | ||
| // KCT8103L CSD: internal pull-up → reads HIGH | ||
| rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CSD); | ||
| pinMode(P_LORA_KCT8103L_PA_CSD, INPUT); | ||
| delay(1); | ||
| if(digitalRead(P_LORA_KCT8103L_PA_CSD)==HIGH) { | ||
| // FEM is KCT8103L (V4.3) | ||
| fem_type= KCT8103L_PA; | ||
| pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT); | ||
| digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH); | ||
| rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CTX); | ||
| pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT); | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH); | ||
| setLnaCanControl(true); | ||
| } else { | ||
| // FEM is GC1109 (V4.2) | ||
| fem_type= GC1109_PA; | ||
| pinMode(P_LORA_GC1109_PA_EN, OUTPUT); | ||
| digitalWrite(P_LORA_GC1109_PA_EN, HIGH); | ||
| pinMode(P_LORA_GC1109_PA_TX_EN, OUTPUT); | ||
| digitalWrite(P_LORA_GC1109_PA_TX_EN, LOW); | ||
| } | ||
| } | ||
|
|
||
| void LoRaFEMControl::setSleepModeEnable(void) | ||
| { | ||
| if(fem_type==GC1109_PA) { | ||
| /* | ||
| * Do not switch the power on and off frequently. | ||
| * After turning off P_LORA_PA_EN, the power consumption has dropped to the uA level. | ||
| */ | ||
| digitalWrite(P_LORA_GC1109_PA_EN, LOW); | ||
| digitalWrite(P_LORA_GC1109_PA_TX_EN, LOW); | ||
| } else if(fem_type==KCT8103L_PA) { | ||
| // shutdown the PA | ||
| digitalWrite(P_LORA_KCT8103L_PA_CSD, LOW); | ||
| } | ||
| } | ||
|
|
||
| void LoRaFEMControl::setTxModeEnable(void) | ||
| { | ||
| if(fem_type==GC1109_PA) { | ||
| digitalWrite(P_LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(P_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(P_LORA_KCT8103L_PA_CSD, HIGH); | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH); | ||
| } | ||
| } | ||
|
|
||
| void LoRaFEMControl::setRxModeEnable(void) | ||
| { | ||
| if(fem_type==GC1109_PA) { | ||
| digitalWrite(P_LORA_GC1109_PA_EN, HIGH); // CSD=1: Chip enabled | ||
| digitalWrite(P_LORA_GC1109_PA_TX_EN, LOW); | ||
| } else if(fem_type==KCT8103L_PA) { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH); | ||
| if(lna_enabled) { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, LOW); // LNA on | ||
| } else { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH); // LNA bypass | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void LoRaFEMControl::setRxModeEnableWhenMCUSleep(void) | ||
| { | ||
| digitalWrite(P_LORA_PA_POWER, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER); | ||
| if(fem_type==GC1109_PA) { | ||
| digitalWrite(P_LORA_GC1109_PA_EN, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)P_LORA_GC1109_PA_EN); | ||
| gpio_pulldown_en((gpio_num_t)P_LORA_GC1109_PA_TX_EN); | ||
| } else if(fem_type==KCT8103L_PA) { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH); | ||
| rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CSD); | ||
| if(lna_enabled) { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, LOW); // LNA on | ||
| } else { | ||
| digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH); // LNA bypass | ||
| } | ||
| rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CTX); | ||
| } | ||
Quency-D marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void LoRaFEMControl::setLNAEnable(bool enabled) | ||
| { | ||
| lna_enabled = enabled; | ||
| } | ||
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,29 @@ | ||
| #pragma once | ||
| #include <stdint.h> | ||
|
|
||
| typedef enum { | ||
| GC1109_PA, | ||
| KCT8103L_PA, | ||
| OTHER_FEM_TYPES | ||
| } LoRaFEMType; | ||
|
|
||
| class LoRaFEMControl | ||
| { | ||
| public: | ||
| LoRaFEMControl(){ } | ||
| virtual ~LoRaFEMControl(){ } | ||
| void init(void); | ||
| void setSleepModeEnable(void); | ||
| void setTxModeEnable(void); | ||
| void setRxModeEnable(void); | ||
| void setRxModeEnableWhenMCUSleep(void); | ||
| void setLNAEnable(bool enabled); | ||
| bool isLnaCanControl(void) { return lna_can_control; } | ||
| void setLnaCanControl(bool can_control) { lna_can_control = can_control; } | ||
| LoRaFEMType getFEMType(void) const { return fem_type; } | ||
| private: | ||
| LoRaFEMType fem_type=OTHER_FEM_TYPES; | ||
| bool lna_enabled=true; | ||
| bool lna_can_control=false; | ||
| }; | ||
|
|
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
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.