Merge pull request #2873 from HiFiPhile/susp_isr
DWC2: fix recurrent suspend ISR without Vbus connected
This commit is contained in:
@@ -53,6 +53,7 @@ void OTG_HS_IRQHandler(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO TYPEDEF CONSTANT ENUM
|
// MACRO TYPEDEF CONSTANT ENUM
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
#ifdef UART_DEV
|
||||||
UART_HandleTypeDef UartHandle = {
|
UART_HandleTypeDef UartHandle = {
|
||||||
.Instance = UART_DEV,
|
.Instance = UART_DEV,
|
||||||
.Init = {
|
.Init = {
|
||||||
@@ -65,6 +66,7 @@ UART_HandleTypeDef UartHandle = {
|
|||||||
.OverSampling = UART_OVERSAMPLING_16
|
.OverSampling = UART_OVERSAMPLING_16
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
board_clock_init();
|
board_clock_init();
|
||||||
@@ -233,7 +235,7 @@ int board_uart_write(void const *buf, int len) {
|
|||||||
HAL_UART_Transmit(&UartHandle, (uint8_t *) (uintptr_t) buf, len, 0xffff);
|
HAL_UART_Transmit(&UartHandle, (uint8_t *) (uintptr_t) buf, len, 0xffff);
|
||||||
return len;
|
return len;
|
||||||
#else
|
#else
|
||||||
(void) buf; (void) len; (void) UartHandle;
|
(void) buf; (void) len;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -431,7 +431,7 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable required interrupts
|
// Enable required interrupts
|
||||||
dwc2->gintmsk |= GINTMSK_OTGINT | GINTMSK_USBSUSPM | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM;
|
dwc2->gintmsk |= GINTMSK_OTGINT | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM;
|
||||||
|
|
||||||
// TX FIFO empty level for interrupt is complete empty
|
// TX FIFO empty level for interrupt is complete empty
|
||||||
uint32_t gahbcfg = dwc2->gahbcfg;
|
uint32_t gahbcfg = dwc2->gahbcfg;
|
||||||
@@ -1032,16 +1032,19 @@ void dcd_int_handler(uint8_t rhport) {
|
|||||||
if (gintsts & GINTSTS_ENUMDNE) {
|
if (gintsts & GINTSTS_ENUMDNE) {
|
||||||
// ENUMDNE is the end of reset where speed of the link is detected
|
// ENUMDNE is the end of reset where speed of the link is detected
|
||||||
dwc2->gintsts = GINTSTS_ENUMDNE;
|
dwc2->gintsts = GINTSTS_ENUMDNE;
|
||||||
|
dwc2->gintmsk |= GINTMSK_USBSUSPM;
|
||||||
handle_enum_done(rhport);
|
handle_enum_done(rhport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gintsts & GINTSTS_USBSUSP) {
|
if (gintsts & GINTSTS_USBSUSP) {
|
||||||
dwc2->gintsts = GINTSTS_USBSUSP;
|
dwc2->gintsts = GINTSTS_USBSUSP;
|
||||||
|
dwc2->gintmsk &= ~GINTMSK_USBSUSPM;
|
||||||
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
|
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gintsts & GINTSTS_WKUINT) {
|
if (gintsts & GINTSTS_WKUINT) {
|
||||||
dwc2->gintsts = GINTSTS_WKUINT;
|
dwc2->gintsts = GINTSTS_WKUINT;
|
||||||
|
dwc2->gintmsk |= GINTMSK_USBSUSPM;
|
||||||
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
|
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1061,6 +1064,7 @@ void dcd_int_handler(uint8_t rhport) {
|
|||||||
|
|
||||||
if(gintsts & GINTSTS_SOF) {
|
if(gintsts & GINTSTS_SOF) {
|
||||||
dwc2->gintsts = GINTSTS_SOF;
|
dwc2->gintsts = GINTSTS_SOF;
|
||||||
|
dwc2->gintmsk |= GINTMSK_USBSUSPM;
|
||||||
const uint32_t frame = (dwc2->dsts & DSTS_FNSOF) >> DSTS_FNSOF_Pos;
|
const uint32_t frame = (dwc2->dsts & DSTS_FNSOF) >> DSTS_FNSOF_Pos;
|
||||||
|
|
||||||
// Disable SOF interrupt if SOF was not explicitly enabled since SOF was used for remote wakeup detection
|
// Disable SOF interrupt if SOF was not explicitly enabled since SOF was used for remote wakeup detection
|
||||||
|
Reference in New Issue
Block a user