mirror of
https://github.com/agessaman/MeshCore.git
synced 2026-08-28 07:34:39 +00:00
Fixed hibernate/powerOff for ESP32 boards to stay at uA
This commit is contained in:
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "ESP32Board.h"
|
#include "ESP32Board.h"
|
||||||
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class MeshadventurerBoard : public ESP32Board {
|
class MeshadventurerBoard : public ESP32Board {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -35,34 +33,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are held on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerOff() override {
|
|
||||||
// TODO: re-enable this when there is a definite wake-up source pin:
|
|
||||||
// enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
analogReadResolution(12);
|
analogReadResolution(12);
|
||||||
|
|
||||||
|
|||||||
@@ -20,33 +20,6 @@ void HeltecE213Board::begin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecE213Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeltecE213Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t HeltecE213Board::getBattMilliVolts() {
|
uint16_t HeltecE213Board::getBattMilliVolts() {
|
||||||
analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class HeltecE213Board : public ESP32Board {
|
class HeltecE213Board : public ESP32Board {
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ public:
|
|||||||
HeltecE213Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
HeltecE213Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,33 +20,6 @@ void HeltecE290Board::begin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecE290Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeltecE290Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t HeltecE290Board::getBattMilliVolts() {
|
uint16_t HeltecE290Board::getBattMilliVolts() {
|
||||||
analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class HeltecE290Board : public ESP32Board {
|
class HeltecE290Board : public ESP32Board {
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ public:
|
|||||||
HeltecE290Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
|
HeltecE290Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
|
|
||||||
|
|||||||
@@ -20,33 +20,6 @@ void HeltecT190Board::begin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecT190Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeltecT190Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t HeltecT190Board::getBattMilliVolts() {
|
uint16_t HeltecT190Board::getBattMilliVolts() {
|
||||||
analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class HeltecT190Board : public ESP32Board {
|
class HeltecT190Board : public ESP32Board {
|
||||||
|
|
||||||
@@ -13,8 +12,6 @@ public:
|
|||||||
HeltecT190Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
HeltecT190Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
|
|
||||||
|
|||||||
@@ -35,33 +35,12 @@ void HeltecTrackerV2Board::begin() {
|
|||||||
loRaFEMControl.setRxModeEnable();
|
loRaFEMControl.setRxModeEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
void HeltecTrackerV2Board::powerOff() {
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
// Turn off PA
|
||||||
|
digitalWrite(P_LORA_PA_POWER, LOW);
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
ESP32Board::powerOff();
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeltecTrackerV2Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t HeltecTrackerV2Board::getBattMilliVolts() {
|
uint16_t HeltecTrackerV2Board::getBattMilliVolts() {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include "LoRaFEMControl.h"
|
#include "LoRaFEMControl.h"
|
||||||
|
|
||||||
class HeltecTrackerV2Board : public ESP32Board {
|
class HeltecTrackerV2Board : public ESP32Board {
|
||||||
@@ -17,7 +16,6 @@ public:
|
|||||||
void begin();
|
void begin();
|
||||||
void onBeforeTransmit(void) override;
|
void onBeforeTransmit(void) override;
|
||||||
void onAfterTransmit(void) override;
|
void onAfterTransmit(void) override;
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
void powerOff() override;
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#define PIN_VBAT_READ 37
|
#define PIN_VBAT_READ 37
|
||||||
#define PIN_LED_BUILTIN 25
|
#define PIN_LED_BUILTIN 25
|
||||||
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class HeltecV2Board : public ESP32Board {
|
class HeltecV2Board : public ESP32Board {
|
||||||
public:
|
public:
|
||||||
void begin() {
|
void begin() {
|
||||||
@@ -26,29 +24,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_0, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_0);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
if (pin_wake_btn < 0) {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_0), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_0) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
#define PIN_ADC_CTRL_ACTIVE LOW
|
#define PIN_ADC_CTRL_ACTIVE LOW
|
||||||
#define PIN_ADC_CTRL_INACTIVE HIGH
|
#define PIN_ADC_CTRL_INACTIVE HIGH
|
||||||
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class HeltecV3Board : public ESP32Board {
|
class HeltecV3Board : public ESP32Board {
|
||||||
private:
|
private:
|
||||||
bool adc_active_state;
|
bool adc_active_state;
|
||||||
@@ -52,33 +50,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerOff() override {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
analogReadResolution(10);
|
analogReadResolution(10);
|
||||||
digitalWrite(PIN_ADC_CTRL, adc_active_state);
|
digitalWrite(PIN_ADC_CTRL, adc_active_state);
|
||||||
|
|||||||
@@ -32,33 +32,12 @@ void HeltecV4Board::begin() {
|
|||||||
loRaFEMControl.setRxModeEnable();
|
loRaFEMControl.setRxModeEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeltecV4Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
void HeltecV4Board::powerOff() {
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
// Turn off PA
|
||||||
|
digitalWrite(P_LORA_PA_POWER, LOW);
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
ESP32Board::powerOff();
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeltecV4Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t HeltecV4Board::getBattMilliVolts() {
|
uint16_t HeltecV4Board::getBattMilliVolts() {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include "LoRaFEMControl.h"
|
#include "LoRaFEMControl.h"
|
||||||
|
|
||||||
#ifndef ADC_MULTIPLIER
|
#ifndef ADC_MULTIPLIER
|
||||||
@@ -23,7 +22,6 @@ public:
|
|||||||
void begin();
|
void begin();
|
||||||
void onBeforeTransmit(void) override;
|
void onBeforeTransmit(void) override;
|
||||||
void onAfterTransmit(void) override;
|
void onAfterTransmit(void) override;
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
void powerOff() override;
|
||||||
bool setLoRaFemLnaEnabled(bool enable) override;
|
bool setLoRaFemLnaEnabled(bool enable) override;
|
||||||
bool canControlLoRaFemLna() const override;
|
bool canControlLoRaFemLna() const override;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "helpers/ESP32Board.h"
|
#include "helpers/ESP32Board.h"
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
#define PIN_VBAT_READ 4
|
#define PIN_VBAT_READ 4
|
||||||
#define BATTERY_SAMPLES 8
|
#define BATTERY_SAMPLES 8
|
||||||
@@ -23,29 +22,6 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() {
|
uint16_t getBattMilliVolts() {
|
||||||
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
|
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
|
||||||
analogReadResolution(12);
|
analogReadResolution(12);
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
||||||
#define BATTERY_SAMPLES 8
|
#define BATTERY_SAMPLES 8
|
||||||
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class RAK3112Board : public ESP32Board {
|
class RAK3112Board : public ESP32Board {
|
||||||
private:
|
private:
|
||||||
bool adc_active_state;
|
bool adc_active_state;
|
||||||
@@ -51,33 +49,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerOff() override {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
analogReadResolution(12);
|
analogReadResolution(12);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class StationG2Board : public ESP32Board {
|
class StationG2Board : public ESP32Board {
|
||||||
public:
|
public:
|
||||||
@@ -21,29 +20,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
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
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#include "StationG3Board.h"
|
||||||
|
|
||||||
|
void StationG3Board::powerOff() {
|
||||||
|
#ifdef P_PA1_EN
|
||||||
|
setPAModeHigh(false);
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_PA1_EN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef P_PRIMARY_LNA_EN
|
||||||
|
setPrimaryLNAControl(true);
|
||||||
|
rtc_gpio_hold_en((gpio_num_t)P_PRIMARY_LNA_EN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ESP32Board::powerOff();
|
||||||
|
}
|
||||||
@@ -73,36 +73,7 @@ public:
|
|||||||
setPrimaryLNAControl(true);
|
setPrimaryLNAControl(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
void powerOff() override;
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
|
||||||
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
|
||||||
|
|
||||||
#ifdef P_PA1_EN
|
|
||||||
setPAModeHigh(false);
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_PA1_EN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef P_PRIMARY_LNA_EN
|
|
||||||
setPrimaryLNAControl(true);
|
|
||||||
rtc_gpio_hold_en((gpio_num_t)P_PRIMARY_LNA_EN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pin_wake_btn < 0) {
|
|
||||||
esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH);
|
|
||||||
} else {
|
|
||||||
esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1) | (1ULL << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_deep_sleep_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,40 +1,30 @@
|
|||||||
#include "ThinknodeM2Board.h"
|
#include "ThinknodeM2Board.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ThinknodeM2Board::begin() {
|
void ThinknodeM2Board::begin() {
|
||||||
pinMode(PIN_VEXT_EN, OUTPUT);
|
pinMode(PIN_VEXT_EN, OUTPUT);
|
||||||
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
||||||
delay(20); // allow power rail to discharge
|
delay(20); // allow power rail to discharge
|
||||||
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
||||||
delay(120); // give display time to bias on cold boot
|
delay(120); // give display time to bias on cold boot
|
||||||
ESP32Board::begin();
|
ESP32Board::begin();
|
||||||
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
|
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
|
||||||
}
|
|
||||||
|
|
||||||
void ThinknodeM2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_deep_sleep_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThinknodeM2Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ThinknodeM2Board::getBattMilliVolts() {
|
|
||||||
analogReadResolution(12);
|
|
||||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
|
||||||
|
|
||||||
uint32_t mv = 0;
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
|
||||||
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
|
||||||
delayMicroseconds(200);
|
|
||||||
}
|
|
||||||
mv /= 8;
|
|
||||||
|
|
||||||
analogReadResolution(10);
|
|
||||||
return static_cast<uint16_t>(mv * ADC_MULTIPLIER );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ThinknodeM2Board::getManufacturerName() const {
|
uint16_t ThinknodeM2Board::getBattMilliVolts() {
|
||||||
return "Elecrow ThinkNode M2";
|
analogReadResolution(12);
|
||||||
|
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||||
|
|
||||||
|
uint32_t mv = 0;
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
||||||
|
delayMicroseconds(200);
|
||||||
}
|
}
|
||||||
|
mv /= 8;
|
||||||
|
|
||||||
|
analogReadResolution(10);
|
||||||
|
return static_cast<uint16_t>(mv * ADC_MULTIPLIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ThinknodeM2Board::getManufacturerName() const {
|
||||||
|
return "Elecrow ThinkNode M2";
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,15 +3,11 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
class ThinknodeM2Board : public ESP32Board {
|
class ThinknodeM2Board : public ESP32Board {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,6 @@ void ThinknodeM5Board::begin() {
|
|||||||
ESP32Board::begin();
|
ESP32Board::begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThinknodeM5Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
||||||
esp_deep_sleep_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThinknodeM5Board::powerOff() {
|
|
||||||
enterDeepSleep(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ThinknodeM5Board::getBattMilliVolts() {
|
uint16_t ThinknodeM5Board::getBattMilliVolts() {
|
||||||
analogReadResolution(12);
|
analogReadResolution(12);
|
||||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <helpers/RefCountedDigitalPin.h>
|
#include <helpers/RefCountedDigitalPin.h>
|
||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include <PCA9557.h>
|
#include <PCA9557.h>
|
||||||
|
|
||||||
extern PCA9557 expander;
|
extern PCA9557 expander;
|
||||||
@@ -13,8 +12,6 @@ class ThinknodeM5Board : public ESP32Board {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
|
||||||
void powerOff() override;
|
|
||||||
uint16_t getBattMilliVolts() override;
|
uint16_t getBattMilliVolts() override;
|
||||||
const char* getManufacturerName() const override ;
|
const char* getManufacturerName() const override ;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <helpers/ESP32Board.h>
|
#include <helpers/ESP32Board.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include <driver/uart.h>
|
#include <driver/uart.h>
|
||||||
|
|
||||||
class XiaoC3Board : public ESP32Board {
|
class XiaoC3Board : public ESP32Board {
|
||||||
@@ -40,37 +39,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterDeepSleep(uint32_t secs, int8_t wake_pin = -1) {
|
|
||||||
gpio_set_direction(gpio_num_t(P_LORA_DIO_1), GPIO_MODE_INPUT);
|
|
||||||
if (wake_pin >= 0) {
|
|
||||||
gpio_set_direction((gpio_num_t)wake_pin, GPIO_MODE_INPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
//hold disable, isolate and power domain config functions may be unnecessary
|
|
||||||
//gpio_deep_sleep_hold_dis();
|
|
||||||
//esp_sleep_config_gpio_isolate();
|
|
||||||
gpio_deep_sleep_hold_en();
|
|
||||||
|
|
||||||
#if defined(LORA_TX_BOOST_PIN)
|
|
||||||
gpio_hold_en((gpio_num_t) LORA_TX_BOOST_PIN);
|
|
||||||
gpio_deep_sleep_hold_en();
|
|
||||||
#endif
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
|
||||||
|
|
||||||
if (wake_pin >= 0) {
|
|
||||||
esp_deep_sleep_enable_gpio_wakeup((1 << P_LORA_DIO_1) | (1 << wake_pin), ESP_GPIO_WAKEUP_GPIO_HIGH);
|
|
||||||
} else {
|
|
||||||
esp_deep_sleep_enable_gpio_wakeup(1 << P_LORA_DIO_1, ESP_GPIO_WAKEUP_GPIO_HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0) {
|
|
||||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally set ESP32 into sleep
|
|
||||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(LORA_TX_BOOST_PIN) || defined(P_LORA_TX_LED)
|
#if defined(LORA_TX_BOOST_PIN) || defined(P_LORA_TX_LED)
|
||||||
void onBeforeTransmit() override {
|
void onBeforeTransmit() override {
|
||||||
#if defined(P_LORA_TX_LED)
|
#if defined(P_LORA_TX_LED)
|
||||||
|
|||||||
Reference in New Issue
Block a user