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