Thinknode M3 support against master (#8630)

* Add variant_shutdown() as a week function in main-nrf52.cpp

* Add Status LED module

* Add Thinknode M3 support

* Catch case of BLE disabled

* Update src/modules/StatusLEDModule.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/modules/StatusLEDModule.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update variants/nrf52840/ELECROW-ThinkNode-M3/rfswitch.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove unused pin

* M3 pairing LED only active for 30 seconds after state change

* Thinknode M3 shutdown work

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jonathan Bennett
2025-11-24 16:35:54 -06:00
committed by GitHub
parent 1bfa9ed4c4
commit ed4a798c60
14 changed files with 471 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
[env:thinknode_m3]
extends = nrf52840_base
board = ThinkNode-M3
board_check = true
debug_tool = jlink
build_flags =
${nrf52840_base.build_flags}
-Ivariants/nrf52840/ELECROW-ThinkNode-M3
-DELECROW_ThinkNode_M3
-DGPS_POWER_TOGGLE
-D CONFIG_NFCT_PINS_AS_GPIOS=1
-L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard"
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/ELECROW-ThinkNode-M3>
lib_deps =
${nrf52840_base.lib_deps}
khoih-prog/nRF52_PWM@^1.0.1
lewisxhe/PCF8563_Library@^1.0.1

View File

@@ -0,0 +1,15 @@
#include "RadioLib.h"
#include "nrf.h"
// set RF switch configuration for ELECROW ThinkNode M3
// ELECROW ThinkNode M3 uses DIO5 and DIO6 for RF switching
static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}},
{LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}},
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
};

View File

@@ -0,0 +1,93 @@
/*
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 "meshUtils.h"
#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
const uint32_t g_ADigitalPinMap[] = {
// P0
0, 1, 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(KEY_POWER, OUTPUT);
digitalWrite(KEY_POWER, HIGH);
pinMode(RGB_POWER, OUTPUT);
digitalWrite(RGB_POWER, HIGH);
pinMode(green_LED_PIN, OUTPUT);
digitalWrite(green_LED_PIN, LED_STATE_OFF);
pinMode(LED_BLUE, OUTPUT);
pinMode(PIN_POWER_USB, INPUT);
pinMode(PIN_POWER_DONE, INPUT);
pinMode(PIN_POWER_CHRG, INPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(EEPROM_POWER, OUTPUT);
digitalWrite(EEPROM_POWER, HIGH);
pinMode(PIN_EN1, OUTPUT);
digitalWrite(PIN_EN1, HIGH);
pinMode(PIN_EN2, OUTPUT);
digitalWrite(PIN_EN2, HIGH);
pinMode(ACC_POWER, OUTPUT);
digitalWrite(ACC_POWER, LOW);
pinMode(DHT_POWER, OUTPUT);
digitalWrite(DHT_POWER, HIGH);
pinMode(Battery_POWER, OUTPUT);
digitalWrite(Battery_POWER, HIGH);
pinMode(GPS_POWER, OUTPUT);
digitalWrite(GPS_POWER, HIGH);
}
// called from main-nrf52.cpp during the cpuDeepSleep() function
void variant_shutdown()
{
digitalWrite(EEPROM_POWER, LOW);
digitalWrite(KEY_POWER, LOW);
for (int pin = 0; pin < 48; pin++) {
if (pin == PIN_POWER_USB || pin == BUTTON_PIN || pin == PIN_EN1 || pin == PIN_EN2 || pin == DHT_POWER ||
pin == ACC_POWER || pin == Battery_POWER || pin == GPS_POWER || pin == LR1110_SPI_MISO_PIN ||
pin == LR1110_SPI_MOSI_PIN || pin == LR1110_SPI_SCK_PIN || pin == LR1110_SPI_NSS_PIN || pin == LR1110_BUSY_PIN ||
pin == LR1110_NRESET_PIN || pin == LR1110_IRQ_PIN || pin == GPS_TX_PIN || pin == GPS_RX_PIN || pin == green_LED_PIN ||
pin == red_LED_PIN || pin == LED_BLUE) {
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(BUTTON_PIN, 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(BUTTON_PIN, sense1);
nrf_gpio_cfg_input(PIN_POWER_USB, NRF_GPIO_PIN_PULLDOWN); // Configure the pin to be woken up as an input
nrf_gpio_pin_sense_t sense2 = NRF_GPIO_PIN_SENSE_HIGH;
nrf_gpio_cfg_sense_set(PIN_POWER_USB, sense2);
}

View File

@@ -0,0 +1,122 @@
/*
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_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "WVariant.h"
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
#define ELECROW_ThinkNode_M3 1
// 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)
// Power Pin
#define NRF_APM
#define GPS_POWER 14
#define PIN_POWER_USB 31
#define EXT_PWR_DETECT PIN_POWER_USB
#define PIN_POWER_DONE 24
#define PIN_POWER_CHRG 32
#define KEY_POWER 16
#define ACC_POWER 2
#define DHT_POWER 3
#define Battery_POWER 17
#define RGB_POWER 29
#define EEPROM_POWER 7
// LED
#define red_LED_PIN 33
#define LED_POWER red_LED_PIN
#define LED_CHARGE LED_POWER // Signals the Status LED Module to handle this LED
#define green_LED_PIN 35
#define LED_BLUE 37
#define LED_PAIRING LED_BLUE // Signals the Status LED Module to handle this LED
#define LED_BUILTIN -1
#define LED_STATE_ON LOW
#define LED_STATE_OFF HIGH
// BUZZER
#define PIN_BUZZER 23
#define PIN_EN1 36
#define PIN_EN2 34
/*Wire Interfaces*/
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA 26
#define PIN_WIRE_SCL 27
// Temperature correction for sensor
#define AHT10_TEMP_OFFSET -5.0
/*GPS pins*/
#define HAS_GPS 1
#define GPS_BAUDRATE 9600
#define PIN_GPS_RESET 25
#define PIN_GPS_STANDBY 21
#define GPS_TX_PIN 20
#define GPS_RX_PIN 22
#define GPS_THREAD_INTERVAL 50
#define PIN_SERIAL1_RX GPS_TX_PIN
#define PIN_SERIAL1_TX GPS_RX_PIN
// Button
#define BUTTON_PIN 12
#define BUTTON_PIN_ALT (0 + 12)
// Battery
#define BATTERY_PIN 5
#define BATTERY_SENSE_RESOLUTION_BITS 12
#define BATTERY_SENSE_RESOLUTION 4096.0
#undef AREF_VOLTAGE
#define AREF_VOLTAGE 2.4
#define VBAT_AR_INTERNAL AR_INTERNAL_2_4
#define ADC_MULTIPLIER (1.75)
/*SPI Interfaces*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (32 + 15) // P1.15 47
#define PIN_SPI_MOSI (32 + 14) // P1.14 46
#define PIN_SPI_SCK (32 + 13) // P1.13 45
#define PIN_SPI_NSS (32 + 12) // P1.12 44
/*LORA Interfaces*/
#define USE_LR1110
#define LR1110_IRQ_PIN 40
#define LR1110_NRESET_PIN 42
#define LR1110_BUSY_PIN 43
#define LR1110_SPI_NSS_PIN 44
#define LR1110_SPI_SCK_PIN 45
#define LR1110_SPI_MOSI_PIN 46
#define LR1110_SPI_MISO_PIN 47
#define LR11X0_DIO3_TCXO_VOLTAGE 3.3
#define LR11X0_DIO_AS_RF_SWITCH
// PCF8563 RTC Module
#define PCF8563_RTC 0x51
#ifdef __cplusplus
}
#endif
#endif