2020-02-01 16:30:53 +00:00
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
TTGO T-BEAM Tracker for The Things Network
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
|
|
|
|
|
|
|
|
|
|
This code requires LMIC library by Matthijs Kooijman
|
|
|
|
|
https://github.com/matthijskooijman/arduino-lmic
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Version
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-02-19 00:18:01 +00:00
|
|
|
|
// If app version is not specified we assume we are not being invoked by the build script
|
2020-02-14 22:00:08 +00:00
|
|
|
|
#ifndef APP_VERSION
|
2020-12-10 03:28:15 +00:00
|
|
|
|
#error APP_VERSION must be set by the build environment
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If app version is not specified we assume we are not being invoked by the build script
|
|
|
|
|
#ifndef HW_VERSION
|
|
|
|
|
#error HW_VERSION, and HW_VERSION_countryname must be set by the build environment
|
2020-02-14 22:00:08 +00:00
|
|
|
|
#endif
|
2020-02-19 00:18:01 +00:00
|
|
|
|
|
2020-02-01 16:30:53 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Configuration
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-02-04 04:18:36 +00:00
|
|
|
|
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
|
2020-02-06 06:13:27 +00:00
|
|
|
|
// we don't support jtag on the ttgo - access to gpio 12 is a PITA
|
2020-03-27 20:20:52 +00:00
|
|
|
|
#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2
|
2020-02-07 05:26:40 +00:00
|
|
|
|
//#define USE_JTAG
|
2020-02-06 06:13:27 +00:00
|
|
|
|
#endif
|
2020-02-04 04:18:36 +00:00
|
|
|
|
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-05-13 00:57:51 +00:00
|
|
|
|
/// Convert a preprocessor name into a quoted string
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define xstr(s) str(s)
|
|
|
|
|
#define str(s) #s
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-05-13 00:57:51 +00:00
|
|
|
|
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
|
|
|
|
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
|
|
|
|
|
2020-09-04 22:03:22 +00:00
|
|
|
|
#ifdef PORTDUINO
|
|
|
|
|
|
|
|
|
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
|
|
|
|
|
2020-09-05 00:23:17 +00:00
|
|
|
|
#elif defined(NRF52_SERIES) // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
|
2020-09-06 23:09:07 +00:00
|
|
|
|
// board specific
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
//
|
|
|
|
|
// Standard definitions for NRF52 targets
|
|
|
|
|
//
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
2020-03-20 03:15:51 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
// We bind to the GPS using variant.h instead for this platform (Serial1)
|
2020-04-15 03:22:27 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
|
2020-07-10 04:27:34 +00:00
|
|
|
|
|
|
|
|
|
// If the variant filed defines as standard button
|
|
|
|
|
#ifdef PIN_BUTTON1
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#define BUTTON_PIN PIN_BUTTON1
|
2020-07-10 21:37:01 +00:00
|
|
|
|
#endif
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-09-28 20:10:27 +00:00
|
|
|
|
#ifdef PIN_BUTTON2
|
|
|
|
|
#define BUTTON_PIN_ALT PIN_BUTTON2
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
|
2020-06-06 00:30:09 +00:00
|
|
|
|
#elif defined(CubeCell_BoardPlus)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Standard definitions for CubeCell targets
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
|
|
|
|
|
2020-06-17 00:01:50 +00:00
|
|
|
|
#define LED_PIN -1 // FIXME totally bogus
|
|
|
|
|
#define BUTTON_PIN -1
|
2020-06-06 00:30:09 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Standard definitions for ESP32 targets
|
|
|
|
|
//
|
2020-02-01 16:30:53 +00:00
|
|
|
|
|
2020-09-18 17:48:39 +00:00
|
|
|
|
#define HAS_WIFI
|
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#define GPS_SERIAL_NUM 1
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define GPS_RX_PIN 34
|
2020-02-04 04:18:36 +00:00
|
|
|
|
#ifdef USE_JTAG
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define GPS_TX_PIN -1
|
2020-02-04 04:18:36 +00:00
|
|
|
|
#else
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define GPS_TX_PIN 12
|
2020-02-01 16:30:53 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// LoRa SPI
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-07-10 21:37:01 +00:00
|
|
|
|
// NRF52 boards will define this in variant.h
|
|
|
|
|
#ifndef RF95_SCK
|
2020-07-10 18:02:29 +00:00
|
|
|
|
#define RF95_SCK 5
|
|
|
|
|
#define RF95_MISO 19
|
|
|
|
|
#define RF95_MOSI 27
|
|
|
|
|
#define RF95_NSS 18
|
2020-07-10 21:37:01 +00:00
|
|
|
|
#endif
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#endif
|
2020-09-05 00:23:17 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Standard definitions for !ESP32 targets
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifdef NO_ESP32
|
|
|
|
|
// Nop definition for these attributes - not used on NRF52
|
|
|
|
|
#define EXT_RAM_ATTR
|
|
|
|
|
#define IRAM_ATTR
|
|
|
|
|
#define RTC_DATA_ATTR
|
|
|
|
|
#endif
|
2020-05-10 19:33:17 +00:00
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// OLED
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#define SSD1306_ADDRESS 0x3C
|
2020-10-23 10:00:43 +00:00
|
|
|
|
#define ST7567_ADDRESS 0x3F
|
2020-05-10 19:33:17 +00:00
|
|
|
|
|
2020-06-14 08:28:23 +00:00
|
|
|
|
// The SH1106 controller is almost, but not quite, the same as SSD1306
|
|
|
|
|
// Define this if you know you have that controller or your "SSD1306" misbehaves.
|
|
|
|
|
//#define USE_SH1106
|
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
// Flip the screen upside down by default as it makes more sense on T-BEAM
|
|
|
|
|
// devices. Comment this out to not rotate screen 180 degrees.
|
2020-10-24 00:16:15 +00:00
|
|
|
|
#define SCREEN_FLIP_VERTICALLY
|
2020-05-10 19:33:17 +00:00
|
|
|
|
|
2020-10-24 00:16:15 +00:00
|
|
|
|
// Define if screen should be mirrored left to right
|
|
|
|
|
// #define SCREEN_MIRROR
|
2020-05-10 19:33:17 +00:00
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// GPS
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#define GPS_BAUDRATE 9600
|
|
|
|
|
|
2020-03-28 22:31:22 +00:00
|
|
|
|
#if defined(TBEAM_V10)
|
2020-02-24 19:21:34 +00:00
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TBEAM
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-03-15 01:48:15 +00:00
|
|
|
|
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
|
|
|
|
|
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define I2C_SDA 21
|
|
|
|
|
#define I2C_SCL 22
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-06-25 16:45:21 +00:00
|
|
|
|
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
|
|
|
|
|
#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-10-06 00:20:06 +00:00
|
|
|
|
#define LED_INVERTED 1
|
|
|
|
|
#define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4
|
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
|
|
|
|
// not found then probe for SX1262
|
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define USE_SX1262
|
|
|
|
|
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 23
|
|
|
|
|
#define LORA_DIO1 33 // SX1262 IRQ
|
|
|
|
|
#define LORA_DIO2 32 // SX1262 BUSY
|
|
|
|
|
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SX1262
|
2021-09-11 21:35:16 +00:00
|
|
|
|
#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead
|
|
|
|
|
#define SX126X_DIO1 LORA_DIO1
|
|
|
|
|
#define SX126X_BUSY LORA_DIO2
|
|
|
|
|
#define SX126X_RESET LORA_RESET
|
|
|
|
|
#define SX126X_E22 // Not really an E22 but TTGO seems to be trying to clone that
|
2020-08-20 22:42:36 +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)
|
2020-02-05 23:37:58 +00:00
|
|
|
|
#endif
|
2020-02-12 17:13:49 +00:00
|
|
|
|
|
2020-10-06 04:45:19 +00:00
|
|
|
|
// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts
|
|
|
|
|
// and waking from light sleep
|
|
|
|
|
// #define PMU_IRQ 35
|
2020-04-24 21:55:51 +00:00
|
|
|
|
#define AXP192_SLAVE_ADDRESS 0x34
|
|
|
|
|
|
2020-03-28 22:31:22 +00:00
|
|
|
|
#elif defined(TBEAM_V07)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TBEAM0p7
|
2020-03-28 22:31:22 +00:00
|
|
|
|
|
|
|
|
|
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
|
|
|
|
|
|
|
|
|
|
#define I2C_SDA 21
|
|
|
|
|
#define I2C_SCL 22
|
|
|
|
|
|
|
|
|
|
#define BUTTON_PIN 39
|
2020-08-14 02:55:57 +00:00
|
|
|
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
2020-03-28 22:31:22 +00:00
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 23
|
|
|
|
|
#define LORA_DIO1 33 // Not really used
|
|
|
|
|
#define LORA_DIO2 32 // Not really used
|
2020-03-28 22:31:22 +00:00
|
|
|
|
|
|
|
|
|
// This board has different GPS pins than all other boards
|
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
2020-07-03 05:41:22 +00:00
|
|
|
|
#define GPS_RX_PIN 12
|
|
|
|
|
#define GPS_TX_PIN 15
|
2020-03-28 22:31:22 +00:00
|
|
|
|
|
2021-09-19 13:05:21 +00:00
|
|
|
|
#elif defined(DIY_V1)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_DIY_V1
|
|
|
|
|
|
|
|
|
|
// For OLED LCD
|
|
|
|
|
#define I2C_SDA 21
|
|
|
|
|
#define I2C_SCL 22
|
|
|
|
|
|
2021-09-24 21:28:01 +00:00
|
|
|
|
// GPS
|
2021-10-08 18:17:05 +00:00
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#define GPS_RX_PIN 15
|
|
|
|
|
//#undef GPS_TX_PIN
|
|
|
|
|
//#define GPS_TX_PIN 12 // not connected
|
2021-09-24 21:28:01 +00:00
|
|
|
|
|
2021-09-19 13:05:21 +00:00
|
|
|
|
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
|
|
|
|
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
|
|
|
|
#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268
|
|
|
|
|
#define LORA_DIO1 33 // IRQ for SX1262/SX1268
|
|
|
|
|
#define LORA_DIO2 32 // BUSY for SX1262/SX1268
|
|
|
|
|
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled
|
|
|
|
|
|
|
|
|
|
#define RF95_SCK 5
|
|
|
|
|
#define RF95_MISO 19
|
|
|
|
|
#define RF95_MOSI 27
|
|
|
|
|
#define RF95_NSS 18
|
|
|
|
|
|
|
|
|
|
// supported modules list
|
|
|
|
|
#define USE_SX1262
|
|
|
|
|
#define USE_SX1268
|
|
|
|
|
|
|
|
|
|
// common pinouts for SX126X modules
|
|
|
|
|
#define SX126X_CS 18 // NSS for SX126X
|
|
|
|
|
#define SX126X_DIO1 LORA_DIO1
|
|
|
|
|
#define SX126X_BUSY LORA_DIO2
|
|
|
|
|
#define SX126X_RESET LORA_RESET
|
|
|
|
|
#define SX126X_RXEN 14
|
|
|
|
|
#define SX126X_TXEN 13
|
|
|
|
|
|
|
|
|
|
#ifdef EBYTE_E22
|
|
|
|
|
// Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch
|
|
|
|
|
// (which is the default for the sx1262interface code)
|
|
|
|
|
#define SX126X_E22
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-27 20:20:52 +00:00
|
|
|
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
2020-02-04 04:18:36 +00:00
|
|
|
|
|
2020-06-15 17:38:15 +00:00
|
|
|
|
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
|
2020-06-17 00:01:50 +00:00
|
|
|
|
// Tested on Neo6m module.
|
2020-06-15 17:38:15 +00:00
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
|
|
|
|
#define GPS_RX_PIN 36
|
|
|
|
|
#define GPS_TX_PIN 37
|
|
|
|
|
|
2020-03-27 23:55:19 +00:00
|
|
|
|
#ifndef USE_JTAG // gpio15 is TDO for JTAG, so no I2C on this board while doing jtag
|
|
|
|
|
#define I2C_SDA 4 // I2C pins for this board
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define I2C_SCL 15
|
2020-02-04 15:31:32 +00:00
|
|
|
|
#endif
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-03-27 23:55:19 +00:00
|
|
|
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
2020-03-27 23:55:19 +00:00
|
|
|
|
#define LED_PIN 25 // If defined we will blink this LED
|
|
|
|
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
2020-02-01 22:23:21 +00:00
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
2020-02-05 23:37:58 +00:00
|
|
|
|
#ifndef USE_JTAG
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define LORA_RESET 14
|
2020-02-05 23:37:58 +00:00
|
|
|
|
#endif
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define LORA_DIO1 35 // Not really used
|
|
|
|
|
#define LORA_DIO2 34 // Not really used
|
|
|
|
|
|
2021-05-11 01:44:41 +00:00
|
|
|
|
// ratio of voltage divider = 3.20 (R1=100k, R2=220k)
|
|
|
|
|
#define ADC_MULTIPLIER 3.2
|
|
|
|
|
|
|
|
|
|
#ifdef HELTEC_V2_0
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
|
|
|
|
|
|
|
|
|
#define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HELTEC_V2_1
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
|
|
|
|
|
|
|
|
|
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-07-14 14:16:49 +00:00
|
|
|
|
#elif defined(TLORA_V1)
|
2020-03-27 23:55:19 +00:00
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V1
|
2020-06-24 10:15:50 +00:00
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
|
|
|
|
#define GPS_RX_PIN 36
|
|
|
|
|
#define GPS_TX_PIN 37
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
2020-04-10 00:44:15 +00:00
|
|
|
|
#define I2C_SDA 4 // I2C pins for this board
|
|
|
|
|
#define I2C_SCL 15
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
|
|
|
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
|
|
|
|
|
|
|
|
|
// #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
|
|
|
|
#define LED_PIN 2 // If defined we will blink this LED
|
|
|
|
|
#define BUTTON_PIN 0 // If defined, this will be used for user button presses
|
2020-09-08 17:25:37 +00:00
|
|
|
|
#define BUTTON_NEED_PULLUP
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 14
|
|
|
|
|
#define LORA_DIO1 35 // Not really used
|
|
|
|
|
#define LORA_DIO2 34 // Not really used
|
2020-07-17 19:06:57 +00:00
|
|
|
|
|
2020-07-14 14:16:49 +00:00
|
|
|
|
#elif defined(TLORA_V2)
|
2020-03-27 23:55:19 +00:00
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V2
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
2020-06-25 16:45:21 +00:00
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
|
|
|
|
#define GPS_RX_PIN 36
|
|
|
|
|
#define GPS_TX_PIN 13 // per @eugene
|
|
|
|
|
|
2020-12-28 07:00:34 +00:00
|
|
|
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
|
|
|
|
|
2020-04-10 00:44:15 +00:00
|
|
|
|
#define I2C_SDA 21 // I2C pins for this board
|
|
|
|
|
#define I2C_SCL 22
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
|
|
|
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
|
|
|
|
|
|
|
|
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
2020-03-28 21:45:33 +00:00
|
|
|
|
#define LED_PIN 25 // If defined we will blink this LED
|
|
|
|
|
#define BUTTON_PIN \
|
|
|
|
|
0 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one
|
2020-07-17 19:06:57 +00:00
|
|
|
|
// between this pin and ground
|
2020-09-08 17:25:37 +00:00
|
|
|
|
#define BUTTON_NEED_PULLUP
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 14
|
|
|
|
|
#define LORA_DIO1 35 // Not really used
|
|
|
|
|
#define LORA_DIO2 34 // Not really used
|
2020-07-14 14:16:49 +00:00
|
|
|
|
|
2021-02-03 01:34:50 +00:00
|
|
|
|
#elif defined(TLORA_V1_3)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-21 03:47:48 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V1_1p3
|
2021-02-03 01:34:50 +00:00
|
|
|
|
|
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
|
|
|
|
#define GPS_RX_PIN 36
|
|
|
|
|
#define GPS_TX_PIN 13 // per @eugene
|
|
|
|
|
|
|
|
|
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
|
|
|
|
|
|
|
|
|
#define I2C_SDA 4 // I2C pins for this board
|
|
|
|
|
#define I2C_SCL 15
|
|
|
|
|
|
|
|
|
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
|
|
|
|
|
|
|
|
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
|
|
|
|
#define LED_PIN 25 // If defined we will blink this LED
|
|
|
|
|
#define BUTTON_PIN 36
|
|
|
|
|
#define BUTTON_NEED_PULLUP
|
|
|
|
|
|
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 14
|
|
|
|
|
#define LORA_DIO1 35 // Not really used
|
|
|
|
|
#define LORA_DIO2 34 // Not really used
|
|
|
|
|
|
2020-07-14 14:16:49 +00:00
|
|
|
|
#elif defined(TLORA_V2_1_16)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-19 15:40:41 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V2_1_1p6
|
2020-07-14 14:16:49 +00:00
|
|
|
|
|
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
2021-03-21 10:58:43 +00:00
|
|
|
|
#define GPS_RX_PIN 15 // per @der_bear on the forum, 36 is incorrect for this board type and 15 is a better pick
|
2021-02-16 03:33:35 +00:00
|
|
|
|
#define GPS_TX_PIN 13
|
2020-07-14 14:16:49 +00:00
|
|
|
|
|
2020-08-14 02:55:57 +00:00
|
|
|
|
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
2020-08-13 00:03:36 +00:00
|
|
|
|
|
2020-07-14 14:16:49 +00:00
|
|
|
|
#define I2C_SDA 21 // I2C pins for this board
|
|
|
|
|
#define I2C_SCL 22
|
|
|
|
|
|
|
|
|
|
#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller
|
|
|
|
|
|
|
|
|
|
#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost
|
|
|
|
|
#define LED_PIN 25 // If defined we will blink this LED
|
2021-02-20 08:34:25 +00:00
|
|
|
|
#define BUTTON_PIN 12 // If defined, this will be used for user button presses,
|
2021-02-20 02:19:14 +00:00
|
|
|
|
|
2020-08-26 20:59:15 +00:00
|
|
|
|
#define BUTTON_NEED_PULLUP
|
2020-03-27 23:55:19 +00:00
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 14
|
|
|
|
|
#define LORA_DIO1 35 // Not really used
|
|
|
|
|
#define LORA_DIO2 34 // Not really used
|
|
|
|
|
|
2020-12-29 15:08:11 +00:00
|
|
|
|
#elif defined(GENIEBLOCKS)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
2020-12-29 15:08:11 +00:00
|
|
|
|
#undef GPS_RX_PIN
|
|
|
|
|
#undef GPS_TX_PIN
|
|
|
|
|
#define GPS_RX_PIN 5
|
|
|
|
|
#define GPS_TX_PIN 18
|
|
|
|
|
#define GPS_RESET_N 10
|
|
|
|
|
#define GPS_EXTINT 23 // On MAX-M8 module pin name is EXTINT. On L70 module pin name is STANDBY.
|
|
|
|
|
|
2021-02-20 08:34:25 +00:00
|
|
|
|
#define BATTERY_PIN 39 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
2020-12-29 15:08:11 +00:00
|
|
|
|
#define BATTERY_EN_PIN 14 // Voltage voltage divider enable pin connected to mosfet
|
|
|
|
|
|
|
|
|
|
#define I2C_SDA 4 // I2C pins for this board
|
|
|
|
|
#define I2C_SCL 2
|
|
|
|
|
|
2021-02-20 08:34:25 +00:00
|
|
|
|
#define LED_PIN 12 // If defined we will blink this LED
|
|
|
|
|
//#define BUTTON_PIN 36 // If defined, this will be used for user button presses (ToDo problem on that line on debug screen -->
|
2021-03-19 15:40:41 +00:00
|
|
|
|
// Long press start!) #define BUTTON_NEED_PULLUP //GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal
|
|
|
|
|
// pull-ups or pull-down resistors.
|
2020-12-29 15:08:11 +00:00
|
|
|
|
|
|
|
|
|
#define USE_RF95
|
|
|
|
|
#define LORA_DIO0 38 // a No connect on the SX1262 module
|
|
|
|
|
#define LORA_RESET 9
|
|
|
|
|
|
|
|
|
|
#define RF95_SCK 22
|
|
|
|
|
#define RF95_MISO 19
|
|
|
|
|
#define RF95_MOSI 13
|
|
|
|
|
#define RF95_NSS 21
|
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#endif
|
2020-04-27 14:39:50 +00:00
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#ifdef ARDUINO_NRF52840_PCA10056
|
2020-04-27 14:39:50 +00:00
|
|
|
|
|
2020-04-01 04:56:35 +00:00
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_NRF52840DK
|
2020-04-15 03:22:27 +00:00
|
|
|
|
|
|
|
|
|
// This board uses 0 to be mean LED on
|
|
|
|
|
#undef LED_INVERTED
|
|
|
|
|
#define LED_INVERTED 1
|
|
|
|
|
|
2020-05-10 19:33:17 +00:00
|
|
|
|
#elif defined(ARDUINO_NRF52840_PPR)
|
|
|
|
|
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_PPR
|
2020-05-10 19:33:17 +00:00
|
|
|
|
|
2021-04-12 05:25:55 +00:00
|
|
|
|
#elif defined(RAK4630)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_RAK4631
|
|
|
|
|
|
2021-04-29 01:51:10 +00:00
|
|
|
|
#elif defined(TTGO_T_ECHO)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_T_ECHO
|
|
|
|
|
|
2020-07-10 04:27:34 +00:00
|
|
|
|
#elif NRF52_SERIES
|
|
|
|
|
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
2020-07-10 04:27:34 +00:00
|
|
|
|
|
2020-09-05 19:34:48 +00:00
|
|
|
|
#elif PORTDUINO
|
|
|
|
|
|
2021-03-14 02:48:20 +00:00
|
|
|
|
#define HW_VENDOR HardwareModel_PORTDUINO
|
2020-09-06 23:09:07 +00:00
|
|
|
|
|
|
|
|
|
#define USE_SIM_RADIO
|
2020-09-05 19:34:48 +00:00
|
|
|
|
|
2021-04-22 00:49:05 +00:00
|
|
|
|
// Pine64 uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if
|
2021-04-22 06:28:56 +00:00
|
|
|
|
// not found then probe for SX1262. Currently the RF95 code is disabled because I think the RF95 module won't need to ship.
|
|
|
|
|
// #define USE_RF95
|
2021-04-22 00:49:05 +00:00
|
|
|
|
#define USE_SX1262
|
2020-09-06 23:32:13 +00:00
|
|
|
|
|
|
|
|
|
// Fake SPI device selections
|
|
|
|
|
#define RF95_SCK 5
|
|
|
|
|
#define RF95_MISO 19
|
|
|
|
|
#define RF95_MOSI 27
|
2021-01-02 11:40:24 +00:00
|
|
|
|
#define RF95_NSS RADIOLIB_NC // the ch341f spi controller does CS for us
|
2020-09-06 23:32:13 +00:00
|
|
|
|
|
2021-04-22 00:49:05 +00:00
|
|
|
|
#define LORA_DIO0 26 // a No connect on the SX1262 module
|
2021-04-28 07:11:55 +00:00
|
|
|
|
#define LORA_RESET 14
|
2021-04-22 06:28:56 +00:00
|
|
|
|
#define LORA_DIO1 33 // SX1262 IRQ, called DIO0 on pinelora schematic, pin 7 on ch341f "ack" - FIXME, enable hwints in linux
|
|
|
|
|
#define LORA_DIO2 32 // SX1262 BUSY, actually connected to "DIO5" on pinelora schematic, pin 8 on ch341f "slct"
|
2021-04-22 00:49:05 +00:00
|
|
|
|
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SX1262
|
2021-09-11 21:35:16 +00:00
|
|
|
|
#define SX126X_CS 20 // CS0 on pinelora schematic, hooked to gpio D0 on ch341f
|
|
|
|
|
#define SX126X_DIO1 LORA_DIO1
|
|
|
|
|
#define SX126X_BUSY LORA_DIO2
|
|
|
|
|
#define SX126X_RESET LORA_RESET
|
|
|
|
|
// HOPE RFM90 does not have a TCXO therefore not SX126X_E22
|
2021-04-22 00:49:05 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-01 22:23:21 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-10-06 00:20:06 +00:00
|
|
|
|
// DEBUG LED
|
|
|
|
|
#ifndef LED_INVERTED
|
|
|
|
|
#define LED_INVERTED 0 // define as 1 if LED is active low (on)
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-08-20 22:42:36 +00:00
|
|
|
|
#ifdef USE_RF95
|
|
|
|
|
#define RF95_RESET LORA_RESET
|
|
|
|
|
#define RF95_IRQ LORA_DIO0 // on SX1262 version this is a no connect DIO0
|
|
|
|
|
#define RF95_DIO1 LORA_DIO1 // Note: not really used for RF95
|
|
|
|
|
#define RF95_DIO2 LORA_DIO2 // Note: not really used for RF95
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-04-23 23:20:07 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// DEBUG
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-07-10 20:24:00 +00:00
|
|
|
|
#ifdef CONSOLE_MAX_BAUD
|
|
|
|
|
#define SERIAL_BAUD CONSOLE_MAX_BAUD
|
|
|
|
|
#else
|
2020-04-24 15:05:56 +00:00
|
|
|
|
#define SERIAL_BAUD 921600 // Serial debug baud rate
|
2020-07-10 21:37:01 +00:00
|
|
|
|
#endif
|
2020-04-24 15:05:56 +00:00
|
|
|
|
|
2020-05-22 04:17:53 +00:00
|
|
|
|
#include "SerialConsole.h"
|
|
|
|
|
|
2021-03-24 22:15:15 +00:00
|
|
|
|
#define DEBUG_PORT (*console) // Serial debug port
|
2020-05-22 04:17:53 +00:00
|
|
|
|
|
2020-06-06 00:30:09 +00:00
|
|
|
|
// What platforms should use SEGGER?
|
|
|
|
|
#ifdef NRF52_SERIES
|
2020-07-10 20:11:29 +00:00
|
|
|
|
|
2020-07-15 20:24:57 +00:00
|
|
|
|
// Always include the SEGGER code on NRF52 - because useful for debugging
|
|
|
|
|
#include "SEGGER_RTT.h"
|
|
|
|
|
|
2020-11-12 23:48:25 +00:00
|
|
|
|
// The channel we send stdout data to
|
|
|
|
|
#define SEGGER_STDOUT_CH 0
|
|
|
|
|
|
2020-07-15 20:24:57 +00:00
|
|
|
|
// Debug printing to segger console
|
2020-11-12 23:48:25 +00:00
|
|
|
|
#define SEGGER_MSG(...) SEGGER_RTT_printf(SEGGER_STDOUT_CH, __VA_ARGS__)
|
2020-07-15 20:24:57 +00:00
|
|
|
|
|
2020-08-17 18:50:50 +00:00
|
|
|
|
// If we are not on a NRF52840 (which has built in USB-ACM serial support) and we don't have serial pins hooked up, then we MUST
|
|
|
|
|
// use SEGGER for debug output
|
|
|
|
|
#if !defined(PIN_SERIAL_RX) && !defined(NRF52840_XXAA)
|
2020-07-15 20:24:57 +00:00
|
|
|
|
// No serial ports on this board - ONLY use segger in memory console
|
2020-04-23 23:20:07 +00:00
|
|
|
|
#define USE_SEGGER
|
2020-07-10 21:37:01 +00:00
|
|
|
|
#endif
|
2020-07-10 20:11:29 +00:00
|
|
|
|
|
2020-06-10 21:36:11 +00:00
|
|
|
|
#else
|
|
|
|
|
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
|
2020-04-23 23:20:07 +00:00
|
|
|
|
#endif
|
2020-06-06 00:30:09 +00:00
|
|
|
|
|
2020-04-23 23:20:07 +00:00
|
|
|
|
#ifdef USE_SEGGER
|
|
|
|
|
#define DEBUG_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__)
|
|
|
|
|
#else
|
|
|
|
|
#ifdef DEBUG_PORT
|
2020-12-25 07:17:56 +00:00
|
|
|
|
#define DEBUG_MSG(...) DEBUG_PORT.logDebug(__VA_ARGS__)
|
2020-04-23 23:20:07 +00:00
|
|
|
|
#else
|
|
|
|
|
#define DEBUG_MSG(...)
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-01 16:30:53 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// AXP192 (Rev1-specific options)
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-03-03 16:23:58 +00:00
|
|
|
|
#define GPS_POWER_CTRL_CH 3
|
|
|
|
|
#define LORA_POWER_CTRL_CH 2
|
2020-10-03 21:02:17 +00:00
|
|
|
|
|
|
|
|
|
// Default Bluetooth PIN
|
|
|
|
|
#define defaultBLEPin 123456
|