Travis Geiselbrecht | 2c691e8 | 2008-09-04 02:41:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 Travis Geiselbrecht |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files |
| 6 | * (the "Software"), to deal in the Software without restriction, |
| 7 | * including without limitation the rights to use, copy, modify, merge, |
| 8 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 9 | * and to permit persons to whom the Software is furnished to do so, |
| 10 | * subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be |
| 13 | * included in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | #ifndef __DEV_USB_H |
| 24 | #define __DEV_USB_H |
| 25 | |
Travis Geiselbrecht | 89fcb14 | 2008-10-10 03:18:10 -0700 | [diff] [blame] | 26 | #include <sys/types.h> |
| 27 | #include <compiler.h> |
| 28 | |
| 29 | /* top level initialization for usb client, abstracts away the interfaces */ |
| 30 | typedef struct { |
| 31 | void *desc; |
| 32 | size_t len; |
| 33 | } usb_descriptor __ALIGNED(2); |
| 34 | |
Travis Geiselbrecht | 345adb5 | 2009-01-01 05:25:50 -0800 | [diff] [blame] | 35 | typedef struct { |
| 36 | usb_descriptor string; |
| 37 | uint8_t id; |
| 38 | } usb_string; |
| 39 | |
Travis Geiselbrecht | 89fcb14 | 2008-10-10 03:18:10 -0700 | [diff] [blame] | 40 | /* complete usb config struct, passed in to usb_setup() */ |
| 41 | typedef struct { |
| 42 | struct usb_descriptor_speed { |
| 43 | usb_descriptor device; |
| 44 | usb_descriptor device_qual; |
| 45 | usb_descriptor config; |
| 46 | } lowspeed, highspeed; |
Travis Geiselbrecht | 89fcb14 | 2008-10-10 03:18:10 -0700 | [diff] [blame] | 47 | usb_descriptor langid; |
| 48 | } usb_config; |
Travis Geiselbrecht | 2c691e8 | 2008-09-04 02:41:01 -0700 | [diff] [blame] | 49 | |
| 50 | void usb_init(void); |
| 51 | |
Travis Geiselbrecht | 89fcb14 | 2008-10-10 03:18:10 -0700 | [diff] [blame] | 52 | /* external code needs to set up the usb stack via the following calls */ |
| 53 | void usb_setup(usb_config *config); |
| 54 | |
| 55 | /* apped new interface descriptors to the existing config if desired */ |
| 56 | int usb_append_interface_highspeed(const uint8_t *int_descr, size_t len); |
| 57 | int usb_append_interface_lowspeed(const uint8_t *int_descr, size_t len); |
| 58 | |
Travis Geiselbrecht | 345adb5 | 2009-01-01 05:25:50 -0800 | [diff] [blame] | 59 | void usb_add_string(const char *string, uint8_t id); |
| 60 | |
Travis Geiselbrecht | 89fcb14 | 2008-10-10 03:18:10 -0700 | [diff] [blame] | 61 | void usb_start(void); |
| 62 | void usb_stop(void); |
| 63 | |
Travis Geiselbrecht | 2c691e8 | 2008-09-04 02:41:01 -0700 | [diff] [blame] | 64 | #endif |
| 65 | |