Merge branch 'master' into disconnected-tip
This commit is contained in:
@@ -22,8 +22,8 @@ extern "C" {
|
||||
#include <gui.hpp>
|
||||
#include <history.hpp>
|
||||
#include <power.hpp>
|
||||
#ifdef POW_PD
|
||||
#include "policy_engine.h"
|
||||
#if POW_PD
|
||||
#include "USBPD.h"
|
||||
#endif
|
||||
// File local variables
|
||||
extern uint32_t currentTempTargetDegC;
|
||||
@@ -724,10 +724,10 @@ void showDebugMenu(void) {
|
||||
} else {
|
||||
// We are not powered via DC, so want to display the appropriate state for PD or QC
|
||||
bool poweredbyPD = false;
|
||||
#ifdef POW_PD
|
||||
if (usb_pd_detect()) {
|
||||
#if POW_PD
|
||||
if (USBPowerDelivery::fusbPresent()) {
|
||||
// We are PD capable
|
||||
if (PolicyEngine::pdHasNegotiated()) {
|
||||
if (USBPowerDelivery::negotiationComplete()) {
|
||||
// We are powered via PD
|
||||
poweredbyPD = true;
|
||||
}
|
||||
@@ -782,9 +782,9 @@ void showWarnings() {
|
||||
warnUser(translatedString(Tr->NoAccelerometerMessage), 10 * TICKS_SECOND);
|
||||
}
|
||||
}
|
||||
#ifdef POW_PD
|
||||
#if POW_PD
|
||||
// We expect pd to be present
|
||||
if (!usb_pd_detect()) {
|
||||
if (!USBPowerDelivery::fusbPresent()) {
|
||||
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
||||
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
|
||||
saveSettings();
|
||||
|
||||
@@ -30,44 +30,49 @@ TickType_t lastMovementTime = 0;
|
||||
|
||||
void detectAccelerometerVersion() {
|
||||
DetectedAccelerometerVersion = AccelType::Scanning;
|
||||
#ifdef ACCEL_SC7
|
||||
if (SC7A20::detect()) {
|
||||
// Setup the SC7A20 Accelerometer
|
||||
if (SC7A20::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::SC7;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef ACCEL_MMA
|
||||
if (MMA8652FC::detect()) {
|
||||
if (MMA8652FC::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::MMA;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
#ifdef ACCEL_LIS
|
||||
if (LIS2DH12::detect()) {
|
||||
if (LIS2DH12::detect()) {
|
||||
// Setup the ST Accelerometer
|
||||
if (LIS2DH12::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::LIS;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
#ifdef ACCEL_BMA
|
||||
if (BMA223::detect()) {
|
||||
if (BMA223::detect()) {
|
||||
// Setup the BMA223 Accelerometer
|
||||
if (BMA223::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::BMA;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
#ifdef ACCEL_MSA
|
||||
if (MSA301::detect()) {
|
||||
if (MSA301::detect()) {
|
||||
// Setup the MSA301 Accelerometer
|
||||
if (MSA301::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::MSA;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#ifdef ACCEL_SC7
|
||||
if (SC7A20::detect()) {
|
||||
// Setup the SC7A20 Accelerometer
|
||||
if (SC7A20::initalize()) {
|
||||
DetectedAccelerometerVersion = AccelType::SC7;
|
||||
}
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
{
|
||||
// disable imu sensitivity
|
||||
|
||||
@@ -9,29 +9,51 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "QC3.h"
|
||||
#include "Settings.h"
|
||||
#include "USBPD.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "fusbpd.h"
|
||||
#include "configuration.h"
|
||||
#include "main.hpp"
|
||||
#include "stdlib.h"
|
||||
#include "task.h"
|
||||
|
||||
// Small worker thread to handle power (mostly QC) related steps
|
||||
// Small worker thread to handle power (PD + QC) related steps
|
||||
|
||||
void startPOWTask(void const *argument __unused) {
|
||||
// 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
|
||||
#ifdef POW_PD
|
||||
if (usb_pd_detect() == true) {
|
||||
// Spawn all of the USB-C processors
|
||||
fusb302_start_processing();
|
||||
}
|
||||
#endif
|
||||
vTaskDelay(TICKS_100MS);
|
||||
// Init any other misc sensors
|
||||
postRToSInit();
|
||||
// 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
|
||||
USBPowerDelivery::step();
|
||||
|
||||
#endif
|
||||
BaseType_t res;
|
||||
for (;;) {
|
||||
res = pdFALSE;
|
||||
// While the interrupt is low, dont delay
|
||||
/*This is due to a possible race condition, where:
|
||||
* IRQ fires
|
||||
* We read interrupt register but dont see the Good CRC
|
||||
* Then Good CRC is set while reading it out (racing on I2C read)
|
||||
* Then we would sleep as nothing to do, but 100ms> 20ms power supply typical timeout
|
||||
*/
|
||||
if (!getFUS302IRQLow()) {
|
||||
res = xTaskNotifyWait(0x0, 0xFFFFFF, NULL, TICKS_100MS);
|
||||
}
|
||||
|
||||
#if POW_PD
|
||||
|
||||
if (res != pdFALSE || getFUS302IRQLow()) {
|
||||
USBPowerDelivery::IRQOccured();
|
||||
}
|
||||
USBPowerDelivery::step();
|
||||
USBPowerDelivery::PPSTimerCallback();
|
||||
#else
|
||||
(void)res;
|
||||
#endif
|
||||
power_check();
|
||||
osDelay(TICKS_100MS); // Slow down update rate
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user