USB PD timeout added
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "int_n.h"
|
||||
#include <pd.h>
|
||||
#include <stdbool.h>
|
||||
#include "Settings.h"
|
||||
|
||||
bool PolicyEngine::pdNegotiationComplete;
|
||||
int PolicyEngine::current_voltage_mv;
|
||||
int PolicyEngine::_requested_voltage;
|
||||
@@ -617,6 +619,18 @@ void PolicyEngine::PPSTimerCallback() {
|
||||
}
|
||||
}
|
||||
|
||||
bool PolicyEngine::NegotiationTimeoutReached() {
|
||||
if (systemSettings.PDNegTimeout == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xTaskGetTickCount() > (TICKS_SECOND/10 * systemSettings.PDNegTimeout)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EventBits_t PolicyEngine::pushMessage(union pd_msg *msg) {
|
||||
if (PD_MSGTYPE_GET(msg) == PD_MSGTYPE_SOFT_RESET && PD_NUMOBJ_GET(msg) == 0) {
|
||||
/* Clear MessageIDCounter */
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
static bool setupCompleteOrTimedOut() {
|
||||
if (pdNegotiationComplete)
|
||||
return true;
|
||||
if (PolicyEngine::NegotiationTimeoutReached())
|
||||
return true;
|
||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||
return true;
|
||||
if (state == policy_engine_state::PESinkReady)
|
||||
@@ -46,11 +48,17 @@ public:
|
||||
static bool pdHasNegotiated() {
|
||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||
return false;
|
||||
if (pdNegotiationComplete)
|
||||
return true;
|
||||
if (PolicyEngine::NegotiationTimeoutReached())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
// Call this periodically, at least once every second
|
||||
static void PPSTimerCallback();
|
||||
|
||||
static bool NegotiationTimeoutReached();
|
||||
|
||||
enum class Notifications {
|
||||
PDB_EVT_PE_RESET = EVENT_MASK(0),
|
||||
PDB_EVT_PE_MSG_RX = EVENT_MASK(1),
|
||||
|
||||
Reference in New Issue
Block a user