Make this properly dependend on the right defines instead of a blacklist.
[kugel-rb.git] / firmware / target / arm / as3525 / usb-as3525.c
blob37433612ed7045e721f96e0d957343cee89f9b5f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright © 2008 Rafaël Carré
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdbool.h>
23 #include "config.h"
24 #include "usb.h"
25 #ifdef HAVE_USBSTACK
26 #include "usb_core.h"
27 #endif
28 #include "usb-target.h"
29 #include "power.h"
30 #include "as3525.h"
32 #if CONFIG_CPU != AS3525 && !defined(USB_DETECT_PIN)
33 #warning USB_DETECT_PIN not defined for your target
34 #endif
36 #if CONFIG_CPU == AS3525
37 static int usb_status = USB_EXTRACTED;
38 #endif
40 void usb_enable(bool on)
42 #ifdef HAVE_USBSTACK
43 if (on)
44 usb_core_init();
45 else
46 usb_core_exit();
47 #else
48 (void)on;
49 #endif
52 void usb_init_device(void)
54 #ifdef USB_DETECT_PIN
55 GPIOA_DIR &= ~(1 << USB_DETECT_PIN); /* set as input */
56 #endif
59 #if CONFIG_CPU == AS3525
60 void usb_insert_int(void)
62 usb_status = USB_INSERTED;
65 void usb_remove_int(void)
67 usb_status = USB_EXTRACTED;
70 int usb_detect(void)
72 return usb_status;
74 #else
75 int usb_detect(void)
77 #ifdef USB_DETECT_PIN
78 if (GPIOA_PIN( USB_DETECT_PIN ))
79 return USB_INSERTED;
80 else
81 #endif
82 return USB_EXTRACTED;
84 #endif