Add Elecrow ThinkNode M8 board support (thinknode_m8) (#11226)
* Add Elecrow ThinkNode M8 variant scaffold (thinknode_m8) nRF52840 + SX1262 + 2.4" e-paper + ATGM336H-5NR32 GPS. All pins resolved from ThinkNode_M8_V0.3.sch; cross-checked against meshtastic/firmware#9181 (Elecrow V0.1 reference). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add Elecrow ThinkNode M8 board support (nRF52840/SX1262, 1.54in e-ink, ATGM336H GNSS, SC7A20, EC04 encoder) * Address review: keep the stored backlight level out of blanking, match only the SC7A20 WHO_AM_I byte, and transfer detents atomically * Use std::atomic for the press-and-turn detent counter so native builds compile * Drop the ThinkNode M8 LED_BUILTIN redefinition that warned on every translation unit --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
GitHub
claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Claude Sonnet 4.6
parent
84322af4e0
commit
597f6767b5
@@ -0,0 +1,41 @@
|
||||
; First prototype eink/nrf52840/sx1262 device
|
||||
[env:thinknode_m8]
|
||||
custom_meshtastic_support_level = 1
|
||||
custom_meshtastic_images = thinknode_m8.svg
|
||||
custom_meshtastic_tags = Elecrow
|
||||
custom_meshtastic_hw_model = 130
|
||||
custom_meshtastic_hw_model_slug = THINKNODE_M8
|
||||
custom_meshtastic_architecture = nrf52840
|
||||
custom_meshtastic_display_name = Elecrow ThinkNode M8
|
||||
custom_meshtastic_actively_supported = true
|
||||
|
||||
extends = nrf52840_base
|
||||
board = ThinkNode-M8
|
||||
board_check = true
|
||||
debug_tool = jlink
|
||||
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
||||
build_flags =
|
||||
${nrf52840_base.build_flags}
|
||||
-I variants/nrf52840/ELECROW-ThinkNode-M8
|
||||
-D ELECROW_ThinkNode_M8
|
||||
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
|
||||
-D EINK_WIDTH=200
|
||||
-D EINK_HEIGHT=200
|
||||
-D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk
|
||||
-D EINK_LIMIT_FASTREFRESH=20 ; How many consecutive fast-refreshes are permitted //20
|
||||
-D EINK_LIMIT_RATE_BACKGROUND_SEC=10 ; Minimum interval between BACKGROUND updates //30
|
||||
-D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates
|
||||
-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
|
||||
build_src_filter =
|
||||
${nrf52_base.build_src_filter}
|
||||
+<../variants/nrf52840/ELECROW-ThinkNode-M8>
|
||||
lib_deps =
|
||||
${nrf52840_base.lib_deps}
|
||||
# renovate: datasource=git-refs depName=meshtastic-GxEPD2 packageName=https://github.com/meshtastic/GxEPD2 gitBranch=master
|
||||
https://github.com/meshtastic/GxEPD2/archive/c7eb4c3c167cf396ef4f541cc5d4c6aa42f3c46b.zip
|
||||
# renovate: datasource=custom.pio depName=nRF52_PWM packageName=khoih-prog/library/nRF52_PWM
|
||||
khoih-prog/nRF52_PWM@1.0.1
|
||||
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
|
||||
lewisxhe/SensorLib@0.3.4
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "main.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
#include <Wire.h>
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
// P0 - pins 0 and 1 are hardwired for xtal and should never be enabled
|
||||
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
|
||||
// P1
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
pinMode(I2C_EN, OUTPUT);
|
||||
digitalWrite(I2C_EN, HIGH);
|
||||
pinMode(VCC_ELNK_EN, OUTPUT);
|
||||
digitalWrite(VCC_ELNK_EN, HIGH);
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, HIGH);
|
||||
pinMode(ADC_EN, OUTPUT);
|
||||
digitalWrite(ADC_EN, HIGH);
|
||||
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
auto dispdev = screen->getDisplayDevice();
|
||||
dispdev->resetDisplay();
|
||||
screen->forceDisplay();
|
||||
delay(500);
|
||||
digitalWrite(I2C_EN, LOW);
|
||||
digitalWrite(VCC_ELNK_EN, LOW);
|
||||
digitalWrite(PIN_GPS_EN, LOW);
|
||||
digitalWrite(ADC_EN, LOW);
|
||||
for (int pin = 0; pin < 48; pin++) {
|
||||
if (pin == I2C_EN || pin == VCC_ELNK_EN || pin == PIN_GPS_EN || pin == ADC_EN || pin == PIN_BUTTON1 ||
|
||||
pin == SX1262_SPI_NSS_PIN || pin == SX1262_SPI_SCK_PIN || pin == SX1262_SPI_MOSI_PIN || pin == SX1262_SPI_MISO_PIN ||
|
||||
pin == SX1262_IRQ_PIN || pin == SX1262_NRESET_PIN || pin == SX126X_BUSY) {
|
||||
continue;
|
||||
}
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, LOW);
|
||||
if (pin >= 32) {
|
||||
NRF_P1->DIRCLR = (1 << (pin - 32));
|
||||
} else {
|
||||
NRF_GPIO->DIRCLR = (1 << pin);
|
||||
}
|
||||
}
|
||||
nrf_gpio_cfg_input(PIN_BUTTON1, NRF_GPIO_PIN_PULLUP); // Configure the pin to be woken up as an input
|
||||
nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW;
|
||||
nrf_gpio_cfg_sense_set(PIN_BUTTON1, sense1);
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
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_ELECROW_EINK_V1_0_
|
||||
#define _VARIANT_ELECROW_EINK_V1_0_
|
||||
|
||||
/** 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 (1)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
#define PIN_NFC1 (9)
|
||||
#define PIN_NFC2 (10)
|
||||
|
||||
#define CANNED_MESSAGE_MODULE_ENABLE 1
|
||||
|
||||
/*Power*/
|
||||
#define I2C_EN (0 + 13)
|
||||
#define VCC_ELNK_EN (32 + 10)
|
||||
#define PIN_GPS_EN (0 + 16) // active high
|
||||
#define ADC_EN (32 + 8)
|
||||
|
||||
/*Buttons*/
|
||||
#define HAS_BUTTON 1
|
||||
#define PIN_BUTTON_E (0 + 12)
|
||||
#define PIN_BUTTON_EC04_A (0 + 8)
|
||||
#define PIN_BUTTON_EC04_B (32 + 9)
|
||||
#define PIN_BUTTON_EC04 (0 + 6)
|
||||
#define PIN_BUTTON1 PIN_BUTTON_E
|
||||
// Press and turn the encoder to dim the frontlight
|
||||
#define INPUTDRIVER_PRESS_AND_TURN_CW INPUT_BROKER_MSG_BRIGHTNESS_UP
|
||||
#define INPUTDRIVER_PRESS_AND_TURN_CCW INPUT_BROKER_MSG_BRIGHTNESS_DOWN
|
||||
|
||||
/*LED*/
|
||||
#define PIN_LED1 -1
|
||||
#define LED_STATE_ON HIGH // State when LED is lit
|
||||
#define LED_BLUE PIN_LED1
|
||||
|
||||
/*BUZZER*/
|
||||
#define PIN_BUZZER (32 + 1)
|
||||
|
||||
/*USB_CHECK*/
|
||||
// Reference only: sits on a divider from VBUS, too near the input threshold to read
|
||||
// digitally. USB presence comes from USBREGSTATUS instead.
|
||||
#define USB_VBUS (32 + 3)
|
||||
|
||||
/*CHARGE_CHECK*/
|
||||
// Reference only: link resistors and pull-ups unpopulated on V0.3, so these never reach the MCU.
|
||||
#define CHRG (32 + 5)
|
||||
#define DONE (32 + 6)
|
||||
|
||||
/*Wire Interfaces*/
|
||||
// Found by the I2C scan: PCF8563 RTC at 0x51, SC7A20 accelerometer at 0x19.
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
#define PIN_WIRE_SDA (0 + 26)
|
||||
#define PIN_WIRE_SCL (0 + 27)
|
||||
|
||||
/*GPS*/
|
||||
// ATGM336H-5NR32. Probes as GNSS_MODEL_MTK; both branches speak CASIC $PCAS.
|
||||
#define HAS_GPS 1
|
||||
#define GPS_BAUDRATE 9600
|
||||
#define PIN_GPS_RESET (0 + 17)
|
||||
#define PIN_GPS_STANDBY (0 + 15) // An output to wake GPS, low means allow sleep, high means force wake
|
||||
#define PIN_GPS_PPS (0 + 14) // 1PPS output, configured as an input by GPS.cpp
|
||||
#define PIN_SERIAL1_RX (32 + 2)
|
||||
#define PIN_SERIAL1_TX (32 + 4)
|
||||
#define GPS_TX_PIN PIN_SERIAL1_TX
|
||||
#define GPS_RX_PIN PIN_SERIAL1_RX
|
||||
#define GPS_THREAD_INTERVAL 50
|
||||
|
||||
/*FLASH*/
|
||||
#define PIN_QSPI_CS (32 + 15)
|
||||
#define PIN_QSPI_SCK (32 + 14)
|
||||
#define PIN_QSPI_IO0 (32 + 12) // MOSI if using two bit interface
|
||||
#define PIN_QSPI_IO1 (32 + 13) // MISO if using two bit interface
|
||||
#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)
|
||||
#define EXTERNAL_FLASH_DEVICES MX25R1635F
|
||||
#define EXTERNAL_FLASH_USE_QSPI
|
||||
|
||||
/*SPI*/
|
||||
#define SPI_INTERFACES_COUNT 2
|
||||
#define PIN_SPI_NSS (0 + 21)
|
||||
#define PIN_SPI_SCK (0 + 19)
|
||||
#define PIN_SPI_MOSI (0 + 20)
|
||||
#define PIN_SPI_MISO (0 + 22)
|
||||
|
||||
#define PIN_SPI1_NSS (0 + 30)
|
||||
#define PIN_SPI1_SCK (0 + 31)
|
||||
#define PIN_SPI1_MOSI (0 + 29)
|
||||
#define PIN_SPI1_MISO -1
|
||||
/*EINK*/
|
||||
#define MESHTASTIC_USE_EINK_UI 1
|
||||
#define USE_EINK 1
|
||||
#define PIN_EINK_CS PIN_SPI1_NSS
|
||||
#define PIN_EINK_SCLK PIN_SPI1_SCK
|
||||
#define PIN_EINK_MOSI PIN_SPI1_MOSI
|
||||
#define PIN_EINK_BUSY (0 + 3)
|
||||
#define PIN_EINK_DC (0 + 28)
|
||||
#define PIN_EINK_RES (0 + 2)
|
||||
// Panel supply is VCC_ELNK_EN; P1.11 is the dimmable frontlight. No PIN_EINK_EN on this board.
|
||||
#define PIN_PWM_BACKLIGHT (32 + 11)
|
||||
#define PWM_BACKLIGHT_DEFAULT 128
|
||||
#define PWM_BACKLIGHT_MIN 8
|
||||
#define PWM_BACKLIGHT_MAX 248
|
||||
#define PWM_BACKLIGHT_STEP 20
|
||||
|
||||
/*Lora radio*/
|
||||
#define USE_SX1262
|
||||
// PE4259 /CTRL pad, held high for single-pin mode; the SX1262 selects the path from DIO2.
|
||||
#define SX126X_ANT_SW (0 + 23)
|
||||
#define SX126X_RESET (0 + 24) // RST
|
||||
#define SX126X_DIO1 (0 + 25) // IRQ
|
||||
#define SX126X_DIO2 (32 + 0) // BUSY
|
||||
#define SX126X_SCK PIN_SPI_SCK
|
||||
#define SX126X_MISO PIN_SPI_MISO
|
||||
#define SX126X_MOSI PIN_SPI_MOSI
|
||||
#define SX126X_CS PIN_SPI_NSS
|
||||
|
||||
#define SX1262_IRQ_PIN SX126X_DIO1
|
||||
#define SX1262_NRESET_PIN SX126X_RESET
|
||||
#define SX126X_BUSY SX126X_DIO2
|
||||
#define SX1262_SPI_NSS_PIN SX126X_CS
|
||||
#define SX1262_SPI_SCK_PIN SX126X_SCK
|
||||
#define SX1262_SPI_MOSI_PIN SX126X_MOSI
|
||||
#define SX1262_SPI_MISO_PIN SX126X_MISO
|
||||
#define SX126X_DIO2_AS_RF_SWITCH
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 3.3
|
||||
|
||||
/*Serial*/
|
||||
#define SERIAL_PRINT_PORT 0 // USB CDC is the StreamAPI transport; no secondary UART
|
||||
|
||||
/*RTC*/
|
||||
#define PCF8563_RTC 0x51
|
||||
|
||||
/*Battert*/
|
||||
#define BATTERY_PIN (0 + 4)
|
||||
#define ADC_V (0 + 4)
|
||||
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
||||
#define BATTERY_SENSE_RESOLUTION 4096.0
|
||||
#define BATTERY_SENSE_SAMPLES 100
|
||||
#undef AREF_VOLTAGE
|
||||
#define AREF_VOLTAGE 2.4
|
||||
#define VBAT_AR_INTERNAL AR_INTERNAL_2_4
|
||||
#define ADC_MULTIPLIER (1.75)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user