summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2008-12-30 21:17:43 +0000
committerBjörn Stenberg <bjorn@haxx.se>2008-12-30 21:17:43 +0000
commit93afe5297b825d1e6f9d3d2782ae00a4593a0a03 (patch)
tree3388290292ed5f8266df351769d3a5ce04febefe
parentf2d2b8c3c78281c0397c27d43921c945655818eb (diff)
Cleaner usb detection.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19615 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/usb-as3525.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/firmware/target/arm/as3525/usb-as3525.c b/firmware/target/arm/as3525/usb-as3525.c
index ab2f51e72f..9fcf2cb2f3 100644
--- a/firmware/target/arm/as3525/usb-as3525.c
+++ b/firmware/target/arm/as3525/usb-as3525.c
@@ -24,6 +24,16 @@
#include "as3525.h"
#include <stdbool.h>
+#if defined(SANSA_CLIP)
+#define USB_DETECT_PIN 6
+
+#elif defined(SANSA_FUZE) || defined(SANSA_E200V2)
+#define USB_DETECT_PIN 3
+
+#elif defined(SANSA_C200V2)
+#define USB_DETECT_PIN 1
+#endif
+
void usb_enable(bool on)
{
(void)on;
@@ -31,19 +41,13 @@ void usb_enable(bool on)
void usb_init_device(void)
{
- /* TODO */
+ GPIOA_DIR &= ~(1 << USB_DETECT_PIN); /* set as input */
}
int usb_detect(void)
{
-#if defined(SANSA_CLIP)
- return !GPIOA_PIN(6);
-#elif defined(SANSA_FUZE) || defined(SANSA_E200V2)
- return !GPIOA_PIN(3);
-#elif defined(SANSA_C200V2)
- return !GPIOA_PIN(1);
-#else
- /* TODO: Implement USB detection */
- return USB_EXTRACTED;
-#endif
+ if (GPIOA_PIN( USB_DETECT_PIN ))
+ return USB_INSERTED;
+ else
+ return USB_EXTRACTED;
}