Compare commits

..

7 Commits

Author SHA1 Message Date
Thomas Göttgens
f8582885bd Merge branch 'master' into moar-nxp 2025-07-13 18:20:07 +02:00
Thomas Göttgens
974ae821d7 Merge branch 'master' into moar-nxp 2025-03-31 09:44:04 +02:00
Thomas Göttgens
4ba7dc21bb Merge branch 'master' into moar-nxp 2025-03-20 21:37:16 +01:00
Austin
c3e7c7843e Merge branch 'master' into moar-nxp 2025-02-15 09:50:33 -05:00
Thomas Göttgens
ccdecbeae2 Merge branch 'master' into moar-nxp 2025-01-19 22:55:39 +01:00
Jonathan Bennett
03cd38929e Add NXP wire define to rak4631 2025-01-05 11:25:41 +01:00
Jonathan Bennett
a5797aceaa Add SE05X library 2025-01-05 11:25:41 +01:00
19 changed files with 32 additions and 226 deletions

View File

@@ -39,6 +39,7 @@ build_flags =
-Isrc/platform/portduino
-DRADIOLIB_EEPROM_UNSUPPORTED
-DPORTDUINO_LINUX_HARDWARE
-DNXP_WIRE=Wire
-DHAS_UDP_MULTICAST
-lpthread
-lstdc++fs

View File

@@ -26,7 +26,6 @@ build_flags = -Wno-missing-field-initializers
-DUSE_THREAD_NAMES
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
-DPB_ENABLE_MALLOC=1
-DRADIOLIB_LOW_LEVEL=1
-DRADIOLIB_EXCLUDE_CC1101=1
-DRADIOLIB_EXCLUDE_NRF24=1
-DRADIOLIB_EXCLUDE_RF69=1
@@ -73,6 +72,8 @@ lib_deps =
nanopb/Nanopb@0.4.91
# renovate: datasource=custom.pio depName=ErriezCRC32 packageName=erriez/library/ErriezCRC32
erriez/ErriezCRC32@1.0.1
https://github.com/meshtastic/SE05X#031f8feccae62689ebbd06914b44bd88547535af
; Used for the code analysis in PIO Home / Inspect
check_tool = cppcheck

View File

