variant.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * variant.h
  3. * Copyright (C) 2023 Seeed K.K.
  4. * MIT License
  5. */
  6. #pragma once
  7. #define _PINNUM(port, pin) ((port) * 32 + (pin))
  8. #include "WVariant.h"
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // Low frequency clock source
  11. #define USE_LFXO // 32.768 kHz crystal oscillator
  12. #define VARIANT_MCK (64000000ul)
  13. #define WIRE_INTERFACES_COUNT (1)
  14. ////////////////////////////////////////////////////////////////////////////////
  15. // Power
  16. #define PIN_PWR_EN _PINNUM(0, 30) // RT9080_EN
  17. #define BATTERY_PIN _PINNUM(0, 2)
  18. #define ADC_MULTIPLIER (2.0F)
  19. #define ADC_RESOLUTION (14)
  20. #define BATTERY_SENSE_RES (12)
  21. #define AREF_VOLTAGE (3.0)
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // Number of pins
  24. #define PINS_COUNT (48)
  25. #define NUM_DIGITAL_PINS (48)
  26. #define NUM_ANALOG_INPUTS (1)
  27. #define NUM_ANALOG_OUTPUTS (0)
  28. ////////////////////////////////////////////////////////////////////////////////
  29. // UART pin definition
  30. #define PIN_SERIAL1_RX PIN_GPS_TX
  31. #define PIN_SERIAL1_TX PIN_GPS_RX
  32. ////////////////////////////////////////////////////////////////////////////////
  33. // I2C pin definition
  34. #define PIN_WIRE_SDA _PINNUM(1, 4) // (SDA) - per LilyGo IIC_1_SDA
  35. #define PIN_WIRE_SCL _PINNUM(1, 2) // (SCL) - per LilyGo IIC_1_SCL
  36. ////////////////////////////////////////////////////////////////////////////////
  37. // SPI pin definition
  38. #define SPI_INTERFACES_COUNT (2)
  39. #define PIN_SPI_MISO _PINNUM(0, 17) // (MISO)
  40. #define PIN_SPI_MOSI _PINNUM(0, 15) // (MOSI)
  41. #define PIN_SPI_SCK _PINNUM(0, 13) // (SCK)
  42. #define PIN_SPI_NSS (-1)
  43. ////////////////////////////////////////////////////////////////////////////////
  44. // QSPI FLASH
  45. #define PIN_QSPI_SCK _PINNUM(0, 4)
  46. #define PIN_QSPI_CS _PINNUM(0, 12)
  47. #define PIN_QSPI_IO0 _PINNUM(0, 6)
  48. #define PIN_QSPI_IO1 _PINNUM(0, 8)
  49. #define PIN_QSPI_IO2 _PINNUM(1, 9)
  50. #define PIN_QSPI_IO3 _PINNUM(0, 26)
  51. #define EXTERNAL_FLASH_DEVICES ZD25WQ32CEIGR
  52. #define EXTERNAL_FLASH_USE_QSPI
  53. ////////////////////////////////////////////////////////////////////////////////
  54. // Builtin LEDs
  55. #define LED_RED _PINNUM(1, 14) // LED_3
  56. #define LED_BLUE _PINNUM(1, 5) // LED_2
  57. #define LED_GREEN _PINNUM(1, 7) // LED_1
  58. //#define PIN_STATUS_LED LED_BLUE
  59. #define LED_BUILTIN (-1)
  60. #define LED_PIN LED_BUILTIN
  61. #define LED_STATE_ON LOW
  62. ////////////////////////////////////////////////////////////////////////////////
  63. // Builtin buttons
  64. #define PIN_BUTTON1 _PINNUM(0, 24) // BOOT
  65. #define BUTTON_PIN PIN_BUTTON1
  66. #define PIN_USER_BTN BUTTON_PIN
  67. #define PIN_BUTTON2 _PINNUM(0, 18)
  68. #define BUTTON_PIN2 PIN_BUTTON2
  69. #define EXTERNAL_FLASH_DEVICES MX25R1635F
  70. #define EXTERNAL_FLASH_USE_QSPI
  71. ////////////////////////////////////////////////////////////////////////////////
  72. // Lora
  73. #define USE_SX1262
  74. #define LORA_CS _PINNUM(0, 11)
  75. #define SX126X_POWER_EN _PINNUM(0, 30)
  76. #define SX126X_DIO1 _PINNUM(1, 8)
  77. #define SX126X_BUSY _PINNUM(0, 14)
  78. #define SX126X_RESET _PINNUM(0, 7)
  79. #define SX126X_RF_VC1 _PINNUM(0, 27)
  80. #define SX126X_RF_VC2 _PINNUM(0, 33)
  81. #define P_LORA_DIO_1 SX126X_DIO1
  82. #define P_LORA_NSS LORA_CS
  83. #define P_LORA_RESET SX126X_RESET
  84. #define P_LORA_BUSY SX126X_BUSY
  85. #define P_LORA_SCLK PIN_SPI_SCK
  86. #define P_LORA_MISO PIN_SPI_MISO
  87. #define P_LORA_MOSI PIN_SPI_MOSI
  88. ////////////////////////////////////////////////////////////////////////////////
  89. // SPI1
  90. #define PIN_SPI1_MISO (-1) // Not used for Display
  91. #define PIN_SPI1_MOSI _PINNUM(0, 20)
  92. #define PIN_SPI1_SCK _PINNUM(0, 19)
  93. // GxEPD2 needs that for a panel that is not even used !
  94. extern const int MISO;
  95. extern const int MOSI;
  96. extern const int SCK;
  97. ////////////////////////////////////////////////////////////////////////////////
  98. // Display
  99. // #define DISP_MISO (-1) // Not used for Display
  100. #define DISP_MOSI _PINNUM(0, 20)
  101. #define DISP_SCLK _PINNUM(0, 19)
  102. #define DISP_CS _PINNUM(0, 22)
  103. #define DISP_DC _PINNUM(0, 21)
  104. #define DISP_RST _PINNUM(0, 28)
  105. #define DISP_BUSY _PINNUM(0, 3)
  106. #define DISP_POWER _PINNUM(1, 12)
  107. // #define DISP_BACKLIGHT (-1) // Display has no backlight
  108. #define PIN_DISPLAY_CS DISP_CS
  109. #define PIN_DISPLAY_DC DISP_DC
  110. #define PIN_DISPLAY_RST DISP_RST
  111. #define PIN_DISPLAY_BUSY DISP_BUSY
  112. ////////////////////////////////////////////////////////////////////////////////
  113. // GPS — per LilyGo t_echo_lite_config.h
  114. // PIN_GPS_TX/RX named from GPS module's perspective
  115. #define PIN_GPS_TX _PINNUM(0, 29) // GPS UART TX → MCU RX
  116. #define PIN_GPS_RX _PINNUM(1, 10) // GPS UART RX ← MCU TX
  117. #define GPS_EN _PINNUM(1, 11) // GPS RT9080 power enable
  118. #define PIN_GPS_STANDBY _PINNUM(1, 13) // GPS wake-up
  119. #define PIN_GPS_PPS _PINNUM(1, 15) // GPS 1PPS