diff --git a/port/dwc2/usb_dc_dwc2.c b/port/dwc2/usb_dc_dwc2.c index e7d3feab..f05207c4 100644 --- a/port/dwc2/usb_dc_dwc2.c +++ b/port/dwc2/usb_dc_dwc2.c @@ -191,7 +191,7 @@ USB_NOCACHE_RAM_SECTION struct dwc2_udc { static inline int dwc2_reset(void) { - uint32_t count = 0U; + volatile uint32_t count = 0U; /* Wait for AHB master IDLE state. */ do { @@ -252,7 +252,7 @@ static inline void dwc2_set_mode(uint8_t mode) static inline int dwc2_flush_rxfifo(void) { - uint32_t count = 0; + volatile uint32_t count = 0; USB_OTG_GLB->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH; @@ -267,7 +267,7 @@ static inline int dwc2_flush_rxfifo(void) static inline int dwc2_flush_txfifo(uint32_t num) { - uint32_t count = 0U; + volatile uint32_t count = 0U; USB_OTG_GLB->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (num << 6)); diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c index 1f18771f..7c51eaa7 100644 --- a/port/dwc2/usb_hc_dwc2.c +++ b/port/dwc2/usb_hc_dwc2.c @@ -66,7 +66,7 @@ struct dwc2_hcd { static inline int dwc2_reset(void) { - uint32_t count = 0U; + volatile uint32_t count = 0U; /* Wait for AHB master IDLE state. */ do { @@ -127,7 +127,7 @@ static inline void dwc2_set_mode(uint8_t mode) static inline int dwc2_flush_rxfifo(void) { - uint32_t count = 0; + volatile uint32_t count = 0; USB_OTG_GLB->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH; @@ -142,7 +142,7 @@ static inline int dwc2_flush_rxfifo(void) static inline int dwc2_flush_txfifo(uint32_t num) { - uint32_t count = 0U; + volatile uint32_t count = 0U; USB_OTG_GLB->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (num << 6));