summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2024-03-25 19:14:58 +0700
committerGitHub <[email protected]>2024-03-25 19:14:58 +0700
commit0814ca0cc70f7343218c6637ce0b4deaf9058dc0 (patch)
tree9a4561f2c40d95761ffeb37ce52fbfce22e0e76a /src/portable
parentc028cfa7cf2fa281e6c88a816cf70fd80eb68338 (diff)
parent29f016ae15eb94654748bf29b81557f6ab611384 (diff)
Merge pull request #2515 from Lurcy38/ReAlignMaster
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h10
1 files changed, 10 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..ade64b4fb 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,16 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_cnt(USB_TypeDef * USB
{
#ifdef FSDEV_BUS_32BIT
(void) USBx;
+ /* WA: few cycles for RX PMA descriptor to update, otherwise doesn't return the correct value.
+ Note: required for G0, U5, H5 etc.
+ This workaround is ported from stm32h5xx_hal_pcd.h and fixes the issue when calling this function fast enough.
+ Reproduced with GCC ast optimization(O2/O3) and stm32h573i_dk with an high frequency.
+ Observed on Windows 10 where tud_task() is scheduled by interrupt handler.
+ */
+ volatile uint32_t count = 10; // defined as PCD_RX_PMA_CNT in stm32 hal_driver
+ while (count > 0U) {
+ count--;
+ }
return (pma32[2*bEpIdx + 1] & 0x03FF0000) >> 16;
#else
__I uint16_t *regPtr = pcd_ep_rx_cnt_ptr(USBx, bEpIdx);