Repository navigation
add heltec v4 board. #813
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 board. #813
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| { | ||
| "build": { | ||
| "arduino": { | ||
| "ldscript": "esp32s3_out.ld", | ||
| "partitions": "default_16MB.csv", | ||
| "memory_type": "qio_qspi" | ||
| }, | ||
| "core": "esp32", | ||
| "extra_flags": [ | ||
| "-DBOARD_HAS_PSRAM", | ||
| "-DARDUINO_USB_CDC_ON_BOOT=1", | ||
| "-DARDUINO_USB_MODE=0", | ||
| "-DARDUINO_RUNNING_CORE=1", | ||
| "-DARDUINO_EVENT_RUNNING_CORE=1" | ||
| ], | ||
| "f_cpu": "240000000L", | ||
| "f_flash": "80000000L", | ||
| "flash_mode": "qio", | ||
| "psram_type": "qspi", | ||
| "hwids": [["0x303A", "0x1001"]], | ||
| "mcu": "esp32s3", | ||
| "variant": "heltec_v4" | ||
| }, | ||
| "connectivity": ["wifi", "bluetooth", "lora"], | ||
| "debug": { | ||
| "default_tool": "esp-builtin", | ||
| "onboard_tools": ["esp-builtin"], | ||
| "openocd_target": "esp32s3.cfg" | ||
| }, | ||
| "frameworks": ["arduino", "espidf"], | ||
| "name": "heltec_wifi_lora_32 v4 (16 MB FLASH, 2 MB PSRAM)", | ||
| "upload": { | ||
| "flash_size": "16MB", | ||
| "maximum_ram_size": 2097152, | ||
| "maximum_size": 16777216, | ||
| "use_1200bps_touch": true, | ||
| "wait_for_upload_port": true, | ||
| "require_upload_port": true, | ||
| "speed": 921600 | ||
| }, | ||
| "url": "https://heltec.org/", | ||
| "vendor": "heltec" | ||
| } |
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,90 @@ | ||
| #include "HeltecV4Board.h" | ||
|
|
||
| void HeltecV4Board::begin() { | ||
| ESP32Board::begin(); | ||
|
|
||
|
|
||
| pinMode(PIN_ADC_CTRL, OUTPUT); | ||
| digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive | ||
|
|
||
| pinMode(P_LORA_PA_POWER, OUTPUT); | ||
| digitalWrite(P_LORA_PA_POWER,HIGH); | ||
|
|
||
| rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN); | ||
| pinMode(P_LORA_PA_EN, OUTPUT); | ||
| digitalWrite(P_LORA_PA_EN,HIGH); | ||
| pinMode(P_LORA_PA_TX_EN, OUTPUT); | ||
| digitalWrite(P_LORA_PA_TX_EN,LOW); | ||
|
|
||
|
|
||
| periph_power.begin(); | ||
|
|
||
| esp_reset_reason_t reason = esp_reset_reason(); | ||
| if (reason == ESP_RST_DEEPSLEEP) { | ||
| long wakeup_source = esp_sleep_get_ext1_wakeup_status(); | ||
| if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep) | ||
| startup_reason = BD_STARTUP_RX_PACKET; | ||
| } | ||
|
|
||
| rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS); | ||
| rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1); | ||
| } | ||
| } | ||
|
|
||
| void HeltecV4Board::onBeforeTransmit(void) { | ||
| digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on | ||
| digitalWrite(P_LORA_PA_TX_EN,HIGH); | ||
| } | ||
|
|
||
| void HeltecV4Board::onAfterTransmit(void) { | ||
| digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off | ||
| digitalWrite(P_LORA_PA_TX_EN,LOW); | ||
| } | ||
|
|
||
| void HeltecV4Board::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); | ||
|
|
||
| rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_EN); //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() { | ||
| analogReadResolution(10); | ||
| digitalWrite(PIN_ADC_CTRL, HIGH); | ||
| delay(10); | ||
| uint32_t raw = 0; | ||
| for (int i = 0; i < 8; i++) { | ||
| raw += analogRead(PIN_VBAT_READ); | ||
| } | ||
| raw = raw / 8; | ||
|
|
||
| digitalWrite(PIN_ADC_CTRL, LOW); | ||
|
|
||
| return (5.42 * (3.3 / 1024.0) * raw) * 1000; | ||
| } | ||
|
|
||
| const char* HeltecV4Board::getManufacturerName() const { | ||
| return "Heltec V4"; | ||
| } |
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,23 @@ | ||
| #pragma once | ||
|
|
||
| #include <Arduino.h> | ||
| #include <helpers/RefCountedDigitalPin.h> | ||
| #include <helpers/ESP32Board.h> | ||
| #include <driver/rtc_io.h> | ||
|
|
||
| class HeltecV4Board : public ESP32Board { | ||
|
|
||
| public: | ||
| RefCountedDigitalPin periph_power; | ||
|
|
||
| HeltecV4Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { } | ||
|
|
||
| void begin(); | ||
| void onBeforeTransmit(void) override; | ||
| void onAfterTransmit(void) override; | ||
| void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1); | ||
| void powerOff() override; | ||
| uint16_t getBattMilliVolts() override; | ||
| const char* getManufacturerName() const override ; | ||
|
|
||
| }; |
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,67 @@ | ||
| #ifndef Pins_Arduino_h | ||
| #define Pins_Arduino_h | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| static const uint8_t LED_BUILTIN = 35; | ||
| #define BUILTIN_LED LED_BUILTIN // backward compatibility | ||
| #define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN | ||
|
|
||
| static const uint8_t TX = 43; | ||
| static const uint8_t RX = 44; | ||
|
|
||
| static const uint8_t SDA = 3; | ||
| static const uint8_t SCL = 4; | ||
|
|
||
| static const uint8_t SS = 8; | ||
| static const uint8_t MOSI = 10; | ||
| static const uint8_t MISO = 11; | ||
| static const uint8_t SCK = 9; | ||
|
|
||
| static const uint8_t A0 = 1; | ||
| static const uint8_t A1 = 2; | ||
| static const uint8_t A2 = 3; | ||
| static const uint8_t A3 = 4; | ||
| static const uint8_t A4 = 5; | ||
| static const uint8_t A5 = 6; | ||
| static const uint8_t A6 = 7; | ||
| static const uint8_t A7 = 8; | ||
| static const uint8_t A8 = 9; | ||
| static const uint8_t A9 = 10; | ||
| static const uint8_t A10 = 11; | ||
| static const uint8_t A11 = 12; | ||
| static const uint8_t A12 = 13; | ||
| static const uint8_t A13 = 14; | ||
| static const uint8_t A14 = 15; | ||
| static const uint8_t A15 = 16; | ||
| static const uint8_t A16 = 17; | ||
| static const uint8_t A17 = 18; | ||
| static const uint8_t A18 = 19; | ||
| static const uint8_t A19 = 20; | ||
|
|
||
| static const uint8_t T1 = 1; | ||
| static const uint8_t T2 = 2; | ||
| static const uint8_t T3 = 3; | ||
| static const uint8_t T4 = 4; | ||
| static const uint8_t T5 = 5; | ||
| static const uint8_t T6 = 6; | ||
| static const uint8_t T7 = 7; | ||
| static const uint8_t T8 = 8; | ||
| static const uint8_t T9 = 9; | ||
| static const uint8_t T10 = 10; | ||
| static const uint8_t T11 = 11; | ||
| static const uint8_t T12 = 12; | ||
| static const uint8_t T13 = 13; | ||
| static const uint8_t T14 = 14; | ||
|
|
||
| static const uint8_t Vext = 36; | ||
| static const uint8_t LED = 35; | ||
| static const uint8_t RST_OLED = 21; | ||
| static const uint8_t SCL_OLED = 18; | ||
| static const uint8_t SDA_OLED = 17; | ||
|
|
||
| static const uint8_t RST_LoRa = 12; | ||
| static const uint8_t BUSY_LoRa = 13; | ||
| static const uint8_t DIO0 = 14; | ||
|
|
||
| #endif /* Pins_Arduino_h */ |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have been nice to give a default value to PIN_GPS_RESET_ACTIVE ... ;)
Because now compilation breaks on TEcho (at least)
I think reset is handled in MicroNMEALocationProvider ...
I'll see how I can clean this mess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is where gps reset is done
MeshCore/src/helpers/sensors/MicroNMEALocationProvider.h
Lines 51 to 57 in ea13fa8
I agree the
GPS_RESET_FORCEsymbol could be changed toPIN_GPS_RESET_ACTIVEbut it has been here for a long time now ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the big issue is that EnvironmentSensorManager is a big mess regarding GPS management ...
I won't be able to fix everything ... will just try to make things work, but there is a need for some rewriting here ...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #820
I've tried to use the symbols introduced in this PR ... so it should work on heltec_v4, but would need to be verified