207c15618df9bbf8418f2723cefc5fad853d08b5
[tpg/acess2.git] / Modules / USB / Core / usb.h
1 /*
2  * AcessOS Version 1
3  * USB Stack
4  */
5 #ifndef _USB_H_
6 #define _USB_H_
7
8 // === TYPES ===
9 typedef struct sUSBHost tUSBHost;
10 typedef struct sUSBDevice       tUSBDevice;
11
12 // === CONSTANTS ===
13 enum eUSB_PIDs
14 {
15         /**
16          * \name Token
17          * \{
18          */
19         PID_OUT         = 0xE1,
20         PID_IN          = 0x69,
21         PID_SOF         = 0xA5,
22         PID_SETUP       = 0x2D,
23         /**
24          * \}
25          */
26         
27         /**
28          * \name Data
29          * \{
30          */
31         PID_DATA0       = 0xC3,
32         PID_DATA1       = 0x4B,
33         PID_DATA2       = 0x87, // USB2 only
34         PID_MDATA       = 0x0F, // USB2 only
35         /**
36          * \}
37          */
38         
39         /**
40          * \name Handshake
41          * \{
42          */
43         PID_ACK         = 0xD2,
44         PID_NAK         = 0x5A,
45         PID_STALL       = 0x1E,
46         PID_NYET        = 0x96,
47         /**
48          * \}
49          */
50         
51         /**
52          * \name Special
53          * \{
54          */
55         PID_PRE         = 0x3C, PID_ERR         = 0x3C,
56         PID_SPLIT       = 0x78,
57         PID_PING        = 0xB4,
58         PID_RESVD       = 0xF0,
59         /**
60          * \}
61          */
62 };
63
64 // === FUNCTIONS ===
65 /**
66  * \note 00101 - X^5+X^2+1
67  */
68 extern Uint8    USB_TokenCRC(void *Data, int len);
69 /**
70  * \note X^16 + X15 + X^2 + 1
71  */
72 extern Uint16   USB_DataCRC(void *Data, int len);
73
74 // === STRUCTURES ===
75 /**
76  * \brief Defines a USB Host Controller
77  */
78 struct sUSBHost
79 {
80         Uint16  IOBase;
81         
82          int    (*SendPacket)(int ID, int Length, void *Data);
83 };
84
85 /**
86  * \brief Defines a single device on the USB Bus
87  */
88 struct sUSBDevice
89 {
90         tUSBHost        *Host;
91          int    MaxControl;
92          int    MaxBulk;
93          int    MaxISync;
94 };
95
96 #endif

UCC git Repository :: git.ucc.asn.au