Modules/USB - Cleaning up protocol code, working on device API
[tpg/acess2.git] / Modules / USB / Core / include / usb_core.h
1 /*
2  * Acess2 USB Stack
3  * - By John Hodge (thePowersGang)
4  *
5  * usb_core.h
6  * - Core USB IO Header 
7  */
8 #ifndef _USB_CORE_H_
9 #define _USB_CORE_H_
10
11 typedef struct sUSBInterface    tUSBInterface;
12 typedef struct sUSBDriver       tUSBDriver;
13
14 /**
15  */
16 struct sUSBDriver
17 {
18         tUSBDriver      *Next;
19         
20         const char      *Name;
21
22          int    MatchType;      // 0: Interface, 1: Device, 2: Vendor
23         union { 
24                 struct {
25                         // 23:16 - Interface Class
26                         // 15:8  - Interface Sub Class
27                         // 7:0   - Interface Protocol
28                         Uint32  ClassMask;
29                         Uint32  ClassCode;
30                 } Class;
31                 struct {
32                         Uint16  VendorID;
33                         Uint16  DeviceID;
34                 } VendorDev;
35         } Match;
36
37         void    (*Connected)(tUSBInterface *Dev);
38         void    (*Disconnected)(tUSBInterface *Dev);
39
40          int    MaxEndpoints;   
41         struct {
42                 // USB Attrbute byte
43                 // NOTE: Top bit indicates the direction (1=Input)
44                 Uint8   Attributes;
45                 // Data availiable Callback
46                 void    (*DataAvail)(tUSBInterface *Dev, int Length, void *Data);
47         } Endpoints[];
48 };
49
50 extern void     *USB_GetDeviceDataPtr(tUSBInterface *Dev);
51 extern void     USB_SetDeviceDataPtr(tUSBInterface *Dev, void *Ptr);
52
53 extern void     USB_StartPollingEndpoint(tUSBInterface *Dev, int Endpoint);
54 extern void     USB_ReadDescriptor(tUSBInterface *Dev, int Type, int Index, int Length, void *Data);
55 // TODO: Async
56 extern void     USB_SendData(tUSBInterface *Dev, int Endpoint, int Length, void *Data);
57 extern void     USB_RecvData(tUSBInterface *Dev, int Endpoint, int Length, void *Data);
58
59 #endif
60

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