@@ -1,8 +1,8 @@
#include "ScanI2CTwoWire.h"
#if !MESHTASTIC_EXCLUDE_I2C
#include "concurrency/LockGuard.h"
#include <SE05X.h>
#if defined(ARCH_PORTDUINO)
#include "linux/LinuxHardwareI2C.h"
#endif
@@ -507,6 +507,10 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
if (len == 5 && memcmp(expectedInfo, info, len) == 0) {
LOG_INFO("NXP SE050 crypto chip found");
type = NXP_SE050;
if (SE05X.begin()) {
LOG_INFO("NXP Random %u", SE05X.random(65535));
LOG_INFO("NXP Serial Number: %s", SE05X.serialNumber().c_str());
}
} else {
LOG_INFO("FT6336U touchscreen found");

View File

@@ -214,8 +214,6 @@ bool pauseBluetoothLogging = false;
bool pmu_found;
uint8_t pa_fan_percentage = 50;
#if !MESHTASTIC_EXCLUDE_I2C
// Array map of sensor types with i2c address and wire as we'll find in the i2c scan
std::pair<uint8_t, TwoWire *> nodeTelemetrySensorsMap[_meshtastic_TelemetrySensorType_MAX + 1] = {};
@@ -1377,36 +1375,16 @@ void setup()
mqttInit();
#endif
#ifdef RADIO_FAN_EN
// Ability to disable FAN if PIN has been set with RADIO_FAN_EN.
#ifdef RF95_FAN_EN
// Ability to disable FAN if PIN has been set with RF95_FAN_EN.
// Make sure LoRa has been started before disabling FAN.
#ifdef RADIO_FAN_PWM
#if defined(ARCH_ESP32)
// Set up PWM at Channel 1 at 25KHz, using 8-bit resolution
// Turn ON/OFF fan to the specified value if enabled by config.
// code by https://github.com/gjelsoe/
if (ledcSetup(1, 25000, 8)) {
ledcAttachPin(RADIO_FAN_EN, 1);
LOG_INFO("PWM init C1 P%d\n", RADIO_FAN_EN);
// Set PWM duty cycle based on fan disabled state
ledcWrite(1, config.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
} else {
LOG_WARN("PWM init fail P%d\n", RADIO_FAN_EN);
}
#elif defined(ARCH_NRF52)
pinMode(RADIO_FAN_EN, OUTPUT);
analogWrite(RADIO_FAN_EN, config.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
#endif
#else
// Set up as ON/OFF switch of fan
pinMode(RADIO_FAN_EN, OUTPUT);
digitalWrite(RADIO_FAN_EN, LOW ^ 0);
#endif
if (config.lora.pa_fan_disabled)
digitalWrite(RF95_FAN_EN, LOW ^ 0);
#endif
#ifndef ARCH_PORTDUINO
// Initialize Wifi
// Initialize Wifi
#if HAS_WIFI
initWifi();
#endif

View File

@@ -78,8 +78,6 @@ extern uint32_t shutdownAtMsec;
extern uint32_t serialSinceMsec;
extern uint8_t pa_fan_percentage;
// If a thread does something that might need for it to be rescheduled ASAP it can set this flag
// This will suppress the current delay and instead try to run ASAP.
extern bool runASAP;

View File

@@ -3,7 +3,6 @@
#include "Throttle.h"
#include "configuration.h"
#include "error.h"
#include "main.h"
#include "mesh/NodeDB.h"
#ifdef LR11X0_DIO_AS_RF_SWITCH
#include "rfswitch.h"
@@ -55,8 +54,6 @@ template <typename T> bool LR11x0Interface<T>::init()
digitalWrite(LR11X0_POWER_EN, HIGH);
#endif
enableFan();
#if ARCH_PORTDUINO
float tcxoVoltage = (float)settingsMap[dio3_tcxo_voltage] / 1000;
// FIXME: correct logic to default to not using TCXO if no voltage is specified for LR11x0_DIO3_TCXO_VOLTAGE

View File

@@ -154,7 +154,10 @@ bool RF95Interface::init()
digitalWrite(RF95_TXEN, 0);
#endif
enableFan();
#ifdef RF95_FAN_EN
pinMode(RF95_FAN_EN, OUTPUT);
digitalWrite(RF95_FAN_EN, 1);
#endif
#ifdef RF95_RXEN
pinMode(RF95_RXEN, OUTPUT);
@@ -327,7 +330,10 @@ bool RF95Interface::sleep()
// put chipset into sleep mode
setStandby(); // First cancel any active receiving/sending
lora->sleep();
disableFan();
#ifdef RF95_FAN_EN
digitalWrite(RF95_FAN_EN, 0);
#endif
return true;
}

View File

@@ -531,37 +531,4 @@ bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
return res == RADIOLIB_ERR_NONE;
}
}
void RadioLibInterface::enableFan()
{
#ifdef RADIO_FAN_EN
#ifdef RADIO_FAN_PWM
#if defined(ARCH_ESP32)
ledcWrite(1, config.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
#elif defined(ARCH_NRF52)
analogWrite(RADIO_FAN_EN, config.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
#endif
#else
pinMode(RADIO_FAN_EN, OUTPUT);
digitalWrite(RADIO_FAN_EN, 1);
#endif
#endif
}
void RadioLibInterface::disableFan()
{
#ifdef RADIO_FAN_EN
#ifdef RADIO_FAN_PWM
#if defined(ARCH_ESP32)
ledcWrite(1, 0);
#elif defined(ARCH_NRF52)
analogWrite(RADIO_FAN_EN, 0);
#endif
#else
pinMode(RADIO_FAN_EN, OUTPUT);
digitalWrite(RADIO_FAN_EN, 0);
#endif
#endif
}

View File

@@ -146,9 +146,6 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
/** Attempt to find a packet in the TxQueue. Returns true if the packet was found. */
virtual bool findInTxQueue(NodeNum from, PacketId id) override;
void enableFan();
void disableFan();
private:
/** if we have something waiting to send, start a short (random) timer so we can come check for collision before actually
* doing the transmit */

View File

@@ -52,8 +52,6 @@ template <typename T> bool SX126xInterface<T>::init()
pinMode(SX126X_POWER_EN, OUTPUT);
#endif
enableFan();
#if ARCH_PORTDUINO
tcxoVoltage = (float)settingsMap[dio3_tcxo_voltage] / 1000;
if (settingsMap[sx126x_ant_sw_pin] != RADIOLIB_NC) {

View File

@@ -35,7 +35,10 @@ template <typename T> bool SX128xInterface<T>::init()
digitalWrite(SX128X_POWER_EN, HIGH);
#endif
enableFan();
#ifdef RF95_FAN_EN
pinMode(RF95_FAN_EN, OUTPUT);
digitalWrite(RF95_FAN_EN, 1);
#endif
#if ARCH_PORTDUINO
if (settingsMap[rxen_pin] != RADIOLIB_NC) {

View File

@@ -706,21 +706,13 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
requiresReboot = false;
}
#ifdef RADIO_FAN_EN
#ifdef RADIO_FAN_PWM
#if defined(ARCH_ESP32)
ledcWrite(1, c.payload_variant.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
#elif defined(ARCH_NFR52)
analogWrite(RADIO_FAN_EN, c.payload_variant.lora.pa_fan_disabled ? 0 : (pa_fan_percentage * 2.55));
#endif
#else
#ifdef RF95_FAN_EN
// Turn PA off if disabled by config
if (c.payload_variant.lora.pa_fan_disabled) {
digitalWrite(RADIO_FAN_EN, LOW ^ 0);
digitalWrite(RF95_FAN_EN, LOW ^ 0);
} else {
digitalWrite(RADIO_FAN_EN, HIGH ^ 0);
digitalWrite(RF95_FAN_EN, HIGH ^ 0);
}
#endif
#endif
config.lora = c.payload_variant.lora;
// If we're setting region for the first time, init the region

View File

@@ -12,7 +12,7 @@
#define LORA_MISO 19
#define LORA_MOSI 23
#define LORA_CS 5
#define RADIO_FAN_EN 17
#define RF95_FAN_EN 17
// #define LED_PIN 16 // This is a LED_WS2812 not a standard LED
#define HAS_NEOPIXEL // Enable the use of neopixels

View File

@@ -46,8 +46,7 @@
FAN is active at 250mW on it's ExpressLRS Firmware.
This FAN has TACHO signal on Pin 27 for use with PWM.
*/
#define RADIO_FAN_EN 2
#define RADIO_FAN_PWM
#define RF95_FAN_EN 2
/*
LED PIN setup and it has a NeoPixel LED.

View File

@@ -32,7 +32,7 @@
This unit has a FAN built-in.
FAN is active at 250mW on it's ExpressLRS Firmware.
*/
#define RADIO_FAN_EN 2
#define RF95_FAN_EN 2
/*
LED PIN setup.

View File

@@ -1,20 +0,0 @@
[env:radiomaster_nomad_gemini]
extends = esp32_base
board = esp32doit-devkit-v1
build_flags =
${esp32_base.build_flags}
-DRADIOMASTER_NOMAD_GEMINI
-DPRIVATE_HW
-DVTABLES_IN_FLASH=1
-DCONFIG_DISABLE_HAL_LOCKS=1
-O2
-Ivariants/radiomaster_nomad_gemini
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
-DMESHTASTIC_EXCLUDE_I2C=1
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
-DRADIOLIB_EXCLUDE_SX126X=1
board_build.f_cpu = 240000000L
upload_protocol = esptool
lib_deps =
${esp32_base.lib_deps}

View File

@@ -1,56 +0,0 @@
#include "RadioLib.h"
static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_LR11X0_DIO7,
RADIOLIB_LR11X0_DIO8, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{LR11x0::MODE_STBY, {LOW, LOW, LOW, LOW}}, {LR11x0::MODE_RX, {LOW, LOW, HIGH, LOW}},
{LR11x0::MODE_TX, {LOW, LOW, LOW, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, LOW, LOW, HIGH}},
{LR11x0::MODE_TX_HF, {LOW, HIGH, LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW, LOW, LOW}},
{LR11x0::MODE_WIFI, {HIGH, LOW, LOW, LOW}}, END_OF_MODE_TABLE,
};
/*
DIO5: RXEN 2.4GHz
DIO6: TXEN 2.4GHz
DIO7: RXEN 900MHz
DIO8: TXEN 900MHz
"radio_dcdc": true,
"radio_rfo_hf": true,
"power_apc2": 26,
"power_min": 0,
"power_high": 6,
"power_max": 6,
"power_default": 3,
"power_control": 3, POWER_OUTPUT_DACWRITE // use internal dacWrite function to set value on GPIO_PIN_RFamp_APC2
[0, 1, 2, 3, 4, 5, 6 ] // 0-6
"power_values": [120, 120, 120, 120, 120, 120, 95] // DAC Value
"power_values2": [-17, -16, -14, -11, -7, -3, 5 ] // 900M
"power_values_dual": [-18, -14, -8, -6, -2, 3, 5 ] // 2.4G
// default value 0 means direct!
#define POWER_OUTPUT_DACWRITE (hardware_int(HARDWARE_power_control)==3)
#define POWER_OUTPUT_VALUES hardware_i16_array(HARDWARE_power_values)
#define POWER_OUTPUT_VALUES_COUNT hardware_int(HARDWARE_power_values_count)
#define POWER_OUTPUT_VALUES2 hardware_i16_array(HARDWARE_power_values2)
#define POWER_OUTPUT_VALUES_DUAL hardware_i16_array(HARDWARE_power_values_dual)
#define POWER_OUTPUT_VALUES_DUAL_COUNT hardware_int(HARDWARE_power_values_dual_count)
#define GPIO_PIN_FAN_EN hardware_pin(HARDWARE_misc_fan_en)
case PWR_10mW: return 10;
case PWR_25mW: return 14;
case PWR_50mW: return 17;
case PWR_100mW: return 20;
case PWR_250mW: return 24;
case PWR_500mW: return 27;
case PWR_1000mW: return 30;
95 -> +25dBm
120 -> +24dBm
*/

View File

@@ -1,60 +0,0 @@
#define HAS_SCREEN 0
#define HAS_WIRE 0
#define HAS_GPS 0
#undef GPS_RX_PIN
#undef GPS_TX_PIN
#define PIN_SPI_MISO 33
#define PIN_SPI_MOSI 32
#define PIN_SPI_SCK 25
#define PIN_SPI_NSS 27
#define LORA_RESET 15
#define LORA_DIO1 37
#define LORA_DIO2 36
#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_LR1121
#define LR1121_IRQ_PIN LORA_DIO1
#define LR1121_NRESET_PIN LORA_RESET
#define LR1121_BUSY_PIN LORA_DIO2
#define LR1121_SPI_NSS_PIN LORA_CS
#define LR1121_SPI_SCK_PIN LORA_SCK
#define LR1121_SPI_MOSI_PIN LORA_MOSI
#define LR1121_SPI_MISO_PIN LORA_MISO
// this is correct and sets the cap for the Sub-GHz part
#define LR1110_MAX_POWER 5
// 2.4G Part
#define LR1120_MAX_POWER 5
#define POWER_SHIFT -20
// not yet implemented
#define JANUS_RADIO
#define LR1121_IRQ2_PIN 34
#define LR1121_NRESET2_PIN 21
#define LR1121_BUSY2_PIN 39
#define LR1121_SPI_NSS2_PIN 13
// TODO: check if this is correct
// #define LR11X0_DIO3_TCXO_VOLTAGE 1.6
#define LR11X0_DIO_AS_RF_SWITCH
#define HAS_NEOPIXEL // Enable the use of neopixels
#define NEOPIXEL_COUNT 2 // How many neopixels are connected
#define NEOPIXEL_DATA 22 // GPIO pin used to send data to the neopixels
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // Type of neopixels in use
#define ENABLE_AMBIENTLIGHTING // Turn on Ambient Lighting
#define BUTTON_PIN 34
#define BUTTON_NEED_PULLUP
#undef EXT_NOTIFY_OUT
#define RADIO_FAN_EN 2

View File

@@ -11,6 +11,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631 -D RAK_4631
-DRADIOLIB_EXCLUDE_SX128X=1
-DRADIOLIB_EXCLUDE_SX127X=1
-DRADIOLIB_EXCLUDE_LR11X0=1
-DNXP_WIRE=Wire
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631> +<mesh/eth/> +<mesh/api/> +<mqtt/>
lib_deps =
${nrf52840_base.lib_deps}