mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Support for S99
* Enable PD Options * Make PDNegTimeout configureable * Add default value for PDNegTimeout, also for S60 and S60P * Add basic DC detection / correct debug readings while powered via DC * Add basic ThermoModel for C245 Tips * Modify op-amp gain
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "QC3.h"
|
||||
#include "Settings.h"
|
||||
#include "USBPD.h"
|
||||
#include "FS2711.hpp"
|
||||
#include "configuration.h"
|
||||
|
||||
void power_check() {
|
||||
@@ -16,9 +17,26 @@ void power_check() {
|
||||
return; // We are using PD
|
||||
}
|
||||
#endif
|
||||
#if POW_PD_EXT == 2
|
||||
if (FS2711::has_run_selection()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef POW_QC
|
||||
QC_resync();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool getIsPoweredByDCIN() { return false; }
|
||||
bool getIsPoweredByDCIN() {
|
||||
#if POW_PD_EXT == 2 && defined(POW_DC)
|
||||
if (!FS2711::has_run_selection()) {
|
||||
return true;
|
||||
} else if(FS2711::debug_get_state().source_voltage > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -8,4 +8,11 @@
|
||||
#include "Utils.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#if defined(TEMP_uV_LOOKUP_S60)
|
||||
TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 50) / 485; }
|
||||
#elif defined(TEMP_uV_LOOKUP_S99)
|
||||
// 42.85 uV / K -> 1/42.85 K/uV = 20/857
|
||||
// TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 20) / 857; }
|
||||
// Measurement is probably with heating element in series, thats why the reading differs from the approx 42.85 uV/K
|
||||
TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 1) / 30; }
|
||||
#endif
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
#define OP_AMP_GAIN_STAGE 536
|
||||
#define TEMP_uV_LOOKUP_S60
|
||||
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
|
||||
#define USB_PD_TIMEOUT 1 // Default Timeout for USB-PD Protocol negotiation in x100ms
|
||||
|
||||
#define HARDWARE_MAX_WATTAGE_X10 600
|
||||
|
||||
@@ -176,6 +177,7 @@
|
||||
#define OP_AMP_GAIN_STAGE 536
|
||||
#define TEMP_uV_LOOKUP_S60
|
||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||
#define USB_PD_TIMEOUT 1 // Default Timeout for USB-PD Protocol negotiation in x100ms
|
||||
|
||||
#define HARDWARE_MAX_WATTAGE_X10 600
|
||||
|
||||
@@ -204,11 +206,12 @@
|
||||
#define POWER_LIMIT 0 // 0 watts default limit
|
||||
#define MAX_POWER_LIMIT 70
|
||||
#define POWER_LIMIT_STEPS 5
|
||||
#define OP_AMP_GAIN_STAGE 536
|
||||
#define TEMP_uV_LOOKUP_S60
|
||||
#define OP_AMP_GAIN_STAGE 237 // Two sequential op-amps 1st: 1+(9k29/997R)=10.31 2nd: 1+(22k/1k)=23 -> 10.31*23=237
|
||||
#define TEMP_uV_LOOKUP_S99
|
||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||
#define USB_PD_TIMEOUT 2 // Default Timeout for USB-PD Protocol negotiation in x100ms
|
||||
|
||||
#define HARDWARE_MAX_WATTAGE_X10 600
|
||||
#define HARDWARE_MAX_WATTAGE_X10 1300
|
||||
|
||||
#define TIP_THERMAL_MASS 8 // X10 watts to raise 1 deg C in 1 second
|
||||
#define TIP_THERMAL_INERTIA 128 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive
|
||||
@@ -219,6 +222,7 @@
|
||||
#define GPIO_VIBRATION
|
||||
#define POW_PD_EXT 2
|
||||
#define USB_PD_EPR_WATTAGE 0 /*No EPR*/
|
||||
#define POW_DC
|
||||
#define DEBUG_POWER_MENU_BUTTON_B 1
|
||||
#define HAS_POWER_DEBUG_MENU
|
||||
#define TEMP_NTC
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "I2CBB2.hpp"
|
||||
#include "configuration.h"
|
||||
#include "Settings.h"
|
||||
#include "Utils.h"
|
||||
#if POW_PD_EXT == 2
|
||||
#include "BSP.h"
|
||||
#include "cmsis_os.h"
|
||||
@@ -33,11 +34,11 @@ void FS2711::start() {
|
||||
state.req_pdo_num = 0xFF;
|
||||
|
||||
enable_protocol(false);
|
||||
// PDNegTimeout is in 1/100 s, so x10 for ms
|
||||
osDelay(getSettingValue(SettingsOptions::PDNegTimeout)*10);
|
||||
// PDNegTimeout is in 100ms, so x100 for ms
|
||||
osDelay(getSettingValue(SettingsOptions::PDNegTimeout)*100);
|
||||
select_protocol(FS2711_PROTOCOL_PD);
|
||||
enable_protocol(true);
|
||||
osDelay(getSettingValue(SettingsOptions::PDNegTimeout)*10);
|
||||
osDelay(getSettingValue(SettingsOptions::PDNegTimeout)*100);
|
||||
}
|
||||
|
||||
uint8_t FS2711::selected_protocol() { return i2c_read(FS2711_REG_SELECT_PROTOCOL); }
|
||||
@@ -161,6 +162,11 @@ void FS2711::negotiate() {
|
||||
if (getSettingValue(SettingsOptions::USBPDMode) == 1) {
|
||||
tip_resistance += 5;
|
||||
}
|
||||
#ifdef MODEL_HAS_DCDC
|
||||
// If this device has step down DC/DC inductor to smooth out current spikes
|
||||
// We can instead ignore resistance and go for max voltage we can accept; and rely on the DC/DC regulation to keep under current limit
|
||||
tip_resistance = 255; // (Push to 25.5 ohms to effectively disable this check)
|
||||
#endif
|
||||
|
||||
uint16_t pdo_min_mv = 0, pdo_max_mv = 0, pdo_max_curr = 0, pdo_type = 0;
|
||||
|
||||
@@ -226,7 +232,7 @@ bool FS2711::has_run_selection() { return state.req_pdo_num != 0xFF; }
|
||||
|
||||
uint16_t FS2711::source_voltage() { return state.source_voltage / 1000; }
|
||||
|
||||
// FS2711 does current in mV so it needs to be converted to x100 intead of x1000
|
||||
// FS2711 does current in mA so it needs to be converted to x100 intead of x1000
|
||||
uint16_t FS2711::source_currentx100() { return state.source_current / 10; }
|
||||
|
||||
uint16_t FS2711::debug_pdo_max_voltage(uint8_t pdoid) { return state.pdo_max_volt[pdoid]; }
|
||||
|
||||
@@ -83,7 +83,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
|
||||
{ 0, 9, 1, 0}, // AccelMissingWarningCounter
|
||||
{ 0, 9, 1, 0}, // PDMissingWarningCounter
|
||||
{ 0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
|
||||
{ 0, 50, 1, 20}, // PDNegTimeout
|
||||
{ 0, 50, 1, USB_PD_TIMEOUT}, // PDNegTimeout
|
||||
{ 0, 1, 1, 0}, // OLEDInversion
|
||||
{ MIN_BRIGHTNESS, MAX_BRIGHTNESS, BRIGHTNESS_STEP, DEFAULT_BRIGHTNESS}, // OLEDBrightness
|
||||
{ 0, 6, 1, 1}, // LOGOTime
|
||||
|
||||
@@ -24,7 +24,7 @@ static void displayInputMinVRange(void);
|
||||
static void displayQCInputV(void);
|
||||
#endif /* POW_QC */
|
||||
|
||||
#ifdef POW_PD
|
||||
#if defined POW_PD || POW_PD_EXT == 2
|
||||
static void displayPDNegTimeout(void);
|
||||
static void displayUSBPDMode(void);
|
||||
#endif /* POW_PD */
|
||||
@@ -225,7 +225,7 @@ const menuitem rootSettingsMenu[] {
|
||||
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||
};
|
||||
|
||||
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
|
||||
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD) || POW_PD_EXT == 2
|
||||
const menuitem powerMenu[] = {
|
||||
/*
|
||||
* Power Source
|
||||
@@ -244,7 +244,7 @@ const menuitem powerMenu[] = {
|
||||
/* Voltage input */
|
||||
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), nullptr, displayQCInputV, nullptr, SettingsOptions::QCIdealVoltage, SettingsItemIndex::QCMaxVoltage, 4},
|
||||
#endif
|
||||
#ifdef POW_PD
|
||||
#if defined(POW_PD) || POW_PD_EXT == 2
|
||||
/* PD timeout setup */
|
||||
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), nullptr, displayPDNegTimeout, nullptr, SettingsOptions::PDNegTimeout, SettingsItemIndex::PDNegTimeout, 6},
|
||||
/* Toggle PPS & EPR */
|
||||
@@ -433,7 +433,7 @@ const menuitem advancedMenu[] = {
|
||||
/* clang-format on */
|
||||
|
||||
const menuitem *subSettingsMenus[] {
|
||||
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
|
||||
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD) || POW_PD_EXT == 2
|
||||
powerMenu,
|
||||
#endif
|
||||
solderingMenu, PowerSavingMenu, UIMenu, advancedMenu,
|
||||
@@ -518,7 +518,7 @@ static void displayQCInputV(void) {
|
||||
|
||||
#endif /* POW_QC */
|
||||
|
||||
#ifdef POW_PD /* POW_PD */
|
||||
#if defined(POW_PD) || POW_PD_EXT == 2 /* POW_PD */
|
||||
|
||||
static void displayPDNegTimeout(void) {
|
||||
auto value = getSettingValue(SettingsOptions::PDNegTimeout);
|
||||
|
||||
@@ -23,6 +23,10 @@ extern "C" {
|
||||
#include "USBPD.h"
|
||||
#include "pd.h"
|
||||
#endif
|
||||
#if POW_PD_EXT == 2
|
||||
#include "FS2711.hpp"
|
||||
#include "FS2711_defines.h"
|
||||
#endif
|
||||
|
||||
enum class OperatingMode {
|
||||
StartupLogo = 0, // Showing the startup logo
|
||||
|
||||
@@ -132,6 +132,13 @@ int8_t getPowerSourceNumber(void) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if POW_PD_EXT == 2
|
||||
if (FS2711::has_run_selection()) {
|
||||
poweredbyPD = true;
|
||||
// FS2711IC has VBUS always connected
|
||||
pdHasVBUSConnected = true;
|
||||
}
|
||||
#endif
|
||||
if (poweredbyPD) {
|
||||
if (pdHasVBUSConnected) {
|
||||
|
||||
Reference in New Issue
Block a user