diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-08-10 17:13:18 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-10-18 13:30:18 -0400 |
commit | d4e9573d41e6a6601ba3f680487dd548b23bf680 (patch) | |
tree | 4902cc1cf8c157cea3b584f2638526687c2c3e4a /libmaple/usb/usb_lib_globals.h | |
parent | 00c5efa7b637ee6ef1878eb870eff140f2af94a8 (diff) | |
download | librambutan-d4e9573d41e6a6601ba3f680487dd548b23bf680.tar.gz librambutan-d4e9573d41e6a6601ba3f680487dd548b23bf680.zip |
usb: Clean up some globals with new struct usblib_dev.
Add struct usblib_dev (and USBLIB, a pointer to the singleton) to
usb.h. USBLIB contains the global state which is used by
functionality imported from usb_lib/.
Consolidating global state into USBLIB will make it easier to remove
later.
Initial fields in struct usblib_dev are endpoint interrupt callbacks,
a mask for what to handle in the low-priority USB interrupt, and
device state. These replace pEpInt_IN, pEpInt_OUT; wInterrupt_Mask;
and bDeviceState, respectively from usb_lib/, so remove their
declarations from usb_lib_globals.h accordingly. Also remove unused
SaveState declaration from usblib_globals.h. Move bDeviceState into
'state' field in usblib_dev. Device state type changes from
DEVICE_STATE to usb_dev_state, volatile gets dropped, and enumerators
get a 'USB_' prefix, but it's otherwise the same.
usb_lib/ expects pInformation to point to Device_Info,
pUser_Standard_Requests -> User_Standard_Requests, and
pProperty -> Device_Property.
Alter usb_init_usblib() to reflect these assumptions. Reorganize
usb_lib_globals.h to make these assumptions more apparent to the
reader.
Modify usb_init_usblib() to take endpoint callbacks as arguments;
update its caller in usb_cdcacm.c.
usb_lib/ defines pInformation, pProperty, and pUser_Standard_Requests
itself (in usb_init.c), but we have our own definitions (in usb.c).
Remove the duplicates from usb.c. Also remove EPindex and Device_Info
definitions from usb.c. Unused, and anyways already defined in
usb_lib/usb_init.c.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/usb/usb_lib_globals.h')
-rw-r--r-- | libmaple/usb/usb_lib_globals.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libmaple/usb/usb_lib_globals.h b/libmaple/usb/usb_lib_globals.h index 854cb12..a494817 100644 --- a/libmaple/usb/usb_lib_globals.h +++ b/libmaple/usb/usb_lib_globals.h @@ -34,19 +34,18 @@ extern "C" { #endif -extern void (*pEpInt_IN[7])(void); -extern void (*pEpInt_OUT[7])(void); -extern DEVICE_PROP Device_Property; -extern USER_STANDARD_REQUESTS User_Standard_Requests; -extern DEVICE Device_Table; -extern DEVICE_INFO Device_Info; +extern USER_STANDARD_REQUESTS User_Standard_Requests; +extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; + +extern DEVICE_PROP Device_Property; +extern DEVICE_PROP *pProperty; + +extern DEVICE_INFO Device_Info; +extern DEVICE_INFO *pInformation; + +extern DEVICE Device_Table; extern u16 SaveRState; extern u16 SaveTState; -extern DEVICE_INFO* pInformation; -extern DEVICE_PROP* pProperty; -extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; -extern u16 SaveState ; -extern u16 wInterrupt_Mask; #ifdef __cplusplus } |