diff options
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r-- | common/usb_pd_protocol.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index a75baa5c14..6c71c155cc 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2577,8 +2577,8 @@ void pd_interrupt_handler_task(void *p) const int port_mask = (PD_STATUS_TCPC_ALERT_0 << port); struct { int count; - uint32_t time; - } storm_tracker[CONFIG_USB_PD_PORT_COUNT] = { 0 }; + timestamp_t time; + } storm_tracker[CONFIG_USB_PD_PORT_COUNT] = {}; ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); @@ -2601,14 +2601,17 @@ void pd_interrupt_handler_task(void *p) */ while ((tcpc_get_alert_status() & port_mask) && pd_is_port_enabled(port)) { - uint32_t now; + timestamp_t now; tcpc_alert(port); - now = get_time().le.lo; - if (time_after(now, storm_tracker[port].time)) { - storm_tracker[port].time = - now + ALERT_STORM_INTERVAL; + now = get_time(); + if (timestamp_expired( + storm_tracker[port].time, &now)) { + /* Reset timer into future */ + storm_tracker[port].time.val = + now.val + ALERT_STORM_INTERVAL; + /* * Start at 1 since we are processing * an interrupt now |