2021-01-16 01:57:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
|
|
|
|
Copyright (c) 2016 Sandeep Mistry All right reserved.
|
|
|
|
Copyright (c) 2018, Adafruit Industries (adafruit.com)
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2021-01-16 03:42:06 +00:00
|
|
|
#ifndef _VARIANT_TTGO_EINK_V1_0_
|
|
|
|
#define _VARIANT_TTGO_EINK_V1_0_
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
/** Master clock frequency */
|
|
|
|
#define VARIANT_MCK (64000000ul)
|
|
|
|
|
|
|
|
#define USE_LFXO // Board uses 32khz crystal for LF
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Headers
|
|
|
|
*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "WVariant.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif // __cplusplus
|
|
|
|
|
2021-04-29 01:51:10 +00:00
|
|
|
#define TTGO_T_ECHO
|
|
|
|
|
2021-01-16 01:57:55 +00:00
|
|
|
// Number of pins defined in PinDescription array
|
|
|
|
#define PINS_COUNT (48)
|
|
|
|
#define NUM_DIGITAL_PINS (48)
|
|
|
|
#define NUM_ANALOG_INPUTS (1)
|
|
|
|
#define NUM_ANALOG_OUTPUTS (0)
|
|
|
|
|
|
|
|
// LEDs
|
2024-03-03 14:55:52 +00:00
|
|
|
#define PIN_LED1 (0 + 14) // 13 red (confirmed on 1.0 board)
|
|
|
|
// Unused(by firmware) LEDs:
|
2024-03-03 15:33:18 +00:00
|
|
|
#define PIN_LED2 (0 + 15) // 14 blue
|
|
|
|
#define PIN_LED3 (0 + 13) // 15 green
|
2021-01-16 01:57:55 +00:00
|
|
|
|
2024-03-03 15:46:36 +00:00
|
|
|
#define LED_RED PIN_LED3
|
|
|
|
#define LED_BLUE PIN_LED1
|
|
|
|
#define LED_GREEN PIN_LED2
|
|
|
|
|
|
|
|
#define LED_BUILTIN LED_BLUE
|
|
|
|
#define LED_CONN PIN_GREEN
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
#define LED_STATE_ON 0 // State when LED is lit
|
|
|
|
#define LED_INVERTED 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Buttons
|
|
|
|
*/
|
|
|
|
#define PIN_BUTTON1 (32 + 10)
|
2023-01-21 13:34:29 +00:00
|
|
|
#define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO
|
2022-01-07 06:57:29 +00:00
|
|
|
#define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Analog pins
|
|
|
|
*/
|
|
|
|
#define PIN_A0 (4) // Battery ADC
|
|
|
|
|
|
|
|
#define BATTERY_PIN PIN_A0
|
|
|
|
|
|
|
|
static const uint8_t A0 = PIN_A0;
|
|
|
|
|
|
|
|
#define ADC_RESOLUTION 14
|
|
|
|
|
|
|
|
#define PIN_NFC1 (9)
|
|
|
|
#define PIN_NFC2 (10)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Serial interfaces
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
No longer populated on PCB
|
|
|
|
*/
|
2023-09-24 04:45:35 +00:00
|
|
|
// #define PIN_SERIAL2_RX (0 + 6)
|
|
|
|
// #define PIN_SERIAL2_TX (0 + 8)
|
|
|
|
// #define PIN_SERIAL2_EN (0 + 17)
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Wire Interfaces
|
|
|
|
*/
|
|
|
|
#define WIRE_INTERFACES_COUNT 1
|
|
|
|
|
2021-01-16 02:34:46 +00:00
|
|
|
#define PIN_WIRE_SDA (26)
|
2021-01-16 01:57:55 +00:00
|
|
|
#define PIN_WIRE_SCL (27)
|
|
|
|
|
|
|
|
/* touch sensor, active high */
|
|
|
|
|
|
|
|
#define TP_SER_IO (0 + 11)
|
|
|
|
|
|
|
|
#define PIN_RTC_INT (0 + 16) // Interrupt from the PCF8563 RTC
|
|
|
|
|
|
|
|
/*
|
|
|
|
External serial flash WP25R1635FZUIL0
|
|
|
|
*/
|
|
|
|
|
|
|
|
// QSPI Pins
|
|
|
|
#define PIN_QSPI_SCK (32 + 14)
|
|
|
|
#define PIN_QSPI_CS (32 + 15)
|
|
|
|
#define PIN_QSPI_IO0 (32 + 12) // MOSI if using two bit interface
|
|
|
|
#define PIN_QSPI_IO1 (32 + 13) // MISO if using two bit interface
|
2023-01-21 13:34:29 +00:00
|
|
|
#define PIN_QSPI_IO2 (0 + 7) // WP if using two bit interface (i.e. not used)
|
|
|
|
#define PIN_QSPI_IO3 (0 + 5) // HOLD if using two bit interface (i.e. not used)
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
// On-board QSPI Flash
|
|
|
|
#define EXTERNAL_FLASH_DEVICES MX25R1635F
|
|
|
|
#define EXTERNAL_FLASH_USE_QSPI
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lora radio
|
|
|
|
*/
|
|
|
|
|
2021-10-14 05:19:50 +00:00
|
|
|
#define USE_SX1262
|
2022-08-29 12:26:17 +00:00
|
|
|
#define USE_SX1268
|
2021-09-11 21:35:16 +00:00
|
|
|
#define SX126X_CS (0 + 24) // FIXME - we really should define LORA_CS instead
|
|
|
|
#define SX126X_DIO1 (0 + 20)
|
2021-01-16 01:57:55 +00:00
|
|
|
// Note DIO2 is attached internally to the module to an analog switch for TX/RX switching
|
|
|
|
#define SX1262_DIO3 \
|
|
|
|
(0 + 21) // This is used as an *output* from the sx1262 and connected internally to power the tcxo, do not drive from the main
|
|
|
|
// CPU?
|
2021-09-11 21:35:16 +00:00
|
|
|
#define SX126X_BUSY (0 + 17)
|
|
|
|
#define SX126X_RESET (0 + 25)
|
2023-09-27 21:01:40 +00:00
|
|
|
// Not really an E22 but TTGO seems to be trying to clone that
|
|
|
|
#define SX126X_DIO2_AS_RF_SWITCH
|
|
|
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
2021-01-16 01:57:55 +00:00
|
|
|
// Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface
|
|
|
|
// code)
|
|
|
|
|
2021-03-10 07:24:00 +00:00
|
|
|
// #define LORA_DISABLE_SENDING // Define this to disable transmission for testing (power testing etc...)
|
|
|
|
|
2021-09-11 21:35:16 +00:00
|
|
|
// #undef SX126X_CS
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* eink display pins
|
|
|
|
*/
|
|
|
|
|
2021-01-16 03:42:06 +00:00
|
|
|
#define PIN_EINK_EN (32 + 11) // Note: this is really just backlight power
|
2021-01-16 01:57:55 +00:00
|
|
|
#define PIN_EINK_CS (0 + 30)
|
|
|
|
#define PIN_EINK_BUSY (0 + 3)
|
|
|
|
#define PIN_EINK_DC (0 + 28)
|
|
|
|
#define PIN_EINK_RES (0 + 2)
|
|
|
|
#define PIN_EINK_SCLK (0 + 31)
|
|
|
|
#define PIN_EINK_MOSI (0 + 29) // also called SDI
|
|
|
|
|
2024-03-09 02:15:37 +00:00
|
|
|
// Controls power for all peripherals (eink + GPS + LoRa + Sensor)
|
|
|
|
#define PIN_POWER_EN (0 + 12)
|
|
|
|
#define PIN_POWER_EN1 (0 + 13)
|
2021-01-16 01:57:55 +00:00
|
|
|
|
2022-07-31 12:11:47 +00:00
|
|
|
#define USE_EINK
|
2021-01-16 01:57:55 +00:00
|
|
|
|
|
|
|
#define PIN_SPI1_MISO \
|
|
|
|
(32 + 7) // FIXME not really needed, but for now the SPI code requires something to be defined, pick an used GPIO
|
|
|
|
#define PIN_SPI1_MOSI PIN_EINK_MOSI
|
|
|
|
#define PIN_SPI1_SCK PIN_EINK_SCLK
|
|
|
|
|
|
|
|
/*
|
2022-03-29 11:11:16 +00:00
|
|
|
* GPS pins
|
2021-01-16 01:57:55 +00:00
|
|
|
*/
|
|
|
|
|
2022-10-05 12:59:07 +00:00
|
|
|
#define GPS_L76K
|
|
|
|
#define PIN_GPS_REINIT (32 + 5) // An output to reset L76K GPS. As per datasheet, low for > 100ms will reset the L76K
|
|
|
|
|
2023-09-24 04:45:35 +00:00
|
|
|
#define PIN_GPS_STANDBY (32 + 2) // An output to wake GPS, low means allow sleep, high means force wake
|
2021-01-16 02:34:46 +00:00
|
|
|
// Seems to be missing on this new board
|
|
|
|
// #define PIN_GPS_PPS (32 + 4) // Pulse per second input from the GPS
|
2023-01-21 13:34:29 +00:00
|
|
|
#define PIN_GPS_TX (32 + 9) // This is for bits going TOWARDS the CPU
|
|
|
|
#define PIN_GPS_RX (32 + 8) // This is for bits going TOWARDS the GPS
|
2021-01-16 01:57:55 +00:00
|
|
|
|
2022-04-02 10:52:50 +00:00
|
|
|
#define GPS_THREAD_INTERVAL 50
|
|
|
|
|
2021-01-16 01:57:55 +00:00
|
|
|
#define PIN_SERIAL1_RX PIN_GPS_TX
|
|
|
|
#define PIN_SERIAL1_TX PIN_GPS_RX
|
|
|
|
|
2022-04-28 06:18:03 +00:00
|
|
|
// PCF8563 RTC Module
|
|
|
|
#define PCF8563_RTC 0x51
|
|
|
|
|
2021-01-16 01:57:55 +00:00
|
|
|
/*
|
|
|
|
* SPI Interfaces
|
|
|
|
*/
|
|
|
|
#define SPI_INTERFACES_COUNT 2
|
|
|
|
|
|
|
|
// For LORA, spi 0
|
|
|
|
#define PIN_SPI_MISO (0 + 23)
|
|
|
|
#define PIN_SPI_MOSI (0 + 22)
|
|
|
|
#define PIN_SPI_SCK (0 + 19)
|
|
|
|
|
2021-01-28 02:30:24 +00:00
|
|
|
#define PIN_PWR_EN (0 + 6)
|
|
|
|
|
2021-01-16 01:57:55 +00:00
|
|
|
// To debug via the segger JLINK console rather than the CDC-ACM serial device
|
|
|
|
// #define USE_SEGGER
|
|
|
|
|
2021-08-10 08:07:40 +00:00
|
|
|
// Battery
|
|
|
|
// The battery sense is hooked to pin A0 (4)
|
|
|
|
// it is defined in the anlaolgue pin section of this file
|
|
|
|
// and has 12 bit resolution
|
|
|
|
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
|
|
|
#define BATTERY_SENSE_RESOLUTION 4096.0
|
|
|
|
// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
|
|
|
|
#define VBAT_MV_PER_LSB (0.73242188F)
|
|
|
|
// Voltage divider value => 100K + 100K voltage divider on VBAT = (100K / (100K + 100K))
|
|
|
|
#define VBAT_DIVIDER (0.5F)
|
|
|
|
// Compensation factor for the VBAT divider
|
2024-01-29 12:14:21 +00:00
|
|
|
#define VBAT_DIVIDER_COMP (2.0F)
|
2021-08-10 08:07:40 +00:00
|
|
|
// Fixed calculation of milliVolt from compensation value
|
|
|
|
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
|
|
|
|
#undef AREF_VOLTAGE
|
|
|
|
#define AREF_VOLTAGE 3.0
|
|
|
|
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
2023-01-21 13:34:29 +00:00
|
|
|
#define ADC_MULTIPLIER VBAT_DIVIDER_COMP
|
2021-08-10 08:07:40 +00:00
|
|
|
#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x)
|
|
|
|
|
2022-07-31 12:11:47 +00:00
|
|
|
#define HAS_RTC 1
|
|
|
|
|
2021-01-16 01:57:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Arduino objects - C++ only
|
|
|
|
*----------------------------------------------------------------------------*/
|
|
|
|
|
2024-03-03 15:33:18 +00:00
|
|
|
#endif
|