mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-27 04:02:05 +00:00
Move device code from main.cpp to earlyInitVariant (#9438)
This commit is contained in:
@@ -11,6 +11,10 @@ custom_meshtastic_requires_dfu = false
|
||||
|
||||
extends = esp32s3_base
|
||||
board = ESP32-S3-WROOM-1-N4
|
||||
build_src_filter =
|
||||
${esp32s3_base.build_src_filter}
|
||||
+<../variants/esp32s3/ELECROW-ThinkNode-M5>
|
||||
|
||||
build_flags =
|
||||
${esp32s3_base.build_flags}
|
||||
-D ELECROW_ThinkNode_M5
|
||||
|
||||
12
variants/esp32s3/ELECROW-ThinkNode-M5/variant.cpp
Normal file
12
variants/esp32s3/ELECROW-ThinkNode-M5/variant.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "variant.h"
|
||||
#include <PCA9557.h>
|
||||
|
||||
PCA9557 io(0x18, &Wire);
|
||||
|
||||
void earlyInitVariant()
|
||||
{
|
||||
Wire.begin(48, 47);
|
||||
io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
|
||||
io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
|
||||
io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
#define UART_TX 43
|
||||
#define UART_RX 44
|
||||
|
||||
#define HAS_PCA9557
|
||||
|
||||
// LED
|
||||
// Both of these are on the GPIO expander
|
||||
#define PCA_LED_USER 1 // the Blue LED
|
||||
|
||||
@@ -6,6 +6,10 @@ board_check = true
|
||||
board_build.partitions = default_16MB.csv
|
||||
upload_protocol = esptool
|
||||
|
||||
build_src_filter =
|
||||
${esp32s3_base.build_src_filter}
|
||||
+<../variants/esp32s3/hackaday-communicator>
|
||||
|
||||
build_flags = ${esp32s3_base.build_flags}
|
||||
-D HACKADAY_COMMUNICATOR
|
||||
-D BOARD_HAS_PSRAM
|
||||
@@ -13,4 +17,4 @@ build_flags = ${esp32s3_base.build_flags}
|
||||
|
||||
lib_deps = ${esp32s3_base.lib_deps}
|
||||
# renovate: datasource=git-refs depName=meshtastic-Arduino_GFX packageName=https://github.com/meshtastic/Arduino_GFX gitBranch=master
|
||||
https://github.com/meshtastic/Arduino_GFX/archive/054e81ffaf23784830a734e3c184346789349406.zip
|
||||
https://github.com/meshtastic/Arduino_GFX/archive/054e81ffaf23784830a734e3c184346789349406.zip
|
||||
6
variants/esp32s3/hackaday-communicator/variant.cpp
Normal file
6
variants/esp32s3/hackaday-communicator/variant.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
void earlyInitVariant()
|
||||
{
|
||||
pinMode(KB_INT, INPUT);
|
||||
}
|
||||
@@ -15,6 +15,10 @@ board = t-deck-pro
|
||||
board_check = true
|
||||
upload_protocol = esptool
|
||||
|
||||
build_src_filter =
|
||||
${esp32s3_base.build_src_filter}
|
||||
+<../variants/esp32s3/t-deck-pro>
|
||||
|
||||
build_flags =
|
||||
${esp32s3_base.build_flags} -I variants/esp32s3/t-deck-pro
|
||||
-D T_DECK_PRO
|
||||
|
||||
14
variants/esp32s3/t-deck-pro/variant.cpp
Normal file
14
variants/esp32s3/t-deck-pro/variant.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
void earlyInitVariant()
|
||||
{
|
||||
pinMode(LORA_EN, OUTPUT);
|
||||
digitalWrite(LORA_EN, HIGH);
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(PIN_EINK_CS, OUTPUT);
|
||||
digitalWrite(PIN_EINK_CS, HIGH);
|
||||
}
|
||||
@@ -17,6 +17,10 @@ board_check = true
|
||||
board_build.partitions = default_16MB.csv
|
||||
upload_protocol = esptool
|
||||
|
||||
build_src_filter =
|
||||
${esp32s3_base.build_src_filter}
|
||||
+<../variants/esp32s3/t-deck>
|
||||
|
||||
build_flags = ${esp32s3_base.build_flags}
|
||||
-D T_DECK
|
||||
-D BOARD_HAS_PSRAM
|
||||
|
||||
23
variants/esp32s3/t-deck/variant.cpp
Normal file
23
variants/esp32s3/t-deck/variant.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
void earlyInitVariant()
|
||||
{
|
||||
// GPIO10 manages all peripheral power supplies
|
||||
// Turn on peripheral power immediately after MUC starts.
|
||||
// If some boards are turned on late, ESP32 will reset due to low voltage.
|
||||
// ESP32-C3(Keyboard) , MAX98357A(Audio Power Amplifier) ,
|
||||
// TF Card , Display backlight(AW9364DNR) , AN48841B(Trackball) , ES7210(Decoder)
|
||||
pinMode(KB_POWERON, OUTPUT);
|
||||
digitalWrite(KB_POWERON, HIGH);
|
||||
// T-Deck has all three SPI peripherals (TFT, SD, LoRa) attached to the same SPI bus
|
||||
// We need to initialize all CS pins in advance otherwise there will be SPI communication issues
|
||||
// e.g. when detecting the SD card
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
delay(100);
|
||||
}
|
||||
@@ -17,6 +17,10 @@ board_check = true
|
||||
board_build.partitions = default_16MB.csv
|
||||
upload_protocol = esptool
|
||||
|
||||
build_src_filter =
|
||||
${esp32s3_base.build_src_filter}
|
||||
+<../variants/esp32s3/tlora-pager>
|
||||
|
||||
build_flags = ${esp32s3_base.build_flags}
|
||||
-I variants/esp32s3/tlora-pager
|
||||
-D T_LORA_PAGER
|
||||
|
||||
31
variants/esp32s3/tlora-pager/variant.cpp
Normal file
31
variants/esp32s3/tlora-pager/variant.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "variant.h"
|
||||
#include "ExtensionIOXL9555.hpp"
|
||||
extern ExtensionIOXL9555 io;
|
||||
|
||||
void earlyInitVariant()
|
||||
{
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
pinMode(SDCARD_CS, OUTPUT);
|
||||
digitalWrite(SDCARD_CS, HIGH);
|
||||
pinMode(TFT_CS, OUTPUT);
|
||||
digitalWrite(TFT_CS, HIGH);
|
||||
pinMode(KB_INT, INPUT_PULLUP);
|
||||
// io expander
|
||||
io.begin(Wire, XL9555_SLAVE_ADDRESS0, SDA, SCL);
|
||||
io.pinMode(EXPANDS_DRV_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_DRV_EN, HIGH);
|
||||
io.pinMode(EXPANDS_AMP_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_AMP_EN, LOW);
|
||||
io.pinMode(EXPANDS_LORA_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_LORA_EN, HIGH);
|
||||
io.pinMode(EXPANDS_GPS_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_GPS_EN, HIGH);
|
||||
io.pinMode(EXPANDS_KB_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_KB_EN, HIGH);
|
||||
io.pinMode(EXPANDS_SD_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_SD_EN, HIGH);
|
||||
io.pinMode(EXPANDS_GPIO_EN, OUTPUT);
|
||||
io.digitalWrite(EXPANDS_GPIO_EN, HIGH);
|
||||
io.pinMode(EXPANDS_SD_PULLEN, INPUT);
|
||||
}
|
||||
@@ -42,3 +42,21 @@ void initVariant()
|
||||
pinMode(PIN_LED3, OUTPUT);
|
||||
ledOff(PIN_LED3);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
for (int pin = 0; pin < 48; pin++) {
|
||||
if (pin == SX126X_BUSY || pin == PIN_SPI_SCK || pin == SX126X_DIO1 || pin == PIN_SPI_MOSI || pin == PIN_SPI_MISO ||
|
||||
pin == SX126X_CS || pin == SX126X_RESET || pin == PIN_NFC1 || pin == PIN_NFC2 || pin == PIN_BUTTON1 ||
|
||||
pin == PIN_BUTTON2) {
|
||||
continue;
|
||||
}
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, LOW);
|
||||
if (pin >= 32) {
|
||||
NRF_P1->DIRCLR = (1 << (pin - 32));
|
||||
} else {
|
||||
NRF_GPIO->DIRCLR = (1 << pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
@@ -36,3 +37,10 @@ void initVariant()
|
||||
pinMode(PIN_LED1, OUTPUT);
|
||||
ledOff(PIN_LED1);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_BUTTON1);
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
@@ -36,3 +37,10 @@ void initVariant()
|
||||
pinMode(PIN_LED1, OUTPUT);
|
||||
ledOff(PIN_LED1);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_BUTTON1);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ No longer populated on PCB
|
||||
|
||||
// The bluetooth transmit power on the nRF52840 is adjustable from -20dB to +8dB in steps of 4dB
|
||||
// so NRF52_BLE_TX_POWER can be set to -20, -16, -12, -8, -4, 0 (default), 4, and 8.
|
||||
//#define NRF52_BLE_TX_POWER 8
|
||||
// #define NRF52_BLE_TX_POWER 8
|
||||
|
||||
/*
|
||||
* GPS pins
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
@@ -38,3 +39,10 @@ void initVariant()
|
||||
digitalWrite(PIN_SCREEN_VDD_CTL, LOW); // Start with power on
|
||||
#endif
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_BUTTON1);
|
||||
}
|
||||
@@ -20,4 +20,11 @@ void initVariant()
|
||||
pinMode(PIN_WD_EN, OUTPUT);
|
||||
digitalWrite(PIN_WD_EN, HIGH); // Enable the Watchdog at boot
|
||||
#endif
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
#ifdef PIN_WD_EN
|
||||
digitalWrite(PIN_WD_EN, LOW);
|
||||
#endif
|
||||
}
|
||||
@@ -43,3 +43,11 @@ void initVariant()
|
||||
// pinMode(PIN_3V3_EN, OUTPUT);
|
||||
// digitalWrite(PIN_3V3_EN, HIGH);
|
||||
}
|
||||
|
||||
void earlyInitVariant()
|
||||
{
|
||||
pinMode(DCDC_EN_HOLD, OUTPUT);
|
||||
digitalWrite(DCDC_EN_HOLD, HIGH);
|
||||
pinMode(NRF_ON, OUTPUT);
|
||||
digitalWrite(NRF_ON, HIGH);
|
||||
}
|
||||
|
||||
@@ -42,4 +42,21 @@ void initVariant()
|
||||
// 3V3 Power Rail
|
||||
pinMode(PIN_3V3_EN, OUTPUT);
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
// GPIO restores input status, otherwise there will be leakage current
|
||||
nrf_gpio_cfg_default(TFT_BL);
|
||||
nrf_gpio_cfg_default(TFT_DC);
|
||||
nrf_gpio_cfg_default(TFT_CS);
|
||||
nrf_gpio_cfg_default(TFT_SCLK);
|
||||
nrf_gpio_cfg_default(TFT_MOSI);
|
||||
nrf_gpio_cfg_default(TFT_MISO);
|
||||
nrf_gpio_cfg_default(SCREEN_TOUCH_INT);
|
||||
nrf_gpio_cfg_default(WB_I2C1_SCL);
|
||||
nrf_gpio_cfg_default(WB_I2C1_SDA);
|
||||
|
||||
// nrf_gpio_cfg_default(WB_I2C2_SCL);
|
||||
// nrf_gpio_cfg_default(WB_I2C2_SDA);
|
||||
}
|
||||
@@ -42,3 +42,13 @@ void initVariant()
|
||||
pinMode(PIN_LED3, OUTPUT);
|
||||
ledOff(PIN_LED3);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
// To power off the T-Echo, the display must be set
|
||||
// as an input pin; otherwise, there will be leakage current.
|
||||
pinMode(PIN_EINK_CS, INPUT);
|
||||
pinMode(PIN_EINK_DC, INPUT);
|
||||
pinMode(PIN_EINK_RES, INPUT);
|
||||
pinMode(PIN_EINK_BUSY, INPUT);
|
||||
}
|
||||
Reference in New Issue
Block a user