Skip to content

Commit

Permalink
T1000-E Peripherals
Browse files Browse the repository at this point in the history
- enable intelligent charge controller signals
- enable Accelerometer
- enable internal I2C bus
- provide Power to Accelerometer
  • Loading branch information
caveman99 committed Oct 25, 2024
1 parent 0c0da39 commit fb65009
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ class AnalogBatteryLevel : public HasBatteryLevel
/**
* return true if there is a battery installed in this unit
*/
// if we have a integrated device with a battery, we can assume that the battery is always connected
#ifdef BATTERY_IMMUTABLE
virtual bool isBatteryConnect() override { return true; }
#else
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
#endif

/// If we see a battery voltage higher than physics allows - assume charger is pumping
/// in power
Expand Down
1 change: 1 addition & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define LPS22HB_ADDR_ALT 0x5D
#define SHT31_4x_ADDR 0x44
#define PMSA0031_ADDR 0x12
#define QMA6100P_ADDR 0x12
#define AHT10_ADDR 0x38
#define RCWL9620_ADDR 0x57
#define VEML7700_ADDR 0x10
Expand Down
1 change: 1 addition & 0 deletions src/detect/ScanI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ScanI2C
QMC5883L,
HMC5883L,
PMSA0031,
QMA6100P,
MPU6050,
LIS3DH,
BMA423,
Expand Down
15 changes: 14 additions & 1 deletion src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,16 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
}
#endif

