fix ADC stuff, and pin defs. get ready for SuperIO support. will I buy one? Maybe!

This commit is contained in:
Ev Lbibass 2026-03-16 22:05:14 -04:00
parent 20953e56d6
commit 08cb7dd7da
4 changed files with 99 additions and 104 deletions

View file

@ -10,7 +10,7 @@ build_flags = ${nrf52_base.build_flags}
-I src/helpers/ui -I src/helpers/ui
-D muzi_base_duo -D muzi_base_duo
-D NRF52_POWER_MANAGEMENT -D NRF52_POWER_MANAGEMENT
-D PIN_USER_BTN=10 -D PIN_USER_BTN=PIN_BUTTON1
-D USER_BTN_PRESSED=LOW -D USER_BTN_PRESSED=LOW
-D PIN_STATUS_LED=35 -D PIN_STATUS_LED=35
-D RADIO_CLASS=CustomLR1110 -D RADIO_CLASS=CustomLR1110
@ -27,6 +27,7 @@ build_flags = ${nrf52_base.build_flags}
-D P_LORA_RESET=LORA_RESET ; P1.10 -D P_LORA_RESET=LORA_RESET ; P1.10
-D LR11X0_DIO_AS_RF_SWITCH=true -D LR11X0_DIO_AS_RF_SWITCH=true
-D LR11X0_DIO3_TCXO_VOLTAGE=3.0 -D LR11X0_DIO3_TCXO_VOLTAGE=3.0
-D QSPIFLASH=1
; -D ENV_INCLUDE_GPS=1 ; -D ENV_INCLUDE_GPS=1
build_src_filter = ${nrf52_base.build_src_filter} build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp> +<helpers/*.cpp>
@ -81,10 +82,8 @@ build_flags = ${muzi_base_duo.build_flags}
; -D MESH_DEBUG=1 ; -D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256 -D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=NullDisplayDriver -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} build_src_filter = ${muzi_base_duo.build_src_filter}
+<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp> +<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp> +<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${muzi_base_duo.lib_deps} lib_deps = ${muzi_base_duo.lib_deps}
@ -105,16 +104,13 @@ build_flags = ${muzi_base_duo.build_flags}
-D QSPIFLASH=1 -D QSPIFLASH=1
; -D BLE_DEBUG_LOGGING=1 ; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1 ; -D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1 ; -D MESH_DEBUG=1
-D OFFLINE_QUEUE_SIZE=256 -D OFFLINE_QUEUE_SIZE=256
-D DISPLAY_CLASS=NullDisplayDriver -D DISPLAY_CLASS=NullDisplayDriver
; -D PIN_BUZZER=25
; -D PIN_BUZZER_EN=37 ; P1/5 - required for T1000-E
-D ADVERT_NAME='"@@MAC"' -D ADVERT_NAME='"@@MAC"'
build_src_filter = ${muzi_base_duo.build_src_filter} build_src_filter = ${muzi_base_duo.build_src_filter}
+<helpers/nrf52/SerialBLEInterface.cpp> +<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/sensors> +<helpers/sensors>
; +<helpers/ui/buzzer.cpp>
+<../examples/companion_radio/*.cpp> +<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp> +<../examples/companion_radio/ui-orig/*.cpp>
lib_deps = ${muzi_base_duo.lib_deps} lib_deps = ${muzi_base_duo.lib_deps}

View file

@ -12,8 +12,7 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock rtc_clock; VolatileRTCClock rtc_clock;
// MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &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 #ifdef DISPLAY_CLASS
NullDisplayDriver display; NullDisplayDriver display;
#endif #endif

View file

@ -10,55 +10,55 @@
const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] = const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] =
{ {
0, // P0.00 0,
1, // P0.01 1,
2, // P0.02, AIN0 BATTERY_PIN 2,
3, // P0.03 3,
4, // P0.04, SENSOR_EN 4,
5, // P0.05, EXT_PWR_DETEC 5,
6, // P0.06, PIN_BUTTON1 6,
7, // P0.07, LORA_BUSY 7,
8, // P0.08, GPS_VRTC_EN 8,
9, // P0.09 9,
10, // P0.10 10,
11, // P0.11, PIN_SPI_SCK 11,
12, // P0.12, PIN_SPI_NSS 12,
13, // P0.13, PIN_SERIAL1_TX 13,
14, // P0.14, PIN_SERIAL1_RX 14,
15, // P0.15, GPS_RTC_INT 15,
16, // P0.16, PIN_SERIAL2_TX 16,
17, // P0.17, PIN_SERIAL2_RX 17,
18, // P0.18 18,
19, // P0.19 19,
20, // P0.20 20,
21, // P0.21 21,
22, // P0.22 22,
23, // P0.23 23,
24, // P0.24, LED_GREEN 24,
25, // P0.25, BUZZER_PIN 25,
26, // P0.26, PIN_WIRE_SDA 26,
27, // P0.27, PIN_WIRE_SCL 27,
28, // P0.28 28,
29, // P0.29, AIN5, LUX_SENSOR 29,
30, // P0.30 30,
31, // P0.31, AIN7, TEMP_SENSOR 31,
32, // P1.00 // P1 pins.
33, // P1.01, LORA_DIO_1 32,
34, // P1.02 33,
35, // P1.03, EXT_CHRG_DETECT 34,
36, // P1.04 35,
37, // P1.05, LR1110_EN 36,
38, // P1.06, 3V3_EN PWR TO SENSORS 37,
39, // P1.07, PIN_3V3_ACC_EN 38,
40, // P1.08, PIN_SPI_MISO 39,
41, // P1.09, PIN_SPI_MOSI 40,
42, // P1.10, LORA_RESET 41,
43, // P1.11, GPS_EN 42,
44, // P1.12, GPS_SLEEP_INT 43,
45, // P1.13 44,
46, // P1.14, GPS_RESETB 45,
47, // P1.15, PIN_GPS_RESET 46,
255, // NRFX_SPIM_PIN_NOT_USED 47,
}; };
void initVariant() void initVariant()
@ -67,11 +67,21 @@ void initVariant()
// https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69 // https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69
pinMode(PIN_VBAT_READ, INPUT); pinMode(PIN_VBAT_READ, INPUT);
// pinMode(EXT_CHRG_DETECT, INPUT); pinMode(PIN_BATTERY_CHARGING, INPUT);
// pinMode(EXT_PWR_DETECT, INPUT); pinMode(PIN_CHARGER_FAULT, INPUT);
pinMode(PIN_BUTTON1, 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_PIN, OUTPUT);
pinMode(LED_BLUE, OUTPUT); pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_PIN, LOW); digitalWrite(LED_PIN, LOW);
digitalWrite(LED_BLUE, 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); //
} }

View file

@ -25,19 +25,23 @@
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 #define VBAT_AR_INTERNAL AR_INTERNAL_3_0
#define ADC_MULTIPLIER 1.537 #define ADC_MULTIPLIER 1.537
#define ADC_RESOLUTION 14 #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) // 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) // LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
#define PWRMGT_LPCOMP_AIN 3 #define PWRMGT_LPCOMP_AIN 7 // AIN7 = P0.31 = PIN_VBAT_READ
#define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V) was the default on RAK4631. should still apply here.
// Other pins // 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); // not used
static const uint8_t AREF = PIN_AREF;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Number of pins // 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_RX (19) // P0.19 used for GPS RX
#define PIN_SERIAL1_TX (20) // P0.20 used for GPS TX #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 // I2C pin definition
#define HAS_WIRE (1) #define HAS_WIRE (1)
#define WIRE_INTERFACES_COUNT (2) #define WIRE_INTERFACES_COUNT (2)
#define PIN_WIRE_SDA (4) // P0.4 #define PIN_WIRE1_SDA (4) // P0.4
#define PIN_WIRE_SCL (6) // P0.6 #define PIN_WIRE1_SCL (6) // P0.6
#define PIN_WIRE1_SDA (24) // P0.24 OLED I2C #define PIN_WIRE_SDA (24) // P0.24 OLED I2C
#define PIN_WIRE1_SCL (25) // P0.25 OLED I2C #define PIN_WIRE_SCL (25) // P0.25 OLED I2C
// #define I2C_NO_RESCAN // #define I2C_NO_RESCAN
// #define HAS_QMA6100P // #define HAS_QMA6100P
// #define QMA_6100P_INT_PIN (34) // P1.2 // #define QMA_6100P_INT_PIN (34) // P1.2
@ -93,9 +93,18 @@ static const uint8_t AREF = PIN_AREF;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Builtin buttons // Builtin buttons
#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_BUTTON1 (10) // P0.10 #define PIN_BUTTON2 (21) // Joystick Up
#define BUTTON_PIN PIN_BUTTON1 #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 // LR1110
@ -112,7 +121,7 @@ static const uint8_t AREF = PIN_AREF;
#define LR11X0_DIO3_TCXO_VOLTAGE 3.0 #define LR11X0_DIO3_TCXO_VOLTAGE 3.0
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// QSPI Flash
#define PIN_QSPI_SCK (0 + 3) #define PIN_QSPI_SCK (0 + 3)
#define PIN_QSPI_CS (0 + 26) #define PIN_QSPI_CS (0 + 26)
#define PIN_QSPI_IO0 (0 + 30) #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_DEVICES W25Q128JVPQ
#define EXTERNAL_FLASH_USE_QSPI #define EXTERNAL_FLASH_USE_QSPI
// // GPS
////////////////////////////////////////////////////////////////////////////////
// GPS
// #define HAS_GPS 1 // #define HAS_GPS 1
// #define GPS_RX_PIN PIN_SERIAL1_RX #define GPS_RX_PIN PIN_SERIAL1_RX
// #define GPS_TX_PIN PIN_SERIAL1_TX #define GPS_TX_PIN PIN_SERIAL1_TX
#define GPS_EN (32+1) // P1.01 PWR_IO2 on schematic. just cuts power to gps.
// #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 // Buzzer
// #define BUZZER_EN (37) // P1.5 #define BUZZER_PIN (22) // P0.22 same load switch design as GPS_EN.
// #define BUZZER_PIN (25) // P0.25