aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/usb
diff options
context:
space:
mode:
authorelagil <[email protected]>2025-03-22 11:46:28 +0100
committerelagil <[email protected]>2025-03-22 11:47:36 +0100
commit07387ea405b3228b9526d994da94e7d4a73339f7 (patch)
treea006f2099ce33211b36c8c3894728fdb519926b9 /embassy-stm32/src/usb
parent4033a619a87da733e2087bb7a2eb92017b33a9c5 (diff)
fix: apply STM32H5 USB errata (OUT transfer delay)
Diffstat (limited to 'embassy-stm32/src/usb')
-rw-r--r--embassy-stm32/src/usb/usb.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs
index 24983cf3c..d5cfa1bb8 100644
--- a/embassy-stm32/src/usb/usb.rs
+++ b/embassy-stm32/src/usb/usb.rs
@@ -7,6 +7,7 @@ use core::task::Poll;
7 7
8use embassy_hal_internal::into_ref; 8use embassy_hal_internal::into_ref;
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10use embassy_time::Timer;
10use embassy_usb_driver as driver; 11use embassy_usb_driver as driver;
11use embassy_usb_driver::{ 12use embassy_usb_driver::{
12 Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, 13 Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported,
@@ -887,6 +888,16 @@ impl<'d, T: Instance> driver::EndpointOut for Endpoint<'d, T, Out> {
887 }) 888 })
888 .await; 889 .await;
889 890
891 // Errata for STM32H5, 2.20.1:
892 // During OUT transfers, the correct transfer interrupt (CTR) is triggered a little before the last USB SRAM accesses
893 // have completed. If the software responds quickly to the interrupt, the full buffer contents may not be correct.
894 //
895 // Workaround:
896 // Software should ensure that a small delay is included before accessing the SRAM contents. This delay should be
897 // 800 ns in Full Speed mode and 6.4 μs in Low Speed mode.
898 #[cfg(stm32h5)]
899 Timer::after_nanos(800).await;
900
890 RX_COMPLETE[index].store(false, Ordering::Relaxed); 901 RX_COMPLETE[index].store(false, Ordering::Relaxed);
891 902
892 if stat == Stat::DISABLED { 903 if stat == Stat::DISABLED {