993bf0cccd85f9d3b0fa1fe2afb545e0c101dab8
[tpg/acess2.git] / Modules / USB / Core / usb_io.c
1 /*
2  * Acess2 USB Stack
3  * - By John Hodge (thePowersGang)
4  *
5  * usb_io.c
6  * - High-level IO
7  */
8 #define DEBUG   1
9
10 #include <usb_core.h>
11 #include "usb.h"
12 #include "usb_lowlevel.h"
13 #include <semaphore.h>
14
15 typedef struct sAsyncOp tAsyncOp;
16
17 struct sAsyncOp
18 {
19         tAsyncOp        *Next;
20         tUSBEndpoint    *Endpt;
21          int    Length;
22         void    *Data;
23 };
24
25 // === PROTOTYPES ===
26 void    USB_ReadDescriptor(tUSBInterface *Iface, int Type, int Index, int Length, void *Data);
27 void    USB_Request(tUSBInterface *Iface, int Endpoint, int Type, int Req, int Value, int Index, int Len, void *Data);
28
29 // === GLOBALS ===
30 tSemaphore      glUSB_AsyncQueue;
31
32 // === CODE ===
33 void USB_ReadDescriptor(tUSBInterface *Iface, int Type, int Index, int Length, void *Data)
34 {
35         USB_int_ReadDescriptor(Iface->Dev, 0, Type, Index, Length, Data);
36 }
37
38 void USB_Request(tUSBInterface *Iface, int Endpoint, int Type, int Req, int Value, int Index, int Len, void *Data)
39 {
40          int    endpt;
41
42         // Sanity check
43         if(Endpoint < 0 || Endpoint >= Iface->nEndpoints)
44                 return ;        
45
46         // Get endpoint number
47         if(Endpoint)
48                 endpt = Iface->Endpoints[Endpoint-1].EndpointNum;
49         else
50                 endpt = 0;
51         
52         USB_int_Request(Iface->Dev->Host, Iface->Dev->Address, endpt, Type, Req, Value, Index, Len, Data);
53 }
54
55
56 void USB_SendData(tUSBInterface *Dev, int Endpoint, int Length, void *Data)
57 {
58         Log_Warning("USB", "TODO: Implement USB_SendData");
59 }
60
61 void USB_RecvData(tUSBInterface *Dev, int Endpoint, int Length, void *Data)
62 {
63         Log_Warning("USB", "TODO: Implement USB_RecvData");
64 }
65
66 void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, int Length, void *DataBuf, tUSB_DataCallback Callback)
67 {
68         Log_Warning("USB", "TODO: Implement USB_RecvDataA");
69 }
70
71 void USB_AsyncThread(void *Unused)
72 {
73         for(;;)
74         {
75                 Semaphore_Wait(&glUSB_AsyncQueue, 1);
76                 
77         }
78 }
79

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