aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/usb.c
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-10-21 17:55:48 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-10-21 18:13:05 -0400
commita9e628ac6fdd5ef1d775bc9e90c2475ef914b911 (patch)
tree62314e93fba27aa33878e604b5d5f739bb7c61ab /libmaple/usb/usb.c
parent1e51e683e3321256c07c146bdd0e3d246be31c34 (diff)
downloadlibrambutan-a9e628ac6fdd5ef1d775bc9e90c2475ef914b911.tar.gz
librambutan-a9e628ac6fdd5ef1d775bc9e90c2475ef914b911.zip
USB: API cleanups.
Modify usb.h functions (changing their names in some cases) to also take a usblib_dev* argument, to fit in better with the rest of libmaple. Store an rcc_clk_id in struct usblib_dev for the same reason. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/usb/usb.c')
-rw-r--r--libmaple/usb/usb.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c
index 00ba4ef..667b11f 100644
--- a/libmaple/usb/usb.c
+++ b/libmaple/usb/usb.c
@@ -72,6 +72,7 @@ struct {
static usblib_dev usblib = {
.irq_mask = USB_ISR_MSK,
.state = USB_UNCONNECTED,
+ .clk_id = RCC_USB,
};
usblib_dev *USBLIB = &usblib;
@@ -79,11 +80,13 @@ usblib_dev *USBLIB = &usblib;
* Routines
*/
-void usb_init_usblib(void (**ep_int_in)(void), void (**ep_int_out)(void)) {
- rcc_clk_enable(RCC_USB);
+void usb_init_usblib(usblib_dev *dev,
+ void (**ep_int_in)(void),
+ void (**ep_int_out)(void)) {
+ rcc_clk_enable(dev->clk_id);
- USBLIB->ep_int_in = ep_int_in;
- USBLIB->ep_int_out = ep_int_out;
+ dev->ep_int_in = ep_int_in;
+ dev->ep_int_out = ep_int_out;
/* usb_lib/ declares both and then assumes that pFoo points to Foo
* (even though the names don't always match), which is stupid for
@@ -242,14 +245,6 @@ void __irq_usb_lp_can_rx0(void) {
#endif
}
-uint8 usbIsConfigured() {
- return USBLIB->state == USB_CONFIGURED;
-}
-
-uint8 usbIsConnected() {
- return USBLIB->state != USB_UNCONNECTED;
-}
-
/*
* Auxiliary routines
*/