diff options
-rw-r--r-- | common/usb_pd_protocol.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 20d713f628..ccfeb944e6 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2539,6 +2539,7 @@ void pd_task(void *u) enum pd_states this_state; enum pd_cc_states new_cc_state; timestamp_t now; + uint64_t next_src_cap = 0; int caps_count = 0, hard_reset_sent = 0; int snk_cap_count = 0; int evt; @@ -3023,8 +3024,10 @@ void pd_task(void *u) } break; case PD_STATE_SRC_DISCOVERY: + now = get_time(); if (pd[port].last_state != pd[port].task_state) { caps_count = 0; + next_src_cap = now.val; /* * If we have had PD connection with this port * partner, then start NoResponseTimer. @@ -3040,7 +3043,8 @@ void pd_task(void *u) } /* Send source cap some minimum number of times */ - if (caps_count < PD_CAPS_COUNT) { + if (caps_count < PD_CAPS_COUNT && + next_src_cap <= now.val) { /* Query capabilities of the other side */ res = send_source_cap(port); /* packet was acked => PD capable device) */ @@ -3055,8 +3059,12 @@ void pd_task(void *u) PD_FLAGS_PREVIOUS_PD_CONN; } else { /* failed, retry later */ timeout = PD_T_SEND_SOURCE_CAP; + next_src_cap = now.val + + PD_T_SEND_SOURCE_CAP; caps_count++; } + } else if (caps_count < PD_CAPS_COUNT) { + timeout = next_src_cap - now.val; } break; case PD_STATE_SRC_NEGOCIATE: |