From 1e435ae2d17929f0397d941d1586edb95547bca7 Mon Sep 17 00:00:00 2001 From: lbibass Date: Fri, 13 Mar 2026 17:44:13 -0400 Subject: [PATCH 1/3] initial add of base duo --- boards/muzi_base_duo.json | 72 +++++++++ variants/muzi_base_duo/muzi_base_duoBoard.cpp | 46 ++++++ variants/muzi_base_duo/muzi_base_duoBoard.h | 88 ++++++++++ variants/muzi_base_duo/platformio.ini | 122 ++++++++++++++ variants/muzi_base_duo/target.cpp | 96 +++++++++++ variants/muzi_base_duo/target.h | 30 ++++ variants/muzi_base_duo/variant.cpp | 76 +++++++++ variants/muzi_base_duo/variant.h | 150 ++++++++++++++++++ 8 files changed, 680 insertions(+) create mode 100644 boards/muzi_base_duo.json create mode 100644 variants/muzi_base_duo/muzi_base_duoBoard.cpp create mode 100644 variants/muzi_base_duo/muzi_base_duoBoard.h create mode 100644 variants/muzi_base_duo/platformio.ini create mode 100644 variants/muzi_base_duo/target.cpp create mode 100644 variants/muzi_base_duo/target.h create mode 100644 variants/muzi_base_duo/variant.cpp create mode 100644 variants/muzi_base_duo/variant.h diff --git a/boards/muzi_base_duo.json b/boards/muzi_base_duo.json new file mode 100644 index 0000000000..13b205db3a --- /dev/null +++ b/boards/muzi_base_duo.json @@ -0,0 +1,72 @@ +{ + "build": { + "arduino": { + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_MUZI_BASE_DUO -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + [ + "0x239A", + "0x4405" + ], + [ + "0x239A", + "0x0029" + ], + [ + "0x239A", + "0x002A" + ] + ], + "usb_product": "muzi_base_duo", + "mcu": "nrf52840", + "variant": "MUZI_BASE_DUO", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "onboard_tools": [ + "jlink" + ], + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52.cfg" + }, + "frameworks": [ + "arduino" + ], + "name": "Muzi Base Duo", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "speed": 115200, + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true, + "protocol": "nrfutil", + "protocols": [ + "jlink", + "nrfjprog", + "nrfutil", + "stlink" + ] + }, + "url": "https://github.com/muzi-works", + "vendor": "MuziWorks" +} diff --git a/variants/muzi_base_duo/muzi_base_duoBoard.cpp b/variants/muzi_base_duo/muzi_base_duoBoard.cpp new file mode 100644 index 0000000000..df72e2d8f2 --- /dev/null +++ b/variants/muzi_base_duo/muzi_base_duoBoard.cpp @@ -0,0 +1,46 @@ +#include +#include + +#include "muzi_base_duoBoard.h" + +// void muzi_base_duoBoard::begin() { +// NRF52BoardDCDC::begin(); +// btn_prev_state = HIGH; + +// #ifdef BUTTON_PIN +// pinMode(BATTERY_PIN, INPUT); +// pinMode(BUTTON_PIN, INPUT); +// pinMode(LED_PIN, OUTPUT); +// #endif + +// #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) +// Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); +// #endif + +// Wire.begin(); + +// delay(10); // give sx1262 some time to power up +// } +void muzi_base_duoBoard::begin() { + NRF52BoardDCDC::begin(); + pinMode(BATTERY_PIN, INPUT); +#ifdef PIN_USER_BTN + pinMode(PIN_USER_BTN, INPUT); +#endif + +#ifdef PIN_USER_BTN_ANA + pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP); +#endif + +#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) + Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); +#endif + + Wire.begin(); + +#ifdef NRF52_POWER_MANAGEMENT + // Boot voltage protection check (may not return if voltage too low) + // We need to call this after we configure SX126X_POWER_EN as output but before we pull high + checkBootVoltage(&power_config); +#endif +} \ No newline at end of file diff --git a/variants/muzi_base_duo/muzi_base_duoBoard.h b/variants/muzi_base_duo/muzi_base_duoBoard.h new file mode 100644 index 0000000000..1029e2a70d --- /dev/null +++ b/variants/muzi_base_duo/muzi_base_duoBoard.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include +#include + +class muzi_base_duoBoard : public NRF52BoardDCDC { +protected: +#ifdef NRF52_POWER_MANAGEMENT + void initiateShutdown(uint8_t reason) override; +#endif + +public: + muzi_base_duoBoard() : NRF52Board("MUZI_BASE_DUO_OTA") {} + void begin(); + + #define BATTERY_SAMPLES 8 + + uint16_t getBattMilliVolts() override { + MESH_DEBUG_PRINTLN("BaseDuo: Sampling battery"); + analogReadResolution(12); + + uint32_t raw = 0; + for (int i = 0; i < BATTERY_SAMPLES; i++) { + raw += analogRead(BATTERY_PIN); + } + raw = raw / BATTERY_SAMPLES; + + return (ADC_MULTIPLIER * raw) / 4096; + } + + const char* getManufacturerName() const override { + return "Muzi Base Duo"; + } + + // int buttonStateChanged() { + // #ifdef BUTTON_PIN + // uint8_t v = digitalRead(BUTTON_PIN); + // if (v != btn_prev_state) { + // btn_prev_state = v; + // return (v == LOW) ? 1 : -1; + // } + // #endif + // return 0; + // } + + // void powerOff() override { + // // #ifdef HAS_GPS + // // digitalWrite(GPS_VRTC_EN, LOW); + // // digitalWrite(GPS_RESET, LOW); + // // digitalWrite(GPS_SLEEP_INT, LOW); + // // digitalWrite(GPS_RTC_INT, LOW); + // // digitalWrite(GPS_EN, LOW); + // // #endif + + // // #ifdef BUZZER_EN + // // digitalWrite(BUZZER_EN, LOW); + // // #endif + + // // #ifdef PIN_3V3_EN + // // digitalWrite(PIN_3V3_EN, LOW); + // // #endif + + // // #ifdef PIN_3V3_ACC_EN + // // digitalWrite(PIN_3V3_ACC_EN, LOW); + // // #endif + // // #ifdef SENSOR_EN + // // digitalWrite(SENSOR_EN, LOW); + // // #endif + + // // set led on and wait for button release before poweroff + // #ifdef LED_PIN + // digitalWrite(LED_PIN, HIGH); + // #endif + // #ifdef BUTTON_PIN + // while(digitalRead(BUTTON_PIN)); + // #endif + // #ifdef LED_PIN + // digitalWrite(LED_PIN, LOW); + // #endif + + // #ifdef BUTTON_PIN + // nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); + // #endif + + // sd_power_system_off(); + // } +}; diff --git a/variants/muzi_base_duo/platformio.ini b/variants/muzi_base_duo/platformio.ini new file mode 100644 index 0000000000..f061c8263a --- /dev/null +++ b/variants/muzi_base_duo/platformio.ini @@ -0,0 +1,122 @@ +[muzi_base_duo] +extends = nrf52_base +board = muzi_base_duo +board_build.ldscript = boards/nrf52840_s140_v6.ld +build_flags = ${nrf52_base.build_flags} + -I src/helpers/nrf52 + -I lib/nrf52/s140_nrf52_6.1.1_API/include + -I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52 + -I variants/muzi_base_duo + -I src/helpers/ui + -D muzi_base_duo + -D PIN_USER_BTN=10 + -D USER_BTN_PRESSED=LOW + -D PIN_STATUS_LED=(32+3) + -D RADIO_CLASS=CustomLR1110 + -D WRAPPER_CLASS=CustomLR1110Wrapper + -D LORA_TX_POWER=22 + -D RF_SWITCH_TABLE + -D RX_BOOSTED_GAIN=true + -D P_LORA_BUSY=LORA_BUSY ; P0.7 + -D P_LORA_SCLK=LORA_SCLK ; P0.11 + -D P_LORA_NSS=LORA_NSS ; P0.12 + -D P_LORA_DIO_1=LORA_DIO_1 ; P1.1 + -D P_LORA_MISO=LORA_MISO ; P1.8 + -D P_LORA_MOSI=LORA_MOSI ; P0.9 + -D P_LORA_RESET=LORA_RESET ; P1.10 + -D LR11X0_DIO_AS_RF_SWITCH=true + -D LR11X0_DIO3_TCXO_VOLTAGE=3.0 + ; -D ENV_INCLUDE_GPS=1 +build_src_filter = ${nrf52_base.build_src_filter} + + + + + + + +<../variants/muzi_base_duo> +debug_tool = jlink +upload_protocol = nrfutil + +[env:muzi_base_duo_repeater] +extends = muzi_base_duo +build_flags = ${muzi_base_duo.build_flags} + -I examples/companion_radio/ui-orig + -D ADVERT_NAME='"muzi_base_duo Repeater"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${muzi_base_duo.build_src_filter} + +<../examples/simple_repeater> +lib_deps = ${muzi_base_duo.lib_deps} + ; stevemarple/MicroNMEA @ ^2.0.6 + +[env:muzi_base_duo_room_server] +extends = muzi_base_duo +build_flags = ${muzi_base_duo.build_flags} + -I examples/companion_radio/ui-orig + -D ADVERT_NAME='"muzi_base_duo Room"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + -D RF_SWITCH_TABLE +build_src_filter = ${muzi_base_duo.build_src_filter} + +<../examples/simple_room_server> +lib_deps = ${muzi_base_duo.lib_deps} + ; stevemarple/MicroNMEA @ ^2.0.6 + +[env:muzi_base_duo_companion_radio_usb] +extends = muzi_base_duo +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 708608 +build_flags = ${muzi_base_duo.build_flags} + -I examples/companion_radio/ui-orig + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + -D OFFLINE_QUEUE_SIZE=256 + -D DISPLAY_CLASS=NullDisplayDriver + ; -D PIN_BUZZER=25 + ; -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E +build_src_filter = ${muzi_base_duo.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-orig/*.cpp> +lib_deps = ${muzi_base_duo.lib_deps} + densaugeo/base64 @ ~1.4.0 + ; stevemarple/MicroNMEA @ ^2.0.6 + end2endzone/NonBlockingRTTTL@^1.3.0 + +[env:muzi_base_duo_companion_radio_ble] +extends = muzi_base_duo +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 708608 +build_flags = ${muzi_base_duo.build_flags} + -I examples/companion_radio/ui-orig + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=123456 + -D BLE_TX_POWER=0 + -D QSPIFLASH=1 +; -D BLE_DEBUG_LOGGING=1 +; -D MESH_PACKET_LOGGING=1 + -D MESH_DEBUG=1 + -D OFFLINE_QUEUE_SIZE=256 + -D DISPLAY_CLASS=NullDisplayDriver + ; -D PIN_BUZZER=25 + ; -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E + -D ADVERT_NAME='"@@MAC"' +build_src_filter = ${muzi_base_duo.build_src_filter} + + + + + ; + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-orig/*.cpp> +lib_deps = ${muzi_base_duo.lib_deps} + densaugeo/base64 @ ~1.4.0 + ; stevemarple/MicroNMEA @ ^2.0.6 + end2endzone/NonBlockingRTTTL@^1.3.0 diff --git a/variants/muzi_base_duo/target.cpp b/variants/muzi_base_duo/target.cpp new file mode 100644 index 0000000000..ac7e2d6916 --- /dev/null +++ b/variants/muzi_base_duo/target.cpp @@ -0,0 +1,96 @@ +#include +#include "target.h" +#include "variant.h" +// #include + +muzi_base_duoBoard board; + +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); + +WRAPPER_CLASS radio_driver(radio, board); + +VolatileRTCClock rtc_clock; +// MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); + +EnvironmentSensorManager sensors; // Added: Instantiate sensors (no GPS, as it's disabled) + +#ifdef DISPLAY_CLASS + NullDisplayDriver display; +#endif + +#ifndef LORA_CR + #define LORA_CR 5 +#endif + +#ifdef RF_SWITCH_TABLE +static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_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, {HIGH, LOW, LOW, HIGH }}, + { LR11x0::MODE_TX, {HIGH, HIGH, LOW, HIGH }}, + { LR11x0::MODE_TX_HP, {LOW, HIGH, LOW, HIGH }}, + { LR11x0::MODE_TX_HF, {LOW, LOW, LOW, LOW }}, + { LR11x0::MODE_GNSS, {LOW, LOW, HIGH, LOW }}, + { LR11x0::MODE_WIFI, {LOW, LOW, LOW, LOW }}, + END_OF_MODE_TABLE, +}; +#endif + +bool radio_init() { + //rtc_clock.begin(Wire); + +#ifdef LR11X0_DIO3_TCXO_VOLTAGE + float tcxo = LR11X0_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif + + SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); + SPI.begin(); + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo); + if (status != RADIOLIB_ERR_NONE) { + Serial.print("ERROR: radio init failed: "); + Serial.println(status); + return false; // fail + } + + radio.setCRC(2); + radio.explicitHeader(); + +#ifdef RF_SWITCH_TABLE + radio.setRfSwitchTable(rfswitch_dios, rfswitch_table); +#endif +#ifdef RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(RX_BOOSTED_GAIN); +#endif + + return true; // success +} + +uint32_t radio_get_rng_seed() { + return radio.random(0x7FFFFFFF); +} + +void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) { + radio.setFrequency(freq); + radio.setSpreadingFactor(sf); + radio.setBandwidth(bw); + radio.setCodingRate(cr); +} + +void radio_set_tx_power(int8_t dbm) { + radio.setOutputPower(dbm); +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); // create new random identity +} \ No newline at end of file diff --git a/variants/muzi_base_duo/target.h b/variants/muzi_base_duo/target.h new file mode 100644 index 0000000000..1b862ee0b0 --- /dev/null +++ b/variants/muzi_base_duo/target.h @@ -0,0 +1,30 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include "muzi_base_duoBoard.h" +#include +#include +#include +#include +#include // Added: Include for EnvironmentSensorManager +#ifdef DISPLAY_CLASS + #include "NullDisplayDriver.h" +#endif + + +#ifdef DISPLAY_CLASS + extern NullDisplayDriver display; +#endif + +extern muzi_base_duoBoard board; +extern WRAPPER_CLASS radio_driver; +extern VolatileRTCClock rtc_clock; +extern EnvironmentSensorManager sensors; + +bool radio_init(); +uint32_t radio_get_rng_seed(); +void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); +void radio_set_tx_power(int8_t dbm); +mesh::LocalIdentity radio_new_identity(); diff --git a/variants/muzi_base_duo/variant.cpp b/variants/muzi_base_duo/variant.cpp new file mode 100644 index 0000000000..24a881f46a --- /dev/null +++ b/variants/muzi_base_duo/variant.cpp @@ -0,0 +1,76 @@ +/* + * variant.cpp + * Copyright (C) 2023 Seeed K.K. + * MIT License + */ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] = +{ + 0, // P0.00 + 1, // P0.01 + 2, // P0.02, AIN0 BATTERY_PIN + 3, // P0.03 + 4, // P0.04, SENSOR_EN + 5, // P0.05, EXT_PWR_DETEC + 6, // P0.06, PIN_BUTTON1 + 7, // P0.07, LORA_BUSY + 8, // P0.08, GPS_VRTC_EN + 9, // P0.09 + 10, // P0.10 + 11, // P0.11, PIN_SPI_SCK + 12, // P0.12, PIN_SPI_NSS + 13, // P0.13, PIN_SERIAL1_TX + 14, // P0.14, PIN_SERIAL1_RX + 15, // P0.15, GPS_RTC_INT + 16, // P0.16, PIN_SERIAL2_TX + 17, // P0.17, PIN_SERIAL2_RX + 18, // P0.18 + 19, // P0.19 + 20, // P0.20 + 21, // P0.21 + 22, // P0.22 + 23, // P0.23 + 24, // P0.24, LED_GREEN + 25, // P0.25, BUZZER_PIN + 26, // P0.26, PIN_WIRE_SDA + 27, // P0.27, PIN_WIRE_SCL + 28, // P0.28 + 29, // P0.29, AIN5, LUX_SENSOR + 30, // P0.30 + 31, // P0.31, AIN7, TEMP_SENSOR + 32, // P1.00 + 33, // P1.01, LORA_DIO_1 + 34, // P1.02 + 35, // P1.03, EXT_CHRG_DETECT + 36, // P1.04 + 37, // P1.05, LR1110_EN + 38, // P1.06, 3V3_EN PWR TO SENSORS + 39, // P1.07, PIN_3V3_ACC_EN + 40, // P1.08, PIN_SPI_MISO + 41, // P1.09, PIN_SPI_MOSI + 42, // P1.10, LORA_RESET + 43, // P1.11, GPS_EN + 44, // P1.12, GPS_SLEEP_INT + 45, // P1.13 + 46, // P1.14, GPS_RESETB + 47, // P1.15, PIN_GPS_RESET + 255, // NRFX_SPIM_PIN_NOT_USED +}; + +void initVariant() +{ + // All pins output HIGH by default. + // https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69 + + pinMode(BATTERY_PIN, INPUT); + pinMode(EXT_CHRG_DETECT, INPUT); + pinMode(EXT_PWR_DETECT, INPUT); + pinMode(PIN_BUTTON1, INPUT); + pinMode(LED_PIN, OUTPUT); + pinMode(LED_BLUE, OUTPUT); + digitalWrite(LED_PIN, LOW); +} diff --git a/variants/muzi_base_duo/variant.h b/variants/muzi_base_duo/variant.h new file mode 100644 index 0000000000..022c33b7cf --- /dev/null +++ b/variants/muzi_base_duo/variant.h @@ -0,0 +1,150 @@ +/* + * variant.h + * Copyright (C) 2023 Seeed K.K. + * MIT License + */ + +#pragma once + +#include "WVariant.h" + +//////////////////////////////////////////////////////////////////////////////// +// Low frequency clock source + +#define USE_LFXO // 32.768 kHz crystal oscillator +#define VARIANT_MCK (64000000ul) +// #define USE_LFRC // 32.768 kHz RC oscillator + +//////////////////////////////////////////////////////////////////////////////// +// Power + +#define NRF_APM // detect usb power +// #define PIN_3V3_EN (38) // P1.6 Power to Sensors no power + +#define BATTERY_PIN (0 + 31) // P0.31 +// #define BATTERY_CHARGING_INV (32 + 02) // P1.02 +// #define BATTERY_IMMUTABLE +#define ADC_MULTIPLIER (1.537F) + +#define EXT_CHRG_DETECT (32+02) // P1.02 Muzi Base schematic shows there's a bat_chg status. That's stat2 on BQ25. if low, it's charging. +#define EXT_PWR_DETECT (27) // P0.5 stat1 (power detect, basically) on bq25 is connected to pin 0.27 + +#define ADC_RESOLUTION (14) +#define BATTERY_SENSE_RES (12) + +#define AREF_VOLTAGE (3.3) + +//////////////////////////////////////////////////////////////////////////////// +// Number of pins + +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +//////////////////////////////////////////////////////////////////////////////// +// UART pin definition + +#define PIN_SERIAL1_RX (19) // P0.19 used for GPS RX +#define PIN_SERIAL1_TX (20) // P0.20 used for GPS TX + + +// #define PIN_SERIAL2_RX (17) // P0.17 +// #define PIN_SERIAL2_TX (16) // P0.16 + +//////////////////////////////////////////////////////////////////////////////// +// I2C pin definition + +#define HAS_WIRE (1) +#define WIRE_INTERFACES_COUNT (2) + +#define PIN_WIRE_SDA (4) // P0.4 +#define PIN_WIRE_SCL (6) // P0.6 +#define PIN_WIRE1_SDA (24) // P0.24 OLED I2C +#define PIN_WIRE1_SCL (25) // P0.25 OLED I2C +// #define I2C_NO_RESCAN +// #define HAS_QMA6100P +// #define QMA_6100P_INT_PIN (34) // P1.2 + +//////////////////////////////////////////////////////////////////////////////// +// SPI pin definition + +#define SPI_INTERFACES_COUNT (1) + +#define PIN_SPI_MISO (32+15) // internally connected to p1.15 +#define PIN_SPI_MOSI (32+14) // internally connected to p1.14 +#define PIN_SPI_SCK (32+13) // internally connected to p1.13 +#define PIN_SPI_NSS (32+12) // internally connected to p1.12 + +//////////////////////////////////////////////////////////////////////////////// +// Builtin LEDs + +#define LED_BUILTIN (-1) +#define LED_BLUE (32+4) // P1.04 +#define LED_GREEN (32+3) // P1.03 +#define LED_PIN LED_GREEN + +#define LED_STATE_ON LOW + +//////////////////////////////////////////////////////////////////////////////// +// Builtin buttons + +#define PIN_BUTTON1 (10) // P0.10 +#define BUTTON_PIN PIN_BUTTON1 + +//////////////////////////////////////////////////////////////////////////////// +// LR1110 + +#define LORA_DIO_1 (32+8) // P1.08 +#define LORA_NSS (PIN_SPI_NSS) // P1.12 +#define LORA_RESET (32+12) // P1.12 +#define LORA_BUSY (32+11) // P1.11 +#define LORA_SCLK (PIN_SPI_SCK) +#define LORA_MISO (PIN_SPI_MISO) +#define LORA_MOSI (PIN_SPI_MOSI) + +#define LR11X0_DIO_AS_RF_SWITCH true +#define LR11X0_DIO3_TCXO_VOLTAGE 3.0 + +//////////////////////////////////////////////////////////////////////////////// + +#define PIN_QSPI_SCK (0 + 3) +#define PIN_QSPI_CS (0 + 26) +#define PIN_QSPI_IO0 (0 + 30) +#define PIN_QSPI_IO1 (0 + 29) +#define PIN_QSPI_IO2 (0 + 28) +#define PIN_QSPI_IO3 (0 + 2) + +#define EXTERNAL_FLASH_DEVICES W25Q128JVPQ +#define EXTERNAL_FLASH_USE_QSPI +// // GPS + +// #define HAS_GPS 1 +// #define GPS_RX_PIN PIN_SERIAL1_RX +// #define GPS_TX_PIN PIN_SERIAL1_TX + +// #define GPS_EN (43) // P1.11 +// #define GPS_RESET (47) // P1.15 + +// #define GPS_VRTC_EN (8) // P0.8 +// #define GPS_SLEEP_INT (44) // P1.12 +// #define GPS_RTC_INT (15) // P0.15 +// #define GPS_RESETB (46) // P1.14 + +//////////////////////////////////////////////////////////////////////////////// +// Temp+Lux Sensor + +// #define SENSOR_EN (4) // P0.4 +// #define TEMP_SENSOR (31) // P0.31/AIN7 +// #define LUX_SENSOR (29) // P0.29/AIN5 + +//////////////////////////////////////////////////////////////////////////////// +// Accelerometer (I2C addr : ??? ) + +// #define PIN_3V3_ACC_EN (39) // P1.7 + +//////////////////////////////////////////////////////////////////////////////// +// Buzzer + +// #define BUZZER_EN (37) // P1.5 +// #define BUZZER_PIN (25) // P0.25 \ No newline at end of file From 20953e56d6d17406e39f5750991a930ac1a430d9 Mon Sep 17 00:00:00 2001 From: Lbibass Date: Sat, 14 Mar 2026 10:38:50 -0400 Subject: [PATCH 2/3] Implement power management features and update battery sensing configuration --- variants/muzi_base_duo/muzi_base_duoBoard.cpp | 50 +++++++-------- variants/muzi_base_duo/muzi_base_duoBoard.h | 61 ++----------------- variants/muzi_base_duo/platformio.ini | 3 +- variants/muzi_base_duo/variant.cpp | 7 ++- variants/muzi_base_duo/variant.h | 35 ++++++----- 5 files changed, 53 insertions(+), 103 deletions(-) diff --git a/variants/muzi_base_duo/muzi_base_duoBoard.cpp b/variants/muzi_base_duo/muzi_base_duoBoard.cpp index df72e2d8f2..c7aacee393 100644 --- a/variants/muzi_base_duo/muzi_base_duoBoard.cpp +++ b/variants/muzi_base_duo/muzi_base_duoBoard.cpp @@ -3,44 +3,38 @@ #include "muzi_base_duoBoard.h" -// void muzi_base_duoBoard::begin() { -// NRF52BoardDCDC::begin(); -// btn_prev_state = HIGH; - -// #ifdef BUTTON_PIN -// pinMode(BATTERY_PIN, INPUT); -// pinMode(BUTTON_PIN, INPUT); -// pinMode(LED_PIN, OUTPUT); -// #endif - -// #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) -// Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); -// #endif - -// Wire.begin(); +#ifdef NRF52_POWER_MANAGEMENT +const PowerMgtConfig power_config = { + .lpcomp_ain_channel = PWRMGT_LPCOMP_AIN, + .lpcomp_refsel = PWRMGT_LPCOMP_REFSEL, + .voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK +}; + +void muzi_base_duoBoard::initiateShutdown(uint8_t reason) { + // Disable LoRa module power before shutdown + if (reason == SHUTDOWN_REASON_LOW_VOLTAGE || + reason == SHUTDOWN_REASON_BOOT_PROTECT) { + configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel); + } + + enterSystemOff(reason); +} +#endif // NRF52_POWER_MANAGEMENT -// delay(10); // give sx1262 some time to power up -// } void muzi_base_duoBoard::begin() { NRF52BoardDCDC::begin(); - pinMode(BATTERY_PIN, INPUT); -#ifdef PIN_USER_BTN - pinMode(PIN_USER_BTN, INPUT); -#endif -#ifdef PIN_USER_BTN_ANA - pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP); + pinMode(PIN_VBAT_READ, INPUT); + +#ifdef PIN_USER_BTN + pinMode(PIN_USER_BTN, INPUT_PULLUP); #endif #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); #endif - - Wire.begin(); - #ifdef NRF52_POWER_MANAGEMENT - // Boot voltage protection check (may not return if voltage too low) - // We need to call this after we configure SX126X_POWER_EN as output but before we pull high checkBootVoltage(&power_config); #endif + delay(10); // give sx1262 some time to power up } \ No newline at end of file diff --git a/variants/muzi_base_duo/muzi_base_duoBoard.h b/variants/muzi_base_duo/muzi_base_duoBoard.h index 1029e2a70d..29d02896a5 100644 --- a/variants/muzi_base_duo/muzi_base_duoBoard.h +++ b/variants/muzi_base_duo/muzi_base_duoBoard.h @@ -17,72 +17,21 @@ class muzi_base_duoBoard : public NRF52BoardDCDC { #define BATTERY_SAMPLES 8 uint16_t getBattMilliVolts() override { - MESH_DEBUG_PRINTLN("BaseDuo: Sampling battery"); analogReadResolution(12); + analogReference(AR_INTERNAL_3_0); + delay(1); uint32_t raw = 0; for (int i = 0; i < BATTERY_SAMPLES; i++) { - raw += analogRead(BATTERY_PIN); + raw += analogRead(PIN_VBAT_READ); } raw = raw / BATTERY_SAMPLES; - return (ADC_MULTIPLIER * raw) / 4096; + // ADC_MULTIPLIER is the voltage divider ratio + return (raw * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096; } const char* getManufacturerName() const override { return "Muzi Base Duo"; } - - // int buttonStateChanged() { - // #ifdef BUTTON_PIN - // uint8_t v = digitalRead(BUTTON_PIN); - // if (v != btn_prev_state) { - // btn_prev_state = v; - // return (v == LOW) ? 1 : -1; - // } - // #endif - // return 0; - // } - - // void powerOff() override { - // // #ifdef HAS_GPS - // // digitalWrite(GPS_VRTC_EN, LOW); - // // digitalWrite(GPS_RESET, LOW); - // // digitalWrite(GPS_SLEEP_INT, LOW); - // // digitalWrite(GPS_RTC_INT, LOW); - // // digitalWrite(GPS_EN, LOW); - // // #endif - - // // #ifdef BUZZER_EN - // // digitalWrite(BUZZER_EN, LOW); - // // #endif - - // // #ifdef PIN_3V3_EN - // // digitalWrite(PIN_3V3_EN, LOW); - // // #endif - - // // #ifdef PIN_3V3_ACC_EN - // // digitalWrite(PIN_3V3_ACC_EN, LOW); - // // #endif - // // #ifdef SENSOR_EN - // // digitalWrite(SENSOR_EN, LOW); - // // #endif - - // // set led on and wait for button release before poweroff - // #ifdef LED_PIN - // digitalWrite(LED_PIN, HIGH); - // #endif - // #ifdef BUTTON_PIN - // while(digitalRead(BUTTON_PIN)); - // #endif - // #ifdef LED_PIN - // digitalWrite(LED_PIN, LOW); - // #endif - - // #ifdef BUTTON_PIN - // nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); - // #endif - - // sd_power_system_off(); - // } }; diff --git a/variants/muzi_base_duo/platformio.ini b/variants/muzi_base_duo/platformio.ini index f061c8263a..52eda948c5 100644 --- a/variants/muzi_base_duo/platformio.ini +++ b/variants/muzi_base_duo/platformio.ini @@ -9,9 +9,10 @@ build_flags = ${nrf52_base.build_flags} -I variants/muzi_base_duo -I src/helpers/ui -D muzi_base_duo + -D NRF52_POWER_MANAGEMENT -D PIN_USER_BTN=10 -D USER_BTN_PRESSED=LOW - -D PIN_STATUS_LED=(32+3) + -D PIN_STATUS_LED=35 -D RADIO_CLASS=CustomLR1110 -D WRAPPER_CLASS=CustomLR1110Wrapper -D LORA_TX_POWER=22 diff --git a/variants/muzi_base_duo/variant.cpp b/variants/muzi_base_duo/variant.cpp index 24a881f46a..590ac4698c 100644 --- a/variants/muzi_base_duo/variant.cpp +++ b/variants/muzi_base_duo/variant.cpp @@ -66,11 +66,12 @@ void initVariant() // All pins output HIGH by default. // https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69 - pinMode(BATTERY_PIN, INPUT); - pinMode(EXT_CHRG_DETECT, INPUT); - pinMode(EXT_PWR_DETECT, INPUT); + pinMode(PIN_VBAT_READ, INPUT); + // pinMode(EXT_CHRG_DETECT, INPUT); + // pinMode(EXT_PWR_DETECT, INPUT); pinMode(PIN_BUTTON1, INPUT); pinMode(LED_PIN, OUTPUT); pinMode(LED_BLUE, OUTPUT); digitalWrite(LED_PIN, LOW); + digitalWrite(LED_BLUE, LOW); } diff --git a/variants/muzi_base_duo/variant.h b/variants/muzi_base_duo/variant.h index 022c33b7cf..7f6c2c00dd 100644 --- a/variants/muzi_base_duo/variant.h +++ b/variants/muzi_base_duo/variant.h @@ -18,21 +18,26 @@ //////////////////////////////////////////////////////////////////////////////// // Power -#define NRF_APM // detect usb power -// #define PIN_3V3_EN (38) // P1.6 Power to Sensors no power +#define PIN_VBAT_READ (31) // P0.31 +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER 1.537 +#define ADC_RESOLUTION 14 -#define BATTERY_PIN (0 + 31) // P0.31 -// #define BATTERY_CHARGING_INV (32 + 02) // P1.02 -// #define BATTERY_IMMUTABLE -#define ADC_MULTIPLIER (1.537F) +// Power management boot protection threshold (millivolts) +#define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV) -#define EXT_CHRG_DETECT (32+02) // P1.02 Muzi Base schematic shows there's a bat_chg status. That's stat2 on BQ25. if low, it's charging. -#define EXT_PWR_DETECT (27) // P0.5 stat1 (power detect, basically) on bq25 is connected to pin 0.27 +// LPCOMP wake configuration (voltage recovery from SYSTEMOFF) +#define PWRMGT_LPCOMP_AIN 3 +#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) -#define ADC_RESOLUTION (14) -#define BATTERY_SENSE_RES (12) +// Other pins +#define PIN_AREF (2) -#define AREF_VOLTAGE (3.3) + +static const uint8_t AREF = PIN_AREF; //////////////////////////////////////////////////////////////////////////////// // Number of pins @@ -79,10 +84,10 @@ //////////////////////////////////////////////////////////////////////////////// // Builtin LEDs -#define LED_BUILTIN (-1) -#define LED_BLUE (32+4) // P1.04 -#define LED_GREEN (32+3) // P1.03 -#define LED_PIN LED_GREEN +#define LED_BUILTIN (35) +#define LED_BLUE (-1) // P1.04 turned off, because the blue LED was annoying. +// #define LED_GREEN (35) // P1.03 +#define LED_PIN LED_BUILTIN #define LED_STATE_ON LOW From 08cb7dd7da5b4b810fb6f01c57048a3534083e9d Mon Sep 17 00:00:00 2001 From: Ev Lbibass Date: Mon, 16 Mar 2026 22:05:14 -0400 Subject: [PATCH 3/3] fix ADC stuff, and pin defs. get ready for SuperIO support. will I buy one? Maybe! --- variants/muzi_base_duo/platformio.ini | 12 +-- variants/muzi_base_duo/target.cpp | 3 +- variants/muzi_base_duo/variant.cpp | 112 ++++++++++++++------------ variants/muzi_base_duo/variant.h | 76 ++++++++--------- 4 files changed, 99 insertions(+), 104 deletions(-) diff --git a/variants/muzi_base_duo/platformio.ini b/variants/muzi_base_duo/platformio.ini index 52eda948c5..2c39574872 100644 --- a/variants/muzi_base_duo/platformio.ini +++ b/variants/muzi_base_duo/platformio.ini @@ -10,7 +10,7 @@ build_flags = ${nrf52_base.build_flags} -I src/helpers/ui -D muzi_base_duo -D NRF52_POWER_MANAGEMENT - -D PIN_USER_BTN=10 + -D PIN_USER_BTN=PIN_BUTTON1 -D USER_BTN_PRESSED=LOW -D PIN_STATUS_LED=35 -D RADIO_CLASS=CustomLR1110 @@ -27,6 +27,7 @@ build_flags = ${nrf52_base.build_flags} -D P_LORA_RESET=LORA_RESET ; P1.10 -D LR11X0_DIO_AS_RF_SWITCH=true -D LR11X0_DIO3_TCXO_VOLTAGE=3.0 + -D QSPIFLASH=1 ; -D ENV_INCLUDE_GPS=1 build_src_filter = ${nrf52_base.build_src_filter} + @@ -81,10 +82,8 @@ build_flags = ${muzi_base_duo.build_flags} ; -D MESH_DEBUG=1 -D OFFLINE_QUEUE_SIZE=256 -D DISPLAY_CLASS=NullDisplayDriver - ; -D PIN_BUZZER=25 - ; -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E + build_src_filter = ${muzi_base_duo.build_src_filter} - + +<../examples/companion_radio/*.cpp> +<../examples/companion_radio/ui-orig/*.cpp> lib_deps = ${muzi_base_duo.lib_deps} @@ -105,16 +104,13 @@ build_flags = ${muzi_base_duo.build_flags} -D QSPIFLASH=1 ; -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1 - -D MESH_DEBUG=1 +; -D MESH_DEBUG=1 -D OFFLINE_QUEUE_SIZE=256 -D DISPLAY_CLASS=NullDisplayDriver - ; -D PIN_BUZZER=25 - ; -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E -D ADVERT_NAME='"@@MAC"' build_src_filter = ${muzi_base_duo.build_src_filter} + + - ; + +<../examples/companion_radio/*.cpp> +<../examples/companion_radio/ui-orig/*.cpp> lib_deps = ${muzi_base_duo.lib_deps} diff --git a/variants/muzi_base_duo/target.cpp b/variants/muzi_base_duo/target.cpp index ac7e2d6916..0c51ebed95 100644 --- a/variants/muzi_base_duo/target.cpp +++ b/variants/muzi_base_duo/target.cpp @@ -12,8 +12,7 @@ WRAPPER_CLASS radio_driver(radio, board); VolatileRTCClock rtc_clock; // MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); -EnvironmentSensorManager sensors; // Added: Instantiate sensors (no GPS, as it's disabled) - +EnvironmentSensorManager sensors; // only enable environment sensors. GPS is disabled. #ifdef DISPLAY_CLASS NullDisplayDriver display; #endif diff --git a/variants/muzi_base_duo/variant.cpp b/variants/muzi_base_duo/variant.cpp index 590ac4698c..0fe63df096 100644 --- a/variants/muzi_base_duo/variant.cpp +++ b/variants/muzi_base_duo/variant.cpp @@ -10,55 +10,55 @@ const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] = { - 0, // P0.00 - 1, // P0.01 - 2, // P0.02, AIN0 BATTERY_PIN - 3, // P0.03 - 4, // P0.04, SENSOR_EN - 5, // P0.05, EXT_PWR_DETEC - 6, // P0.06, PIN_BUTTON1 - 7, // P0.07, LORA_BUSY - 8, // P0.08, GPS_VRTC_EN - 9, // P0.09 - 10, // P0.10 - 11, // P0.11, PIN_SPI_SCK - 12, // P0.12, PIN_SPI_NSS - 13, // P0.13, PIN_SERIAL1_TX - 14, // P0.14, PIN_SERIAL1_RX - 15, // P0.15, GPS_RTC_INT - 16, // P0.16, PIN_SERIAL2_TX - 17, // P0.17, PIN_SERIAL2_RX - 18, // P0.18 - 19, // P0.19 - 20, // P0.20 - 21, // P0.21 - 22, // P0.22 - 23, // P0.23 - 24, // P0.24, LED_GREEN - 25, // P0.25, BUZZER_PIN - 26, // P0.26, PIN_WIRE_SDA - 27, // P0.27, PIN_WIRE_SCL - 28, // P0.28 - 29, // P0.29, AIN5, LUX_SENSOR - 30, // P0.30 - 31, // P0.31, AIN7, TEMP_SENSOR - 32, // P1.00 - 33, // P1.01, LORA_DIO_1 - 34, // P1.02 - 35, // P1.03, EXT_CHRG_DETECT - 36, // P1.04 - 37, // P1.05, LR1110_EN - 38, // P1.06, 3V3_EN PWR TO SENSORS - 39, // P1.07, PIN_3V3_ACC_EN - 40, // P1.08, PIN_SPI_MISO - 41, // P1.09, PIN_SPI_MOSI - 42, // P1.10, LORA_RESET - 43, // P1.11, GPS_EN - 44, // P1.12, GPS_SLEEP_INT - 45, // P1.13 - 46, // P1.14, GPS_RESETB - 47, // P1.15, PIN_GPS_RESET - 255, // NRFX_SPIM_PIN_NOT_USED + 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 pins. + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, }; void initVariant() @@ -67,11 +67,21 @@ void initVariant() // https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69 pinMode(PIN_VBAT_READ, INPUT); - // pinMode(EXT_CHRG_DETECT, INPUT); - // pinMode(EXT_PWR_DETECT, INPUT); + pinMode(PIN_BATTERY_CHARGING, INPUT); + pinMode(PIN_CHARGER_FAULT, INPUT); pinMode(PIN_BUTTON1, INPUT); + pinMode(PIN_BUTTON2, INPUT); + pinMode(PIN_BUTTON3, INPUT); + pinMode(PIN_BUTTON4, INPUT); + pinMode(PIN_BUTTON5, INPUT); + pinMode(PIN_BUTTON6, INPUT); pinMode(LED_PIN, OUTPUT); pinMode(LED_BLUE, OUTPUT); digitalWrite(LED_PIN, LOW); digitalWrite(LED_BLUE, LOW); + pinMode(GPS_EN, OUTPUT); + digitalWrite(GPS_EN, LOW); // lets turn off the GPS at start. we can turn it on when we need it. + + pinMode(SCREEN_12V_ENABLE, OUTPUT); + digitalWrite(SCREEN_12V_ENABLE, LOW); // } diff --git a/variants/muzi_base_duo/variant.h b/variants/muzi_base_duo/variant.h index 7f6c2c00dd..02dfeb9b25 100644 --- a/variants/muzi_base_duo/variant.h +++ b/variants/muzi_base_duo/variant.h @@ -25,19 +25,23 @@ #define VBAT_AR_INTERNAL AR_INTERNAL_3_0 #define ADC_MULTIPLIER 1.537 #define ADC_RESOLUTION 14 +#define PIN_BATTERY_CHARGING (32+2) // P1.02 STAT2 +#define PIN_CHARGER_FAULT (27) // P0.27 STAT1 this pin is disabled on meshtastic. +// BQ25185 has 2 status pins: STAT1 and STAT2. Both are high when not charging. STAT1 high, STAT2 low: charging. Recoverable fault: STAT1 low, STAT2 high. Unrecoverable fault: both low. +// We only need to detect charging vs not charging, but someone else can use the fault pin to log when the battery gets too hot or cold. // Power management boot protection threshold (millivolts) -#define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV) +#define PWRMGT_VOLTAGE_BOOTLOCK 3100 // Won't boot below this voltage (mV). BB15 battery min voltage is 3v, 3100mV is minimum batt in meshtastic code. // LPCOMP wake configuration (voltage recovery from SYSTEMOFF) -#define PWRMGT_LPCOMP_AIN 3 -#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) +#define PWRMGT_LPCOMP_AIN 7 // AIN7 = P0.31 = PIN_VBAT_READ +#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) was the default on RAK4631. should still apply here. // Other pins -#define PIN_AREF (2) +#define PIN_AREF (-1) +#define SCREEN_12V_ENABLE (23) // SH1107 OLED controller has a pin that needs to be enabled to turn on the screen. - -static const uint8_t AREF = PIN_AREF; +static const uint8_t AREF = (PIN_AREF); // not used //////////////////////////////////////////////////////////////////////////////// // Number of pins @@ -53,20 +57,16 @@ static const uint8_t AREF = PIN_AREF; #define PIN_SERIAL1_RX (19) // P0.19 used for GPS RX #define PIN_SERIAL1_TX (20) // P0.20 used for GPS TX - -// #define PIN_SERIAL2_RX (17) // P0.17 -// #define PIN_SERIAL2_TX (16) // P0.16 - //////////////////////////////////////////////////////////////////////////////// // I2C pin definition #define HAS_WIRE (1) #define WIRE_INTERFACES_COUNT (2) -#define PIN_WIRE_SDA (4) // P0.4 -#define PIN_WIRE_SCL (6) // P0.6 -#define PIN_WIRE1_SDA (24) // P0.24 OLED I2C -#define PIN_WIRE1_SCL (25) // P0.25 OLED I2C +#define PIN_WIRE1_SDA (4) // P0.4 +#define PIN_WIRE1_SCL (6) // P0.6 +#define PIN_WIRE_SDA (24) // P0.24 OLED I2C +#define PIN_WIRE_SCL (25) // P0.25 OLED I2C // #define I2C_NO_RESCAN // #define HAS_QMA6100P // #define QMA_6100P_INT_PIN (34) // P1.2 @@ -93,9 +93,18 @@ static const uint8_t AREF = PIN_AREF; //////////////////////////////////////////////////////////////////////////////// // Builtin buttons - -#define PIN_BUTTON1 (10) // P0.10 -#define BUTTON_PIN PIN_BUTTON1 +#define PIN_BUTTON1 (10) // P0.10 Menu / User Button | on superIO, this is in the center of the "D-Pad", but it's also the button on the Uno/Duo. +#define PIN_BUTTON2 (21) // Joystick Up +#define PIN_BUTTON3 (17) // Joystick Down +#define PIN_BUTTON4 (37) // Joystick Left +#define PIN_BUTTON5 (16) // Joystick Right +#define PIN_BUTTON6 (15) // Back / Cancel Button. +#define JOYSTICK_PRESS PIN_BUTTON1 +#define JOYSTICK_UP PIN_BUTTON2 +#define JOYSTICK_DOWN PIN_BUTTON3 +#define JOYSTICK_LEFT PIN_BUTTON4 +#define JOYSTICK_RIGHT PIN_BUTTON5 +#define PIN_BACK_BTN PIN_BUTTON6 //////////////////////////////////////////////////////////////////////////////// // LR1110 @@ -112,7 +121,7 @@ static const uint8_t AREF = PIN_AREF; #define LR11X0_DIO3_TCXO_VOLTAGE 3.0 //////////////////////////////////////////////////////////////////////////////// - +// QSPI Flash #define PIN_QSPI_SCK (0 + 3) #define PIN_QSPI_CS (0 + 26) #define PIN_QSPI_IO0 (0 + 30) @@ -122,34 +131,15 @@ static const uint8_t AREF = PIN_AREF; #define EXTERNAL_FLASH_DEVICES W25Q128JVPQ #define EXTERNAL_FLASH_USE_QSPI -// // GPS - -// #define HAS_GPS 1 -// #define GPS_RX_PIN PIN_SERIAL1_RX -// #define GPS_TX_PIN PIN_SERIAL1_TX - -// #define GPS_EN (43) // P1.11 -// #define GPS_RESET (47) // P1.15 - -// #define GPS_VRTC_EN (8) // P0.8 -// #define GPS_SLEEP_INT (44) // P1.12 -// #define GPS_RTC_INT (15) // P0.15 -// #define GPS_RESETB (46) // P1.14 //////////////////////////////////////////////////////////////////////////////// -// Temp+Lux Sensor - -// #define SENSOR_EN (4) // P0.4 -// #define TEMP_SENSOR (31) // P0.31/AIN7 -// #define LUX_SENSOR (29) // P0.29/AIN5 - -//////////////////////////////////////////////////////////////////////////////// -// Accelerometer (I2C addr : ??? ) - -// #define PIN_3V3_ACC_EN (39) // P1.7 +// GPS +// #define HAS_GPS 1 +#define GPS_RX_PIN PIN_SERIAL1_RX +#define GPS_TX_PIN PIN_SERIAL1_TX +#define GPS_EN (32+1) // P1.01 PWR_IO2 on schematic. just cuts power to gps. //////////////////////////////////////////////////////////////////////////////// // Buzzer -// #define BUZZER_EN (37) // P1.5 -// #define BUZZER_PIN (25) // P0.25 \ No newline at end of file +#define BUZZER_PIN (22) // P0.22 same load switch design as GPS_EN. \ No newline at end of file