1/******************************************************************************
2 *
3 *  Copyright (C) 2001-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 *  This file contains usb definitions from Widcomm's Universal Embedded
22 *  Drivers API.
23 *
24 ******************************************************************************/
25
26#ifndef UUSB_H
27#define UUSB_H
28
29#include "bt_target.h"
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
35/*******************************************************************************
36** Codec APIs
37*******************************************************************************/
38
39
40/**** Status ****/
41#define UUSB_SUCCESS                                  0
42#define UUSB_DRV_INVALID_PARM                         1   // Invalid parameter(s) passed to Driver
43#define UUSB_DRV_INVALID_STATE                        2   // Driver is not in correct state to accept
44#define UUSB_DRV_UNSUPPORTED_SETUP_REQ                3   // Unsupported SETUP request (use with tUSER_EP0_SETUP_CB)
45#define UUSB_DRV_NO_BUFFER_AVAILABLE                  4   // User cannot provide a Buffer (use with CB functions)
46
47typedef UINT8 tUUSB_STATUS;
48
49
50#define  UUSB_EP1   0
51#define  UUSB_EP2   1
52#define  UUSB_EP3   2
53#define  UUSB_EP4   3
54#define  UUSB_EP5   4
55#define  UUSB_EP6   5
56#define  UUSB_EP7   6
57
58typedef UINT8 tUUSB_EP_ID;
59
60typedef enum {
61  UUSB_EP_TYPE_CONTROL = 0,
62  UUSB_EP_TYPE_ISOCHRONOUS,
63  UUSB_EP_TYPE_BULK,
64  UUSB_EP_TYPE_INTERRUPT
65} tUUSB_EP_TYPE;
66
67typedef enum {
68  UUSB_DIR_OUT = 0,
69  UUSB_DIR_IN
70} tUUSB_EP_DIRECTION;
71
72typedef struct tUUSB_SETUP_PKTTag
73{
74/* Definition of "USBbmRequestType" */
75#define UUSB_DATA_PHASE_DIR      0x80    /* Mask to get data phase transfer direction */
76#define UUSB_HOST_TO_DEVICE      0x00    /* Data transfer directions */
77#define UUSB_DEVICE_TO_HOST      0x80    /* Data transfer directions */
78/* Types of requests */
79#define UUSB_REQUEST_TYPE		0x60	/* Mask to get request type */
80#define UUSB_STANDARD_REQUEST	0x00	/* Standard request */
81#define	UUSB_CLASS_REQUEST		0x20	/* Class request */
82#define	UUSB_VENDOR_REQUEST		0x40	/* Vendor request */
83  UINT8 bmRequestType;
84  UINT8 bRequest;
85  UINT16 wValue;
86  UINT16 wIndex;
87  UINT16 wLength;
88} tUUSB_SETUP_PKT;
89
90typedef union
91{
92#define UUSB_HEAD_SIZE (8)
93	UINT8           HeadBytes[UUSB_HEAD_SIZE];
94    tUUSB_SETUP_PKT Setup;
95} tSETUP_OR_HEAD;
96
97typedef struct
98{
99  UINT8        BufSize;
100  UINT8        NumBytesInBuf;
101  tSETUP_OR_HEAD Buf;
102} tUUSB_RX_HEAD;
103
104typedef enum
105{
106  UUSB_EP_DISABLE,
107  UUSB_EP_ENABLE,
108  UUSB_EP_STALL
109} tUUSB_EP_STATE;
110
111typedef UINT8 tEndPoint;
112
113#if 0
114#define  UUSB_ATTACHED      0
115#define  UUSB_POWERED       1
116#define  UUSB_DEFAULT       2
117#define  UUSB_ADDRESS       3
118#define  UUSB_CONFIGURED    4
119#define  UUSB_SUSPENDED     5
120
121typedef UINT8 tUUSB_BUS_STATE;
122#else
123typedef enum
124{
125  UUSB_ATTACHED,
126  UUSB_POWERED,
127  UUSB_DEFAULT,
128  UUSB_ADDRESS,
129  UUSB_CONFIGURED,
130  UUSB_SUSPENDED
131} tUUSB_BUS_STATE;
132#endif
133
134typedef enum _tUUSB_STANDART_REQ
135{
136	UUSB_GET_STATUS = 0,
137	UUSB_CLEAR_FEATURE,
138	UUSB_RESERVED1,
139	UUSB_SET_FEATURE,
140	UUSB_RESERVED2,
141	UUSB_SET_ADDRESS,
142	UUSB_GET_DESCRIPTOR,
143	UUSB_SET_DESCRIPTOR,
144	UUSB_GET_CONFIGURATION,
145	UUSB_SET_CONFIGURATION,
146	UUSB_GET_INTERFACE,
147	UUSB_SET_INTERFACE,
148	UUSB_TOTAL_sREQUEST,				/* Total number of Standard request */
149	UUSB_SYNCH_FRAME = 12
150} tUUSB_STANDART_REQ;
151
152
153typedef void (*tUUSB_STATE_CB)          (tUUSB_BUS_STATE State);
154typedef void (*tUUSB_PROT_COMPLETE_CB ) (UINT8 *pBuf,UINT16 NumBytesInBuf);
155
156typedef tUUSB_STATUS (*tUUSB_PROT_SETUP_CB ) (UINT8 **ppBuf,UINT16 *pBufSize);
157
158typedef void (*tUUSB_RX_START_CB )      (tUUSB_EP_ID EndPoint,
159                                        UINT8 **ppBuf,
160                                        UINT16 *pBufSize);
161
162typedef void (*tUUSB_RX_COMPLETE_CB )   (tUUSB_EP_ID EndPoint,
163                                        UINT8 *pRxBuf,
164                                        UINT16 NumBytesInBuf);
165
166typedef void (*tUUSB_TX_COMPLETE_CB )   (tUUSB_EP_ID EndPoint,
167                                        UINT8 *pRxBuf);
168/*******************************************************************************
169** Function Prototypes
170*******************************************************************************/
171
172/******************************************************************************
173**
174** Function         UCODEC_Init
175**
176** Description      Startup initialisation function. This function is called
177**                  before any orther function of UUSB it initialize UUSB
178**                  internal structure an the external hw.
179**
180**                  Input :
181**
182**                  Output Parameters :
183**
184** Returns          UUSB_SUCCESS if The action was performed with sucess.
185**                  Error code else.
186**
187******************************************************************************/
188BT_API extern tUUSB_STATUS    UUSB_Init    (tUUSB_PROT_SETUP_CB       userProtSetupCallBack,
189                                            tUUSB_PROT_COMPLETE_CB    userProtCompleteCallBack,
190                                            tUUSB_RX_START_CB         userRxStartCallBack,
191                                            tUUSB_STATE_CB            userStateCallBack,
192                                            tUUSB_TX_COMPLETE_CB      userTxCompleteCallBack,
193                                            tUUSB_RX_COMPLETE_CB      userRxCompleteCallBack);
194
195
196
197
198/******************************************************************************
199**
200** Function         UUSB_Start
201**
202** Description
203**
204**
205**
206**
207**
208** Returns          UUSB_SUCCESS if The action was performed with sucess.
209**
210******************************************************************************/
211BT_API extern tUUSB_STATUS    UUSB_Start  (void);
212
213/******************************************************************************
214**
215** Function         UUSB_Stop
216**
217** Description
218**
219**
220**
221**
222** Returns          UUSB_SUCCESS if The action was performed with sucess.
223**                  Error code else.
224**
225******************************************************************************/
226BT_API extern tUUSB_STATUS    UUSB_Stop      (void);
227
228/******************************************************************************
229**
230** Function         UUSB_SetEndPointCnf
231**
232** Description
233**
234**
235** Returns
236**
237******************************************************************************/
238BT_API extern tUUSB_STATUS    UUSB_SetEndPointCnf ( BOOLEAN         IsIN_EndPoint,
239                                                    tUUSB_EP_ID     EndPoint,
240                                                    UINT8           MaxPacketSize,
241                                                    tUUSB_EP_TYPE   EndPointType,
242                                                    tUUSB_RX_HEAD   *pRxHead,
243                                                    UINT16          RxTimeOut);
244
245
246/******************************************************************************
247**
248** Function         UUSB_SetEndPointState
249**
250** Description
251**
252**
253** Returns
254**
255******************************************************************************/
256BT_API extern tUUSB_STATUS UUSB_SetEndPointState (tUUSB_EP_ID    EndPoint,
257                                                    tUUSB_EP_STATE EndPointState);
258
259/******************************************************************************
260**
261** Function         UUSB_WriteEndPoint
262**
263** Description
264**
265**
266** Returns
267**
268******************************************************************************/
269BT_API extern tUUSB_STATUS UUSB_WriteEndPoint (tUUSB_EP_ID     EndPoint,
270                                                UINT16     Length,
271                                                UINT8*    pBuf);
272
273/******************************************************************************
274**
275** Function         UUSB_GenerateRemoteWakeUp
276**
277** Description
278**
279**
280** Returns
281**
282******************************************************************************/
283BT_API extern tUUSB_STATUS UUSB_GenerateRemoteWakeUp (void);
284
285#ifdef __cplusplus
286};
287#endif
288
289
290#endif /* UUSB_H */
291