From bf1cddf3e890944e0108913b4271e403c094375c Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 29 Jan 2009 01:28:34 +0000 Subject: Hopefully make some progress against FS#9831. iPod Video seems fine now under XP at least. Move false reset detection to the USB target code. Gigabeat S works using the OTG module upon bus reset. Portal Player targets verify that the USB pin detect is ok upon bus reset. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19874 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/usb-fw-pp502x.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'firmware/target/arm/usb-fw-pp502x.c') diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index 883ca1e8e2..cf5a82f37c 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c @@ -177,6 +177,11 @@ void usb_attach(void) usb_drv_attach(); } +static bool usb_pin_state(void) +{ + return (USB_GPIO_INPUT_VAL & USB_GPIO_MASK) == USB_GPIO_VAL; +} + #ifdef USB_STATUS_BY_EVENT /* Cannot always tell power pin from USB pin */ static int usb_status = USB_EXTRACTED; @@ -197,10 +202,13 @@ void usb_insert_int(void) timeout_register(&usb_oneshot, usb_timeout_event, HZ/5, val); } -/* Called during the bus reset interrupt when in detect mode */ +/* Called during the bus reset interrupt when in detect mode - filter for + * invalid bus reset when unplugging by checking the pin state. */ void usb_drv_usb_detect_event(void) { - usb_status_event(USB_INSERTED); + if(usb_pin_state()) { + usb_status_event(USB_INSERTED); + } } #endif /* USB_STATUS_BY_EVENT */ @@ -221,8 +229,7 @@ int usb_detect(void) #ifdef USB_STATUS_BY_EVENT return usb_status; #else - return ((USB_GPIO_INPUT_VAL & USB_GPIO_MASK) == USB_GPIO_VAL) ? - USB_INSERTED : USB_EXTRACTED; + return usb_pin_state() ? USB_INSERTED : USB_EXTRACTED; #endif } -- cgit v1.2.3