From c4686aafc41d0627609ed42536a2f9b5922c4a1f Mon Sep 17 00:00:00 2001 From: doryan Date: Fri, 25 Apr 2025 14:35:30 +0400 Subject: [PATCH] feat(api): add plug_in_detection --- src/types/usb_device.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/usb_device.rs b/src/types/usb_device.rs index ac4be91..8856967 100644 --- a/src/types/usb_device.rs +++ b/src/types/usb_device.rs @@ -93,7 +93,10 @@ impl UsbDevice { }) } - #[inline] + #[inline(always)] + pub fn plug_in_detect(&self, cs: CriticalSection<'_>) -> bool { + self.usb.borrow(cs).usbsta.read().vbus().bit_is_set() + } #[inline(always)] pub(crate) fn allocated_endpoints(&self) -> impl Iterator {