for (addr.address = 1; addr.address < 127; addr.address++) {
// We only need to scan 112 addresses, the rest is reserved for special purposes
// 0x00 General Call
// 0x01 CBUS addresses
// 0x02 Reserved for different bus formats
// 0x03 Reserved for future purposes
// 0x04-0x07 High Speed Master Code
// 0x78-0x7B 10-bit slave addressing
// 0x7C-0x7F Reserved for future purposes

for (addr.address = 8; addr.address < 120; addr.address++) {
if (asize != 0) {
if (!in_array(address, asize, addr.address))
continue;
Expand Down Expand Up @@ -395,7 +404,11 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)

SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found")
SCAN_SIMPLE_CASE(HMC5883L_ADDR, HMC5883L, "HMC5883L 3-Axis digital compass found")
#ifdef HAS_QMA6100P
SCAN_SIMPLE_CASE(QMA6100P_ADDR, QMA6100P, "QMA6100P accelerometer found")
#else
SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found")
#endif
SCAN_SIMPLE_CASE(BMA423_ADDR, BMA423, "BMA423 accelerometer found");
SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3 accelerometer found at address 0x%x", (uint8_t)addr.address);
SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535 I2C expander found");
Expand Down
4 changes: 2 additions & 2 deletions src/input/cardKbI2cImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CardKbI2cImpl::CardKbI2cImpl() : KbI2cBase("cardKB") {}

void CardKbI2cImpl::init()
{
#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_PORTDUINO)
#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_PORTDUINO) && !defined(I2C_NO_RESCAN)
if (cardkb_found.address == 0x00) {
LOG_DEBUG("Rescanning for I2C keyboard");
uint8_t i2caddr_scan[] = {CARDKB_ADDR, TDECK_KB_ADDR, BBQ10_KB_ADDR, MPR121_KB_ADDR};
Expand Down Expand Up @@ -49,7 +49,7 @@ void CardKbI2cImpl::init()
kb_model = 0x00;
}
}
LOG_DEBUG("Keyboard Type: 0x%02x Model: 0x%02x Address: 0x%02x\n", kb_info.type, kb_model, cardkb_found.address);
LOG_DEBUG("Keyboard Type: 0x%02x Model: 0x%02x Address: 0x%02x", kb_info.type, kb_model, cardkb_found.address);
if (cardkb_found.address == 0x00) {
disable();
return;
Expand Down
2 changes: 2 additions & 0 deletions src/modules/Telemetry/AirQualityTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int32_t AirQualityTelemetryModule::runOnce()
if (moduleConfig.telemetry.air_quality_enabled) {
LOG_INFO("Air quality Telemetry: Initializing");
if (!aqi.begin_I2C()) {
#ifndef I2C_NO_RESCAN
LOG_WARN("Could not establish i2c connection to AQI sensor. Rescanning...");
// rescan for late arriving sensors. AQI Module starts about 10 seconds into the boot so this is plenty.
uint8_t i2caddr_scan[] = {PMSA0031_ADDR};
Expand All @@ -51,6 +52,7 @@ int32_t AirQualityTelemetryModule::runOnce()
i2cScanner->fetchI2CBus(found.address);
return 1000;
}
#endif
return disable();
}
return 1000;
Expand Down
6 changes: 2 additions & 4 deletions variants/tracker-t1000-e/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
; tracker-t1000-e v0.9.1
[env:tracker-t1000-e]
extends = nrf52840_base
board = tracker-t1000-e
; board_level = extra
; platform = https://github.com/maxgerhardt/platform-nordicnrf52#cac6fcf943a41accd2aeb4f3659ae297a73f422e
build_flags = ${nrf52840_base.build_flags} -Ivariants/tracker-t1000-e -Isrc/platform/nrf52/softdevice -Isrc/platform/nrf52/softdevice/nrf52 -DTRACKER_T1000_E
-L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m4/fpv4-sp-d16-hard"
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
-DGPS_POWER_TOGGLE
board_build.ldscript = src/platform/nrf52/nrf52840_s140_v7.ld
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/tracker-t1000-e>
lib_deps =
${nrf52840_base.lib_deps}
https://github.com/meshtastic/QMA6100P_Arduino_Library.git#1f73284383a852dc593535a232cfab5fdc2c87fe
debug_tool = jlink
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
upload_protocol = nrfutil
2 changes: 1 addition & 1 deletion variants/tracker-t1000-e/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void initVariant()
digitalWrite(PIN_3V3_EN, HIGH);

pinMode(PIN_3V3_ACC_EN, OUTPUT);
digitalWrite(PIN_3V3_ACC_EN, LOW);
digitalWrite(PIN_3V3_ACC_EN, HIGH);

pinMode(BUZZER_EN_PIN, OUTPUT);
digitalWrite(BUZZER_EN_PIN, HIGH);
Expand Down
31 changes: 20 additions & 11 deletions variants/tracker-t1000-e/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern "C" {
#define LED_BLUE -1 // Actually green
#define LED_STATE_ON 1 // State when LED is lit

#define BUTTON_PIN (0 + 6) // P0.6
#define BUTTON_PIN (0 + 6) // P0.06
#define BUTTON_ACTIVE_LOW false
#define BUTTON_ACTIVE_PULLUP false
#define BUTTON_SENSE_TYPE 0x6
Expand All @@ -61,9 +61,10 @@ extern "C" {

#define WIRE_INTERFACES_COUNT 1

// unused pins
#define PIN_WIRE_SDA (0 + 9) // P0.26
#define PIN_WIRE_SCL (0 + 10) // P0.27
#define PIN_WIRE_SDA (0 + 26) // P0.26
#define PIN_WIRE_SCL (0 + 27) // P0.27
#define I2C_NO_RESCAN // I2C is a bit finicky, don't scan too much
#define HAS_QMA6100P // very rare beast, only on this board.

/*
* Serial interfaces
Expand Down Expand Up @@ -116,14 +117,22 @@ extern "C" {
#define PIN_GPS_RESET (32 + 15) // P1.15
#define GPS_RESET_MODE HIGH

#define GPS_VRTC_EN (0 + 8) // P0.8, awlays high
#define GPS_SLEEP_INT (32 + 12) // P1.12, awlays high
#define GPS_VRTC_EN (0 + 8) // P0.8, always high
#define GPS_SLEEP_INT (32 + 12) // P1.12, always high
#define GPS_RTC_INT (0 + 15) // P0.15, normal is LOW, wake by HIGH
#define GPS_RESETB_OUT (32 + 14) // P1.14, awlays input pull_up
#define GPS_RESETB_OUT (32 + 14) // P1.14, always input pull_up

#define GPS_FIX_HOLD_TIME 15000 // ms
#define BATTERY_PIN 2
#define BATTERY_PIN 2 // P0.02/AIN0, BAT_ADC
#define BATTERY_IMMUTABLE
#define ADC_MULTIPLIER (2.0F)
// P0.04/AIN2 is VCC_ADC, P0.05/AIN3 is CHARGER_DET, P1.03 is CHARGE_STA, P1.04 is CHARGE_DONE

#define EXT_CHRG_DETECT (32 + 3) // P1.03
#define EXT_CHRG_DETECT_VALUE LOW
// #define EXT_IS_CHRGD (32 + 4) // P1.04
// #define EXT_IS_CHRGD_VALUE LOW
#define EXT_PWR_DETECT (0 + 5) // P0.05

#define ADC_RESOLUTION 14
#define BATTERY_SENSE_RESOLUTION_BITS 12
Expand All @@ -133,13 +142,13 @@ extern "C" {
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0

// Buzzer
#define BUZZER_EN_PIN (32 + 5) // P1.05, awlays high
#define BUZZER_EN_PIN (32 + 5) // P1.05, always high
#define PIN_BUZZER (0 + 25) // P0.25, pwm output

#define T1000X_SENSOR_EN
#define T1000X_VCC_PIN (0 + 4) // P0.4
#define T1000X_NTC_PIN (0 + 31) // P0.31
#define T1000X_LUX_PIN (0 + 29) // P0.29
#define T1000X_NTC_PIN (0 + 31) // P0.31/AIN7
#define T1000X_LUX_PIN (0 + 29) // P0.29/AIN5

#ifdef __cplusplus
}
Expand Down

0 comments on commit fb65009

Please sign in to comment.