variant.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // LilyGo T-Beam-1W variant.h
  2. // Configuration based on Meshtastic PR #8967 and LilyGO documentation
  3. #pragma once
  4. // I2C for OLED display (SH1106 at 0x3C)
  5. #define I2C_SDA 8
  6. #define I2C_SCL 9
  7. // GPS - Quectel L76K
  8. // GNSS_TXD (IO5) = GPS transmits → MCU RX (setPins rxPin)
  9. // GNSS_RXD (IO6) = GPS receives → MCU TX (setPins txPin)
  10. #define PIN_GPS_TX 5 // MCU receives from GPS TX
  11. #define PIN_GPS_RX 6 // MCU transmits to GPS RX
  12. #define PIN_GPS_PPS 7 // GPS PPS output
  13. #define PIN_GPS_EN 16 // GPS wake-up/enable (GPS_EN_PIN in LilyGO code)
  14. #define HAS_GPS 1
  15. #define GPS_BAUDRATE 9600
  16. // Buttons
  17. #define BUTTON_PIN 0 // BUTTON 1 (boot)
  18. #define BUTTON_PIN_ALT 17 // BUTTON 2
  19. // SPI (shared by LoRa and SD)
  20. #define SPI_MOSI 11
  21. #define SPI_SCK 13
  22. #define SPI_MISO 12
  23. #define SPI_CS 10
  24. // SD Card
  25. #define HAS_SDCARD
  26. #define SDCARD_USE_SPI1
  27. #define SDCARD_CS SPI_CS
  28. // LoRa Radio - SX1262 with 1W PA
  29. #define USE_SX1262
  30. #define LORA_SCK SPI_SCK
  31. #define LORA_MISO SPI_MISO
  32. #define LORA_MOSI SPI_MOSI
  33. #define LORA_CS 15
  34. #define LORA_RESET 3
  35. #define LORA_DIO1 1
  36. #define LORA_BUSY 38
  37. // CRITICAL: Radio power enable - MUST be HIGH before lora.begin()!
  38. // GPIO 40 powers the SX1262 + PA module via LDO
  39. #define SX126X_POWER_EN 40
  40. #ifdef USE_SX1262
  41. #define SX126X_CS LORA_CS
  42. #define SX126X_DIO1 LORA_DIO1
  43. #define SX126X_BUSY LORA_BUSY
  44. #define SX126X_RESET LORA_RESET
  45. // RF switching configuration for 1W PA module
  46. // DIO2 controls PA (via SX126X_DIO2_AS_RF_SWITCH)
  47. // CTRL PIN (GPIO 21) controls LNA - must be HIGH during RX
  48. // Truth table: DIO2=1,CTRL=0 -> TX (PA on, LNA off)
  49. // DIO2=0,CTRL=1 -> RX (PA off, LNA on)
  50. #define SX126X_DIO2_AS_RF_SWITCH
  51. #define SX126X_RXEN 21 // LNA enable - HIGH during RX
  52. // TCXO voltage - required for radio init
  53. #define SX126X_DIO3_TCXO_VOLTAGE 3.0
  54. #define SX126X_MAX_POWER 22
  55. #endif
  56. // LED
  57. #define LED_PIN 18
  58. #define LED_STATE_ON 1 // HIGH = ON
  59. // Battery ADC
  60. #define BATTERY_PIN 4
  61. #define ADC_CHANNEL ADC1_GPIO4_CHANNEL
  62. #define BATTERY_SENSE_SAMPLES 30
  63. #define ADC_MULTIPLIER 3.0
  64. // NTC temperature sensor
  65. #define NTC_PIN 14
  66. // Fan control
  67. #define FAN_CTRL_PIN 41
  68. // PA Ramp Time - T-Beam 1W requires >800us stabilization (default is 200us)
  69. // Value 0x05 = RADIOLIB_SX126X_PA_RAMP_800U
  70. #define SX126X_PA_RAMP_US 0x05
  71. // Display - SH1106 OLED (128x64)
  72. #define USE_SH1106
  73. #define OLED_WIDTH 128
  74. #define OLED_HEIGHT 64
  75. // 32768 Hz crystal present
  76. #define HAS_32768HZ 1