6579b725b2acdab462e2cae90a59b72e485e9ba0
[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 usb_device * usb_open(u32 vendor_id, u32 product_id);
48 usb_device * usb_open_class(u8 class);
49
50 u8 usb_close(usb_device *dev);
51
52
53
54 u8 usb_get_device_descriptor(usb_device *dev, char *buf,u8 size);
55 u8 usb_set_address(usb_device *dev, u8 address);
56 u8 usb_set_configuration(usb_device *dev, u8 configuration);
57 u8 usb_set_altinterface(usb_device *dev, u8 alternate);
58
59
60 /**
61  * usb_reset resets the specified device by sending a RESET down the port 
62  * it is connected to. Returns 0 on success or < 0 on error.
63  */
64
65 u8 usb_reset(usb_device *dev);
66
67
68 /******************* Control Transfer **********************/
69
70
71 u8 usb_control_msg(usb_device *dev, u8 requesttype, u8 request, u16 value, u16 index, u16 length, char *buf, u16 size, u16 timeout);
72 u8 usb_get_string(usb_device *dev, u8 index, u8 langid, char *buf, u8 buflen);
73 u8 usb_get_string_simple(usb_device *dev, u8 index, char *buf, u8 buflen);
74 u8 usb_get_descriptor(usb_device *dev, unsigned char type, unsigned char index, void *buf, u8 size);
75
76
77 /******************* Bulk Transfer **********************/
78
79 u8 usb_bulk_write(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
80 u8 usb_bulk_read(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
81
82
83 /******************* Interrupt Transfer **********************/
84 u8 usb_u8errupt_write(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
85 u8 usb_u8errupt_read(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
86
87
88 /******************* Isochron Transfer **********************/
89 u8 usb_isochron_write(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
90 u8 usb_isochron_read(usb_device *dev, u8 ep, char *buf, u8 size, u8 timeout);
91
92
93
94 #endif  //_USB_H_