feat(esp_hal_usb): Add remote wakeup support

This commit is contained in:
peter.marcisovsky
2025-10-07 11:33:16 +02:00
parent d13533ba7f
commit 7fbf68a3f5
2 changed files with 7 additions and 3 deletions
@@ -67,6 +67,7 @@ typedef enum {
USB_DWC_HAL_PORT_EVENT_DISABLED, /**< The host port has been disabled (no more SOFs). Could be due to disable/reset request, or a port error (e.g. port babble condition. See 11.8.1 of USB2.0 spec) */
USB_DWC_HAL_PORT_EVENT_OVRCUR, /**< The host port has encountered an overcurrent condition */
USB_DWC_HAL_PORT_EVENT_OVRCUR_CLR, /**< The host port has been cleared of the overcurrent condition */
USB_DWC_HAL_PORT_EVENT_REMOTE_WAKEUP, /**< The host port has detected remote wakeup sequence from a device */
} usb_dwc_hal_port_event_t;
/**
@@ -304,7 +305,7 @@ static inline void usb_dwc_hal_port_init(usb_dwc_hal_context_t *hal)
{
//Configure Host related interrupts
usb_dwc_ll_haintmsk_dis_chan_intr(hal->dev, 0xFFFFFFFF); //Disable interrupts for all channels
usb_dwc_ll_gintmsk_en_intrs(hal->dev, USB_DWC_LL_INTR_CORE_PRTINT | USB_DWC_LL_INTR_CORE_HCHINT);
usb_dwc_ll_gintmsk_en_intrs(hal->dev, USB_DWC_LL_INTR_CORE_PRTINT | USB_DWC_LL_INTR_CORE_HCHINT | USB_DWC_LL_INTR_CORE_WKUPINT);
}
/**
@@ -317,7 +318,7 @@ static inline void usb_dwc_hal_port_init(usb_dwc_hal_context_t *hal)
static inline void usb_dwc_hal_port_deinit(usb_dwc_hal_context_t *hal)
{
//Disable Host port and channel interrupts
usb_dwc_ll_gintmsk_dis_intrs(hal->dev, USB_DWC_LL_INTR_CORE_PRTINT | USB_DWC_LL_INTR_CORE_HCHINT);
usb_dwc_ll_gintmsk_dis_intrs(hal->dev, USB_DWC_LL_INTR_CORE_PRTINT | USB_DWC_LL_INTR_CORE_HCHINT | USB_DWC_LL_INTR_CORE_WKUPINT);
}
/**
+4 -1
View File
@@ -44,7 +44,8 @@
//Interrupts that pertain to core events
#define CORE_EVENTS_INTRS_MSK (USB_DWC_LL_INTR_CORE_DISCONNINT | \
USB_DWC_LL_INTR_CORE_HCHINT)
USB_DWC_LL_INTR_CORE_HCHINT | \
USB_DWC_LL_INTR_CORE_WKUPINT)
//Interrupt that pertain to host port events
#define PORT_EVENTS_INTRS_MSK (USB_DWC_LL_INTR_HPRT_PRTCONNDET | \
@@ -462,6 +463,8 @@ usb_dwc_hal_port_event_t usb_dwc_hal_decode_intr(usb_dwc_hal_context_t *hal)
} else if (intrs_port & USB_DWC_LL_INTR_HPRT_PRTCONNDET && !hal->flags.dbnc_lock_enabled) {
event = USB_DWC_HAL_PORT_EVENT_CONN;
debounce_lock_enable(hal);
} else if (intrs_core & USB_DWC_LL_INTR_CORE_WKUPINT) {
event = USB_DWC_HAL_PORT_EVENT_REMOTE_WAKEUP; // Remote wakeup was generated from device
}
}
//Port events always take precedence over channel events