b4c2db10334e0fb915a6ec0ce099ead96ff3e6fb
[ppcskel.git] / usb / core / usb.h
1 /*
2  * Copyright (c) 2006, Benedikt Sauter <sauter@ixbat.de>
3  * All rights reserved.
4  *
5  * Short descripton of file:
6  * I take the function names and parameters mainly from
7  * libusb.sf.net.
8  *
9  *
10  * Redistribution and use in source and binary forms, with or without 
11  * modification, are permitted provided that the following conditions 
12  * are met:
13  *
14  *   * Redistributions of source code must retain the above copyright 
15  *     notice, this list of conditions and the following disclaimer.
16  *   * Redistributions in binary form must reproduce the above 
17  *     copyright notice, this list of conditions and the following 
18  *     disclaimer in the documentation and/or other materials provided 
19  *     with the distribution.
20  *   * Neither the name of the FH Augsburg nor the names of its 
21  *     contributors may be used to endorse or promote products derived 
22  *     from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
28  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
34  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #ifndef _USB_H_
38 #define _USB_H_
39
40 #include "../../types.h"
41 #include "core.h"
42
43
44 /******************* Device Operations **********************/
45
46 // use an own usb device
47 struct usb_device *usb_open(u32 vendor_id, u32 product_id);
48 struct usb_device *usb_open_class(u8 class);
49
50 s8 usb_close(struct usb_device *dev);
51
52
53 /**
54  * usb_reset resets the specified device by sending a RESET down the port 
55  * it is connected to. Returns 0 on success or < 0 on error.
56  */
57
58 s8 usb_reset(struct usb_device *dev);
59
60
61 /******************* Control Transfer **********************/
62 s8 usb_control_msg(struct usb_device *dev, u8 requesttype, u8 request, u16 value, u16 index, u16 length, u8 *buf, u16 timeout);
63 s8 usb_get_descriptor(struct usb_device *dev, u8 type, u8 index, u8 *buf, u8 size);
64 s8 usb_get_desc_dev_simple(struct usb_device *dev);
65 s8 usb_get_desc_dev(struct usb_device *dev);
66 s8 usb_get_desc_configuration(struct usb_device *dev, u8 index);
67 s8 usb_get_desc_config_ext(struct usb_device *dev, u8 index);
68
69 char *usb_get_string_simple(struct usb_device *dev, u8 index);
70 s8 usb_get_string(struct usb_device *dev, u8 index, u8 langid);
71
72 s8 usb_set_address(struct usb_device *dev, u8 address);
73 s8 usb_set_configuration(struct usb_device *dev, u8 configuration);
74 s8 usb_set_altinterface(struct usb_device *dev, u8 alternate);
75
76
77 /******************* Bulk Transfer **********************/
78 s8 usb_bulk_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
79 s8 usb_bulk_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
80
81
82 /******************* Interrupt Transfer **********************/
83 s8 usb_u8errupt_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
84 s8 usb_u8errupt_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
85
86
87 /******************* Isochron Transfer **********************/
88 s8 usb_isochron_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
89 s8 usb_isochron_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
90
91 #endif  //_USB_H_