* Seeed Tracker X1 Support * silence CPPCheck * fix macro order regression and adapt stm32hal for new radiolib * STM32 is a radiolib upstream fix ( https://github.com/jgromes/RadioLib/issues/1825 ) * fix STM32 regression * Seeed Tracker X1 Support * silence CPPCheck * fix macro order regression and adapt stm32hal for new radiolib * STM32 is a radiolib upstream fix ( https://github.com/jgromes/RadioLib/issues/1825 ) * fix STM32 regression * address copilot OCD * Split behavior only when the two LEDs are on distinct pins. * bring naming in line with the other seeed devices * update env name to fit convention too * guarantee evaluation order * Guard sensor readings against null values, make sensor use less power
173 lines
5.2 KiB
C
173 lines
5.2 KiB
C
/*
|
|
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
|
|
*/
|
|
|
|
#ifndef _VARIANT_MESH_TRACKER_X1_
|
|
#define _VARIANT_MESH_TRACKER_X1_
|
|
|
|
/** 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
|
|
|
|
// Number of pins defined in PinDescription array
|
|
#define PINS_COUNT (48)
|
|
#define NUM_DIGITAL_PINS (48)
|
|
#define NUM_ANALOG_INPUTS (6)
|
|
#define NUM_ANALOG_OUTPUTS (0)
|
|
|
|
// Use the native nrf52 usb power detection
|
|
#define NRF_APM
|
|
|
|
// PIN_3V3_EN use in deep sleep , as power pin.
|
|
#define PIN_3V3_EN (32 + 7) // P1.7, Power to Sensors
|
|
#define PIN_BAT_ADC_EN (32 + 6) // P1.6, Power to battery ADC
|
|
#define PIN_RTC_EN (0 + 9) // P0.9, Power to RTC
|
|
|
|
#define PIN_LED1 (0 + 3) // P0.3, red led
|
|
#define PIN_LED2 (0 + 24) // P0.24, green led
|
|
#define PIN_LED3 (0 + 28) // P0.28, blue led
|
|
#define LED_POWER PIN_LED2
|
|
#define LED_RED PIN_LED1
|
|
#define LED_BLUE -1 // Actually green
|
|
#define LED_STATE_ON 1 // State when LED is lit
|
|
#define LED_POWER_CRITICAL LED_RED // red LED doubles as the low-battery/critical indicator
|
|
|
|
// ARCH_NRF52 auto define HAS_BUTTON 1
|
|
#define HAS_BUTTON 1
|
|
#define BUTTON_PIN (0 + 6) // P0.06
|
|
#define BUTTON_ACTIVE_LOW false
|
|
#define BUTTON_ACTIVE_PULLUP false
|
|
#define BUTTON_SENSE_TYPE 0x5 // enable input pull-down
|
|
|
|
/**************** Sensor *******************/
|
|
|
|
#define HAS_WIRE 1
|
|
#define WIRE_INTERFACES_COUNT 1 // have 1 I2C interface, Wire
|
|
|
|
#define PIN_WIRE_SDA (32 + 15) // P1.15
|
|
#define PIN_WIRE_SCL (32 + 14) // P1.14
|
|
#define I2C_NO_RESCAN // I2C is a bit finicky, don't scan too much
|
|
|
|
#define HAS_DRV2605 1 // haptic driver
|
|
#define DRV2605_USE_LRA
|
|
#define PIN_DRV_EN (32 + 5) // P1.05, Power to haptic driver
|
|
|
|
#define HAS_SPA06 1
|
|
|
|
/*
|
|
* Serial interfaces
|
|
*/
|
|
#define PIN_SERIAL1_RX (0 + 14) // P0.14
|
|
#define PIN_SERIAL1_TX (0 + 13) // P0.13
|
|
|
|
#define PIN_SERIAL2_RX (0 + 17) // P0.17
|
|
#define PIN_SERIAL2_TX (0 + 16) // P0.16
|
|
|
|
#define SPI_INTERFACES_COUNT 1
|
|
|
|
#define PIN_SPI_MISO (32 + 8) // P1.08
|
|
#define PIN_SPI_MOSI (32 + 9) // P1.09
|
|
#define PIN_SPI_SCK (0 + 11) // P0.11
|
|
#define PIN_SPI_NSS (0 + 12) // P0.12
|
|
|
|
#define LORA_RESET (32 + 10) // P1.10 // RST
|
|
#define LORA_DIO1 (32 + 1) // P1.01 // IRQ
|
|
#define LORA_DIO2 (0 + 7) // P0.07 // BUSY
|
|
#define LORA_SCK PIN_SPI_SCK
|
|
#define LORA_MISO PIN_SPI_MISO
|
|
#define LORA_MOSI PIN_SPI_MOSI
|
|
#define LORA_CS PIN_SPI_NSS
|
|
|
|
// supported modules list
|
|
#define USE_LR2021
|
|
#define IRQ_DIO_NUM 8
|
|
|
|
#define LR2021_IRQ_PIN LORA_DIO1
|
|
#define LR2021_NRESET_PIN LORA_RESET
|
|
#define LR2021_BUSY_PIN LORA_DIO2
|
|
#define LR2021_SPI_NSS_PIN LORA_CS
|
|
#define LR2021_SPI_SCK_PIN LORA_SCK
|
|
#define LR2021_SPI_MOSI_PIN LORA_MOSI
|
|
#define LR2021_SPI_MISO_PIN LORA_MISO
|
|
|
|
#define LR2021_DIO3_TCXO_VOLTAGE 1.6
|
|
// #define LR2021_DIO_AS_RF_SWITCH
|
|
|
|
// GPS
|
|
#define HAS_GPS 1
|
|
#define GNSS_AIROHA
|
|
#define GPS_RX_PIN PIN_SERIAL1_RX
|
|
#define GPS_TX_PIN PIN_SERIAL1_TX
|
|
|
|
#define GPS_BAUDRATE 115200
|
|
#define GPS_PROBETRIES 8
|
|
|
|
#define PIN_GPS_EN (32 + 11) // P1.11
|
|
#define GPS_EN_ACTIVE HIGH
|
|
|
|
#define PIN_GPS_RESET (0 + 8) // P0.8
|
|
#define GPS_RESET_MODE HIGH
|
|
|
|
#define GPS_VRTC_EN (32 + 13) // P1.13, always high
|
|
#define GPS_SLEEP_INT (0 + 30) // P0.30, always high
|
|
#define GPS_RTC_INT (0 + 29) // P0.29, normal is LOW, wake by HIGH
|
|
|
|
#define BATTERY_PIN 2 // P0.02/AIN0, BAT_ADC
|
|
#define BATTERY_IMMUTABLE
|
|
#define ADC_MULTIPLIER (2.0F)
|
|
// P0.04/AIN2 is VCC_ADC, P0.05/AIN3 is CHARGER_DET, P1.03 is CHARGE_STA, P1.04 is CHARGE_DONE
|
|
|
|
#define EXT_CHRG_DETECT (32 + 3) // P1.03
|
|
#define EXT_CHRG_DETECT_VALUE LOW
|
|
// #define EXT_IS_CHRGD (32 + 4) // P1.04
|
|
// #define EXT_IS_CHRGD_VALUE LOW
|
|
#define EXT_PWR_DETECT (0 + 5) // P0.05
|
|
|
|
#define ADC_RESOLUTION 14
|
|
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
|
|
|
#undef AREF_VOLTAGE
|
|
#define AREF_VOLTAGE 3.0
|
|
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
|
|
|
#define OCV_ARRAY 4290, 4118, 4002, 3889, 3798, 3728, 3677, 3643, 3594, 3500, 3100
|
|
|
|
// Buzzer
|
|
#define PIN_BUZZER (0 + 25) // P0.25, pwm output
|
|
|
|
#define HAS_SCREEN 0
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
/*----------------------------------------------------------------------------
|
|
* Arduino objects - C++ only
|
|
*----------------------------------------------------------------------------*/
|
|
|
|
#endif // _VARIANT_MESH_TRACKER_X1_
|