|
@@ -51,6 +51,8 @@ static union pd_msg *policy_engine_message = NULL;
|
51
|
51
|
static bool capability_match = false;
|
52
|
52
|
/* Whether or not we have an explicit contract */
|
53
|
53
|
static bool explicit_contract = false;
|
|
54
|
+/* Keep track of how many hard resets we've sent */
|
|
55
|
+static int hard_reset_counter = 0;
|
54
|
56
|
/* Policy Engine thread mailbox */
|
55
|
57
|
static msg_t pdb_pe_mailbox_queue[PDB_MSG_POOL_SIZE];
|
56
|
58
|
mailbox_t pdb_pe_mailbox;
|
|
@@ -359,11 +361,20 @@ static enum policy_engine_state pe_sink_give_sink_cap(void)
|
359
|
361
|
|
360
|
362
|
static enum policy_engine_state pe_sink_hard_reset(void)
|
361
|
363
|
{
|
|
364
|
+ /* If we've already sent the maximum number of hard resets, give up */
|
|
365
|
+ if (hard_reset_counter > PD_N_HARD_RESET_COUNT) {
|
|
366
|
+ pdb_dpm_output_off();
|
|
367
|
+ /* TODO: Fall back to USB BC or Type-C power if configured for 5 V. */
|
|
368
|
+ for (;;)
|
|
369
|
+ chThdSleepMilliseconds(1000);
|
|
370
|
+ }
|
|
371
|
+
|
362
|
372
|
/* Generate a hard reset signal */
|
363
|
373
|
chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_RESET);
|
364
|
374
|
chEvtWaitAny(PDB_EVT_PE_HARD_SENT);
|
365
|
375
|
|
366
|
|
- /* TODO: maintain HardResetCounter */
|
|
376
|
+ /* Increment HardResetCounter */
|
|
377
|
+ hard_reset_counter++;
|
367
|
378
|
|
368
|
379
|
return PESinkTransitionDefault;
|
369
|
380
|
}
|