mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 12:45:45 +00:00
Update Heltec Tracker v2 to version KCT8103L.
This commit is contained in:
@@ -39,6 +39,7 @@ class MicroNMEALocationProvider : public LocationProvider {
|
||||
mesh::RTCClock* _clock;
|
||||
Stream* _gps_serial;
|
||||
RefCountedDigitalPin* _peripher_power;
|
||||
int8_t _claims = 0;
|
||||
int _pin_reset;
|
||||
int _pin_en;
|
||||
long next_check = 0;
|
||||
@@ -57,8 +58,21 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
void claim() {
|
||||
_claims++;
|
||||
if (_claims > 0) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
}
|
||||
}
|
||||
|
||||
void release() {
|
||||
if (_claims == 0) return; // avoid negative _claims
|
||||
_claims--;
|
||||
if (_peripher_power) _peripher_power->release();
|
||||
}
|
||||
|
||||
void begin() override {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
claim();
|
||||
if (_pin_en != -1) {
|
||||
digitalWrite(_pin_en, PIN_GPS_EN_ACTIVE);
|
||||
}
|
||||
@@ -82,7 +96,7 @@ public :
|
||||
if (_pin_reset != -1) {
|
||||
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
||||
}
|
||||
if (_peripher_power) _peripher_power->release();
|
||||
release();
|
||||
}
|
||||
|
||||
bool isEnabled() override {
|
||||
|
||||
@@ -6,19 +6,7 @@ void HeltecTrackerV2Board::begin() {
|
||||
pinMode(PIN_ADC_CTRL, OUTPUT);
|
||||
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
|
||||
|
||||
// Set up digital GPIO registers before releasing RTC hold. The hold latches
|
||||
// the pad state including function select, so register writes accumulate
|
||||
// without affecting the pad. On hold release, all changes apply atomically
|
||||
// (IO MUX switches to digital GPIO with output already HIGH — no glitch).
|
||||
pinMode(P_LORA_PA_POWER, OUTPUT);
|
||||
digitalWrite(P_LORA_PA_POWER,HIGH);
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
|
||||
|
||||
pinMode(P_LORA_PA_EN, OUTPUT);
|
||||
digitalWrite(P_LORA_PA_EN,HIGH);
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);
|
||||
pinMode(P_LORA_PA_TX_EN, OUTPUT);
|
||||
digitalWrite(P_LORA_PA_TX_EN,LOW);
|
||||
loRaFEMControl.init();
|
||||
|
||||
esp_reset_reason_t reason = esp_reset_reason();
|
||||
if (reason != ESP_RST_DEEPSLEEP) {
|
||||
@@ -39,12 +27,12 @@ void HeltecTrackerV2Board::begin() {
|
||||
|
||||
void HeltecTrackerV2Board::onBeforeTransmit(void) {
|
||||
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
|
||||
digitalWrite(P_LORA_PA_TX_EN,HIGH);
|
||||
loRaFEMControl.setTxModeEnable();
|
||||
}
|
||||
|
||||
void HeltecTrackerV2Board::onAfterTransmit(void) {
|
||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
||||
digitalWrite(P_LORA_PA_TX_EN,LOW);
|
||||
loRaFEMControl.setRxModeEnable();
|
||||
}
|
||||
|
||||
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
@@ -56,9 +44,7 @@ void HeltecTrackerV2Board::begin() {
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
// Hold GC1109 FEM pins during sleep to keep LNA active for RX wake
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN);
|
||||
loRaFEMControl.setRxModeEnableWhenMCUSleep();//It also needs to be enabled in receive mode
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
class HeltecTrackerV2Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
RefCountedDigitalPin periph_power;
|
||||
LoRaFEMControl loRaFEMControl;
|
||||
|
||||
HeltecTrackerV2Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
|
||||
58
variants/heltec_tracker_v2/LoRaFEMControl.cpp
Normal file
58
variants/heltec_tracker_v2/LoRaFEMControl.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "LoRaFEMControl.h"
|
||||
#include <driver/rtc_io.h>
|
||||
#include <esp_sleep.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
void LoRaFEMControl::init(void)
|
||||
{
|
||||
pinMode(P_LORA_PA_POWER, OUTPUT);
|
||||
digitalWrite(P_LORA_PA_POWER, HIGH);
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_POWER);
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CSD);
|
||||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_KCT8103L_PA_CTX);
|
||||
delay(1);
|
||||
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
||||
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
setLnaCanControl(true);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setSleepModeEnable(void)
|
||||
{
|
||||
// shutdown the PA
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, LOW);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setTxModeEnable(void)
|
||||
{
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setRxModeEnable(void)
|
||||
{
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
|
||||
if (lna_enabled) {
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, LOW);
|
||||
} else {
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setRxModeEnableWhenMCUSleep(void)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
|
||||
}
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_KCT8103L_PA_CTX);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setLNAEnable(bool enabled)
|
||||
{
|
||||
lna_enabled = enabled;
|
||||
}
|
||||
21
variants/heltec_tracker_v2/LoRaFEMControl.h
Normal file
21
variants/heltec_tracker_v2/LoRaFEMControl.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
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; }
|
||||
|
||||
private:
|
||||
bool lna_enabled = false;
|
||||
bool lna_can_control = false;
|
||||
};
|
||||
@@ -17,18 +17,18 @@ build_flags =
|
||||
-D P_LORA_SCLK=9
|
||||
-D P_LORA_MISO=11
|
||||
-D P_LORA_MOSI=10
|
||||
-D P_LORA_PA_POWER=7 ; VFEM_Ctrl - GC1109 LDO power enable
|
||||
-D P_LORA_PA_EN=4 ; CSD - GC1109 chip enable (HIGH=on)
|
||||
-D P_LORA_PA_TX_EN=46 ; CPS - GC1109 PA mode (HIGH=full PA, LOW=bypass)
|
||||
-D LORA_TX_POWER=10 ; 10dBm + ~11dB GC1109 gain = ~21dBm output
|
||||
-D P_LORA_PA_POWER=7 ;VFEM_Ctrl -LDO power enable
|
||||
-D P_LORA_KCT8103L_PA_CSD=4
|
||||
-D P_LORA_KCT8103L_PA_CTX=5
|
||||
-D LORA_TX_POWER=9 ; 9dBm + ~14dB KCT8103L gain = ~22dBm output
|
||||
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~28dBm at antenna
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D SX126X_REGISTER_PATCH=1
|
||||
-D PIN_BOARD_SDA=5
|
||||
-D PIN_BOARD_SCL=6
|
||||
-D PIN_BOARD_SDA=6
|
||||
-D PIN_BOARD_SCL=17
|
||||
-D PIN_USER_BTN=0
|
||||
-D PIN_TFT_SDA=42 ; SDIN
|
||||
-D PIN_TFT_SCL=41 ; SCLK
|
||||
@@ -207,8 +207,6 @@ build_flags =
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ENV_PIN_SDA=3
|
||||
-D ENV_PIN_SCL=4
|
||||
-D DISPLAY_CLASS=ST7735Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
Reference in New Issue
Block a user