Modules/USB - A little more work
[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_TransferType
14 {
15         TRANSTYPE_ISYNCH,       // Constant, Low latency, low bandwidth, no transmission retries
16         TRANSTYPE_INTERRUPT,    // -- NEVER SENT -- Spontanious, Low latency, low bandwith
17         TRANSTYPE_CONTROL,      // Device control
18         TRANSTYPE_BULK          // High latency, high bandwidth
19 };
20
21 enum eUSB_PIDs
22 {
23         /**
24          * \name Token
25          * \{
26          */
27         PID_OUT         = 0xE1,
28         PID_IN          = 0x69,
29         PID_SOF         = 0xA5,
30         PID_SETUP       = 0x2D,
31         /**
32          * \}
33          */
34         
35         /**
36          * \name Data
37          * \{
38          */
39         PID_DATA0       = 0xC3,
40         PID_DATA1       = 0x4B,
41         PID_DATA2       = 0x87, // USB2 only
42         PID_MDATA       = 0x0F, // USB2 only
43         /**
44          * \}
45          */
46         
47         /**
48          * \name Handshake
49          * \{
50          */
51         PID_ACK         = 0xD2,
52         PID_NAK         = 0x5A,
53         PID_STALL       = 0x1E,
54         PID_NYET        = 0x96,
55         /**
56          * \}
57          */
58         
59         /**
60          * \name Special
61          * \{
62          */
63         PID_PRE         = 0x3C, PID_ERR         = 0x3C,
64         PID_SPLIT       = 0x78,
65         PID_PING        = 0xB4,
66         PID_RESVD       = 0xF0,
67         /**
68          * \}
69          */
70 };
71
72 // === FUNCTIONS ===
73 /**
74  * \note 00101 - X^5+X^2+1
75  */
76 extern Uint8    USB_TokenCRC(void *Data, int len);
77 /**
78  * \note X^16 + X15 + X^2 + 1
79  */
80 extern Uint16   USB_DataCRC(void *Data, int len);
81
82 // === STRUCTURES ===
83 /**
84  * \brief Defines a USB Host Controller
85  */
86 struct sUSBHost
87 {
88         Uint16  IOBase;
89         
90          int    (*SendPacket)(int ID, int Length, void *Data);
91 };
92
93 /**
94  * \brief Defines a single device on the USB Bus
95  */
96 struct sUSBDevice
97 {
98         tUSBHost        *Host;
99          int    MaxControl;
100          int    MaxBulk;
101          int    MaxISync;
102 };
103
104 #endif

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