sforkowany z mirror/meshtastic-firmware
placeholder guess at PMU code until I have HW
rodzic
7bc299573f
commit
7fa9d09d9f
|
@ -11,7 +11,7 @@ Minimum items needed to make sure hardware is good.
|
|||
- Use the PMU driver
|
||||
- add a NEMA based GPS driver to test GPS
|
||||
- Use new radio driver - possibly start with https://os.mbed.com/teams/Semtech/code/SX126xLib/
|
||||
- Use UC1701 LCD driver. Still need to create at startup and probe on SPI
|
||||
- Use UC1701 LCD driver. Still need to create at startup and probe on SPI
|
||||
- test the LEDs
|
||||
- test the buttons
|
||||
- make a new boarddef with a variant.h file. Fix pins in that file. In particular (at least):
|
||||
|
@ -25,6 +25,9 @@ Minimum items needed to make sure hardware is good.
|
|||
|
||||
Needed to be fully functional at least at the same level of the ESP32 boards. At this point users would probably want them.
|
||||
|
||||
- enable BLE DFU somehow
|
||||
- set appversion/hwversion
|
||||
- report appversion/hwversion in BLE
|
||||
- use new LCD driver from screen.cpp. Still need to hook it to a subclass of (poorly named) OLEDDisplay, and override display() to stream bytes out to the screen.
|
||||
- get full BLE api working
|
||||
- we need to enable the external xtal for the sx1262 (on dio3)
|
||||
|
@ -35,9 +38,14 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
|
|||
- make a file system implementation (preferably one that can see the files the bootloader also sees)
|
||||
- make ble endpoints not require "start config", jsut have them start in config mode
|
||||
- measure power management and confirm battery life
|
||||
- use new PMU to provide battery voltage/% full to app (both bluetooth and screen)
|
||||
- do initial power measurements
|
||||
|
||||
## Items to be 'feature complete'
|
||||
|
||||
- call PMU set_ADC_CONV(0) during sleep, to stop reading PMU adcs and decrease current draw
|
||||
- do final power measurements
|
||||
- backport the common PMU API between AXP192 and PmuBQ25703A
|
||||
- use the new buttons in the UX
|
||||
- currently using soft device SD140, is that ideal?
|
||||
- turn on the watchdog timer, require servicing from key application threads
|
||||
|
@ -45,12 +53,15 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
|
|||
|
||||
## Things to do 'someday'
|
||||
|
||||
Nice ideas worth considering...
|
||||
Nice ideas worth considering someday...
|
||||
|
||||
- in addition to the main CPU watchdog, use the PMU watchdog as a really big emergency hammer
|
||||
- turn on 'shipping mode' in the PMU when device is 'off' - to cut battery draw to essentially zero
|
||||
- make Lorro_BQ25703A read/write operations atomic, current version could let other threads sneak in (once we start using threads)
|
||||
- turn on DFU assistance in the appload using the nordic DFU helper lib call
|
||||
- make the segger logbuffer larger, move it to RAM that is preserved across reboots and support reading it out at runtime (to allow full log messages to be included in crash reports). Share this code with ESP32
|
||||
- make the segger logbuffer larger, move it to RAM that is preserved across reboots and support reading it out at runtime (to allow full log messages to be included in crash reports). Share this code with ESP32
|
||||
- convert hardfaults/panics/asserts/wd exceptions into fault codes sent to phone
|
||||
- stop enumerating all i2c devices at boot, it wastes power & time
|
||||
|
||||
```
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
#include "PmuBQ25703A.h"
|
||||
#include <assert.h>
|
||||
|
||||
// Default address for device. Note, it is without read/write bit. When read with analyser,
|
||||
// this will appear 1 bit shifted to the left
|
||||
#define BQ25703ADevaddr 0xD6
|
||||
|
||||
const byte Lorro_BQ25703A::BQ25703Aaddr = BQ25703ADevaddr;
|
||||
|
||||
void PmuBQ25703A::init()
|
||||
{
|
||||
// Set the watchdog timer to not have a timeout
|
||||
regs.chargeOption0.set_WDTMR_ADJ(0);
|
||||
assert(writeRegEx(regs.chargeOption0)); // FIXME, instead log a critical hw failure and reboot
|
||||
delay(15); // FIXME, why are these delays required? - check datasheet
|
||||
|
||||
// Set the ADC on IBAT and PSYS to record values
|
||||
// When changing bitfield values, call the writeRegEx function
|
||||
// This is so you can change all the bits you want before sending out the byte.
|
||||
regs.chargeOption1.set_EN_IBAT(1);
|
||||
regs.chargeOption1.set_EN_PSYS(1);
|
||||
assert(writeRegEx(regs.chargeOption1));
|
||||
delay(15);
|
||||
|
||||
// Set ADC to make continuous readings. (uses more power)
|
||||
regs.aDCOption.set_ADC_CONV(1);
|
||||
// Set individual ADC registers to read. All have default off.
|
||||
regs.aDCOption.set_EN_ADC_VBUS(1);
|
||||
regs.aDCOption.set_EN_ADC_PSYS(1);
|
||||
regs.aDCOption.set_EN_ADC_IDCHG(1);
|
||||
regs.aDCOption.set_EN_ADC_ICHG(1);
|
||||
regs.aDCOption.set_EN_ADC_VSYS(1);
|
||||
regs.aDCOption.set_EN_ADC_VBAT(1);
|
||||
// Once bits have been twiddled, send bytes to device
|
||||
assert(writeRegEx(regs.aDCOption));
|
||||
delay(15);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
//Initialise the device and library
|
||||
Lorro_BQ25703A BQ25703A;
|
||||
|
||||
//Instantiate with reference to global set
|
||||
extern Lorro_BQ25703A::Regt BQ25703Areg;
|
||||
|
||||
uint32_t previousMillis;
|
||||
uint16_t loopInterval = 1000;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
uint32_t currentMillis = millis();
|
||||
|
||||
if( currentMillis - previousMillis > loopInterval ){
|
||||
previousMillis = currentMillis;
|
||||
|
||||
Serial.print( "Voltage of VBUS: " );
|
||||
Serial.print( BQ25703Areg.aDCVBUSPSYS.get_VBUS() );
|
||||
Serial.println( "mV" );
|
||||
delay( 15 );
|
||||
|
||||
Serial.print( "System power usage: " );
|
||||
Serial.print( BQ25703Areg.aDCVBUSPSYS.get_sysPower() );
|
||||
Serial.println( "W" );
|
||||
delay( 15 );
|
||||
|
||||
Serial.print( "Voltage of VBAT: " );
|
||||
Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VBAT() );
|
||||
Serial.println( "mV" );
|
||||
delay( 15 );
|
||||
|
||||
Serial.print( "Voltage of VSYS: " );
|
||||
Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VSYS() );
|
||||
Serial.println( "mV" );
|
||||
delay( 15 );
|
||||
|
||||
Serial.print( "Charging current: " );
|
||||
Serial.print( BQ25703Areg.aDCIBAT.get_ICHG() );
|
||||
Serial.println( "mA" );
|
||||
delay( 15 );
|
||||
|
||||
Serial.print( "Voltage of VSYS: " );
|
||||
Serial.print( BQ25703Areg.aDCIBAT.get_IDCHG() );
|
||||
Serial.println( "mA" );
|
||||
delay( 15 );
|
||||
|
||||
}
|
||||
|
||||
}*/
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <Lorro_BQ25703A.h>
|
||||
|
||||
class PmuBQ25703A : private Lorro_BQ25703A
|
||||
{
|
||||
Lorro_BQ25703A::Regt regs;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Configure the PMU for our board
|
||||
*/
|
||||
void init();
|
||||
|
||||
// Methods to have a common API with AXP192
|
||||
bool isBatteryConnect() { return true; } // FIXME
|
||||
bool isVBUSPlug() { return true; }
|
||||
bool isChargeing() { return true; } // FIXME, intentional misspelling
|
||||
|
||||
/// battery voltage in mV
|
||||
int getBattVoltage() { return 3200; }
|
||||
};
|
|
@ -16,9 +16,10 @@ static inline void debugger_break(void)
|
|||
// handle standard gcc assert failures
|
||||
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *failedexpr)
|
||||
{
|
||||
DEBUG_MSG("assert failed %s: %d, %s, test=%s\n", file, line, func, failedexpr);
|
||||
debugger_break();
|
||||
while (1)
|
||||
;
|
||||
; // FIXME, reboot!
|
||||
}
|
||||
|
||||
void getMacAddr(uint8_t *dmac)
|
||||
|
@ -57,3 +58,13 @@ void setBluetoothEnable(bool on)
|
|||
bleOn = on;
|
||||
}
|
||||
}
|
||||
|
||||
#include "PmuBQ25703A.h"
|
||||
|
||||
PmuBQ25703A pmu;
|
||||
|
||||
void nrf52Setup()
|
||||
{
|
||||
// Not yet on board
|
||||
// pmu.init();
|
||||
}
|
|
@ -163,6 +163,10 @@ void setup()
|
|||
esp32Setup();
|
||||
#endif
|
||||
|
||||
#ifdef NRF52_SERIES
|
||||
nrf52Setup();
|
||||
#endif
|
||||
|
||||
// Initialize the screen first so we can show the logo while we start up everything else.
|
||||
if (ssd1306_found)
|
||||
screen.setup();
|
||||
|
|
|
@ -14,3 +14,5 @@ extern meshtastic::Screen screen;
|
|||
const char *getDeviceName();
|
||||
|
||||
void getMacAddr(uint8_t *dmac);
|
||||
|
||||
void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop();
|
Ładowanie…
Reference in New Issue