summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorhenneboi <[email protected]>2024-03-11 13:36:25 +0100
committerhenneboi <[email protected]>2024-03-14 09:13:12 +0100
commit5a854ef2dc03373f125b48e93accf302c2fbdd66 (patch)
tree3ee407f39ee2cc23bc7499993c22d80ae5553d47 /src/portable
parent7c66f9b2a4f302268caeab9f8e63fb6ebd8be466 (diff)
dcd_stm32_fsdev.c: Fix a bug seend with stm32h5xxx when the driver is compiled with cubeide O1/O2/O3
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
index 3f4db985d..e0df21860 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
@@ -296,6 +296,19 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_cnt(USB_TypeDef * USB
{
#ifdef FSDEV_BUS_32BIT
(void) USBx;
+ volatile uint32_t count = 10;
+ /*
+ WA: few cycles for RX PMA descriptor to update
+ This workaround is ported from stm32h5xx_hal_pcd.h : PCD_GET_EP_RX_CNT H5
+ This code fixes an issue when the code is compiled in GCC with a fast optimization(O2/O3) and device with an high frequency.
+ The function doesn't return the correct value.
+ Issue observed on Windows 10 and stm32h573i_dk and tud_task() scheduled by IT, the device is not migrated the USB device is not visible .
+ */
+ while (count > 0U)
+ {
+ asm("NOP");
+ count--;
+ }
return (pma32[2*bEpIdx + 1] & 0x03FF0000) >> 16;
#else
__I uint16_t *regPtr = pcd_ep_rx_cnt_ptr(USBx, bEpIdx);