Pinecil V2 (#1341)

* Add SDK

* fork

* massaging makefile

* Drop git module

* Bring in sdk as its broken

Far, Far to much crap to fix with regex now

* Remove bl706

* rf_para_flash_t is missing defs

* Remove crapton of junk

* Remove yet more

* Poking I2C

* Update peripheral_config.h

* Update pinmux_config.h

* Update preRTOS.cpp

* Update main.hpp

* Setup template

* Verbose boot

* I2C ish

* Update I2C_Wrapper.cpp

* Update main.cpp

* Turn off I2C reading for now

* Display running

* Roughing out scheduling timer0

* Starting ADC setup

* Working scheduling of ADC 🎉

* Format adc headers

* Update IRQ.cpp

* Buttons working

* Slow down I2C

* Poking IRQ

* Larger stack required

* Accel on

* Trying to chase down why __libc_init_array isnt working yet

* Working c++

* Cleanup

* Bump stacks

* I2C wake part workaround

* Cleanup

* Working PWM init

* qc draft

* Hookup PWM

* Stable enough ADC

* ADC timing faster + timer without HAL

* Silence

* Remove boot banner

* Tuning in ADC

* Wake PID after ADC

* Remove unused hal

* Draft flash settings

* Working settings save & restore

* Update to prod model

* Cleanup

* NTC thermistor

* Correct adc gain

* Rough tip resistance progress

* Scratch out resistance awareness of the tip

* better adc settings

* Tweaking ADC

* ADC tweaking

* Make adc range scalable

* Update Dockerfile

* Update configuration.h

* Can read same ADC twice in a row

* ADC Setup

* Update PIDThread.cpp

* Lesser adc backoff

* Update USBPD.h

* Add device ID

* Update BSP_Power.h

* Update BSP.cpp

* DrawHex dynamicLength

* Shorter ID padding

* Show validation code

* tip measurement

* Create access for w0w1

* Expose w0 w1

* Enable debug

* crc32

* Device validation

* wip starting epr

* Logic refactor

* Safer PWM Init

* PD cleanups

* Update bl702_pwm.c

* Update power.cpp

* Update usb-pd

* io

* EPR decode

* Better gui for showing pd specs

* Rough handler for capabilities

* EPR

* Fix > 25V input

* Perform pow step after PPS

* Update BSP.cpp

* Fix timer output

* QC3

* Add tip resistance view

* Hold PD negotiation until detection is done for tip res

* Get Thermal mass

* Tip res =0 protection

* Update PIDThread.cpp

* Update GUIThread.cpp

* Rewrite tip resistance measurement

* Update GUIThread.cpp

* Fix fallback

* Far better tip resistance measurement

* Fix QC 0.6V D-

* Convert the interpolator to int32

* Correct the NTC lookup

* Update BSP.cpp

* Update Setup.cpp

* .

Update configuration #defines

More backported functions

* Update usb-pd

* More missed updates

* Refactor BSP

Magic BSP -> PinecilV2
Pine64 BSP -> Pinecil

Update Makefile

* Add Pinecilv2 to CI

* Pinecil v2 multi-lang

Update push.yml

* Update HallSensor.md

* Update README.md

* Fix wrong prestartcheck default

* Fix logo mapping

* Update Makefile

* Remove unused font block

* Style

* Style

* Remove unused timer funcs

* More culling TS80P

* Revert "More culling TS80P"

This reverts commit 2078b89be7.

* Revert "Remove unused timer funcs"

This reverts commit 0c693a89cc.

* Make VBus check maskable

* Remove DMA half transfer

* Drop using brightness and invert icons and go back to text

Saves flash space

* Refactor settings UI drawing descriptions

* Shorten setting function names

* Store bin file assets

* Fix MHP prestart
This commit is contained in:
Ben V. Brown
2022-08-19 15:39:37 +10:00
committed by GitHub
parent 61a679115d
commit 1fbcdcdf98
428 changed files with 165913 additions and 1380 deletions

View File

@@ -42,7 +42,7 @@ void showWarnings();
#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
static TickType_t lastHallEffectSleepStart = 0;
static uint16_t min(uint16_t a, uint16_t b) {
if (a > b)
if (a > b)
return b;
else
return a;
@@ -132,14 +132,14 @@ static bool checkVoltageForExit() {
static void gui_drawBatteryIcon() {
#if defined(POW_PD) || defined(POW_QC)
if (!getIsPoweredByDCIN()) {
// On TS80 we replace this symbol with the voltage we are operating on
// On non-DC inputs we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show dual small ones vertically stacked
uint8_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
if (V % 10 >= 5)
V = V / 10 + 1; // round up
V = (V / 10) + 1; // round up
else
V = V / 10;
if (V >= 10) {
if (V > 9) {
int16_t xPos = OLED::getCursorX();
OLED::printNumber(V / 10, 1, FontStyle::SMALL);
OLED::setCursor(xPos, 8);
@@ -758,8 +758,16 @@ void showDebugMenu(void) {
// Print device ID Numbers
{
uint64_t id = getDeviceID();
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
#ifdef DEVICE_HAS_VALIDATION_CODE
// If device has validation code; then we want to take over both lines of the screen
OLED::clearScreen(); // Ensure the buffer starts clean
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(DebugMenu[screen], FontStyle::SMALL);
OLED::drawHex(getDeviceValidation(), FontStyle::SMALL, 8);
OLED::setCursor(0, 8); // second line
#endif
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL, 8);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL, 8);
}
break;
case 10:
@@ -767,19 +775,26 @@ void showDebugMenu(void) {
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
break;
case 11:
// Tip resistance
OLED::printNumber(getTipResistanceX10() / 10, 4, FontStyle::SMALL); // large to pad over so that we cover ID left overs
OLED::print(SymbolDot, FontStyle::SMALL);
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
break;
case 12:
// High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break;
case 12:
case 13:
// High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break;
case 13:
case 14:
// High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break;
break;
#ifdef HALL_SENSOR
case 14:
case 15:
// Print raw hall effect value if availabe, none if hall effect disabled.
{
int16_t hallEffectStrength = getRawHallEffect();
@@ -801,9 +816,9 @@ void showDebugMenu(void) {
else if (b == BUTTON_F_SHORT) {
screen++;
#ifdef HALL_SENSOR
screen = screen % 15;
screen = screen % 16;
#else
screen = screen % 14;
screen = screen % 15;
#endif
}
GUIDelay();
@@ -906,6 +921,12 @@ void showWarnings() {
if (settingsWereReset) {
warnUser(translatedString(Tr->SettingsResetMessage), 10 * TICKS_SECOND);
}
#ifdef DEVICE_HAS_VALIDATION_SUPPORT
if (getDeviceValidationStatus()) {
// Warn user this device might be counterfeit
warnUser(translatedString(Tr->DeviceFailedValidationWarning), 10 * TICKS_SECOND);
}
#endif
#ifndef NO_WARN_MISSING
// We also want to alert if accel or pd is not detected / not responding
// In this case though, we dont want to nag the user _too_ much
@@ -951,6 +972,7 @@ void startGUITask(void const *argument) {
bool tempOnDisplay = false;
bool tipDisconnectedDisplay = false;
bool showExitMenuTransition = false;
{
// Generate the flipped screen into ram for later use
// flipped is generated by flipping each row
@@ -962,7 +984,9 @@ void startGUITask(void const *argument) {
}
}
}
getTipRawTemp(1); // reset filter
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
// If the front button is held down, on supported devices, show PD debugging metrics
#if POW_PD
@@ -973,10 +997,8 @@ void startGUITask(void const *argument) {
#endif
#endif
// If the boot logo is enabled (but it times out) and the autostart mode is enabled (but not set to sleep w/o heat), start heating during boot logo
if (getSettingValue(SettingsOptions::LOGOTime) > 0 &&
getSettingValue(SettingsOptions::LOGOTime) < 5 &&
getSettingValue(SettingsOptions::AutoStartMode) > 0 &&
getSettingValue(SettingsOptions::AutoStartMode) < 3) {
if (getSettingValue(SettingsOptions::LOGOTime) > 0 && getSettingValue(SettingsOptions::LOGOTime) < 5 && getSettingValue(SettingsOptions::AutoStartMode) > 0
&& getSettingValue(SettingsOptions::AutoStartMode) < 3) {
uint16_t sleepTempDegC;
if (getSettingValue(SettingsOptions::TemperatureInF)) {
sleepTempDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SleepTemp));
@@ -987,11 +1009,9 @@ void startGUITask(void const *argument) {
currentTempTargetDegC = min(sleepTempDegC, 75);
}
BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);
showWarnings();
if (getSettingValue(SettingsOptions::AutoStartMode)) {
// jump directly to the autostart mode
gui_solderingMode(getSettingValue(SettingsOptions::AutoStartMode) - 1);

View File

@@ -14,6 +14,7 @@
#include "main.hpp"
#include "power.hpp"
#include "task.h"
static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s
static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms
TaskHandle_t pidTaskNotification = NULL;
@@ -45,7 +46,8 @@ void startPIDTask(void const *argument __unused) {
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1);
}
while (preStartChecks() != 0) {
while (preStartChecks() == 0) {
resetWatchdog();
ulTaskNotifyTake(pdTRUE, 2000);
}
@@ -141,7 +143,7 @@ int32_t getPIDResultX10Watts(int32_t setpointDelta) {
// TIM3->CTR1 is configured with a duty cycle of 50% so, in real, we get only 50% of the presumed power output
// so we basically double the need (gain = 2) to get what we want.
return powerStore.update(TIP_THERMAL_MASS * setpointDelta, // the required power
TIP_THERMAL_MASS, // Inertia, smaller numbers increase dominance of the previous value
getTipThermalMass(), // Inertia, smaller numbers increase dominance of the previous value
2, // gain
rate, // PID cycle frequency
getX10WattageLimits());

View File

@@ -21,9 +21,11 @@
void startPOWTask(void const *argument __unused) {
// Init any other misc sensors
postRToSInit();
while (preStartChecksDone() == 0) {
osDelay(3);
}
// You have to run this once we are willing to answer PD messages
// Setting up too early can mean that we miss the ~20ms window to respond on some chargers
#if POW_PD
USBPowerDelivery::start();
// Crank the handle at boot until we are stable and waiting for IRQ
@@ -41,16 +43,16 @@ void startPOWTask(void const *argument __unused) {
* Then we would sleep as nothing to do, but 100ms> 20ms power supply typical timeout
*/
if (!getFUS302IRQLow()) {
res = xTaskNotifyWait(0x0, 0xFFFFFF, NULL, TICKS_100MS);
res = xTaskNotifyWait(0x0, 0xFFFFFF, NULL, TICKS_100MS / 2);
}
#if POW_PD
if (res != pdFALSE || getFUS302IRQLow()) {
USBPowerDelivery::IRQOccured();
}
USBPowerDelivery::step();
USBPowerDelivery::PPSTimerCallback();
USBPowerDelivery::step();
#else
(void)res;
#endif