usb.h revision 45faad0ff5deeb0c676356345d99398cc4ab695a
1/******************************************************************************* 2** Name: usb.h 3** 4** Description: 5** 6** This file contains serial definitions from WIDCOMM's Universal Embedded 7** Drivers API. 8** 9** Copyright (c) 2001-2004, WIDCOMM Inc., All Rights Reserved. 10** WIDCOMM Bluetooth Core. Proprietary and confidential. 11*******************************************************************************/ 12 13#ifndef USB_H 14#define USB_H 15 16/******************************************************************************* 17** Serial APIs 18*******************************************************************************/ 19 20/**** port IDs ****/ 21#define USB_PORT_1 0 22#define USB_PORT_2 1 23#define USB_PORT_3 2 24#define USB_PORT_4 3 25 26typedef UINT8 tUSB_PORT; 27 28/**** baud rates ****/ 29#define USB_BAUD_300 0 30#define USB_BAUD_600 1 31#define USB_BAUD_1200 2 32#define USB_BAUD_2400 3 33#define USB_BAUD_9600 4 34#define USB_BAUD_19200 5 35#define USB_BAUD_57600 6 36#define USB_BAUD_115200 7 37#define USB_BAUD_230400 8 38#define USB_BAUD_460800 9 39#define USB_BAUD_921600 10 40#define USB_BAUD_AUTO 11 41 42/**** Data Format ****/ 43 44/* Stop Bits */ 45#define USB_STOPBITS_1 1 46#define USB_STOPBITS_1_5 (1<<1) 47#define USB_STOPBITS_2 (1<<2) 48 49/* Parity Bits */ 50#define USB_PARITY_NONE (1<<3) 51#define USB_PARITY_EVEN (1<<4) 52#define USB_PARITY_ODD (1<<5) 53 54/* Data Bits */ 55#define USB_DATABITS_5 (1<<6) 56#define USB_DATABITS_6 (1<<7) 57#define USB_DATABITS_7 (1<<8) 58#define USB_DATABITS_8 (1<<9) 59 60 61/**** Flow Control ****/ 62#define USB_FC_NONE 0 63#define USB_FC_HW 1 64#define USB_FC_SW 2 65 66/**** Data Buffering Mechanism ****/ 67#define USB_BUF_BYTE 0 68#define USB_BUF_GKI 1 69 70/**** Signals ****/ 71#define USB_SIG_RTSCTS 1 72#define USB_SIG_DSRDTR (1<<1) 73#define USB_SIG_RI (1<<2) 74#define USB_SIG_CD (1<<3) 75#define USB_SIG_DTE_DEVICE (1<<4) 76 77/**** Errors *****/ 78#define USB_ERR_OVERRUN 1 79#define USB_ERR_PARITY (1<<1) 80#define USB_ERR_FRAMING (1<<2) 81#define USB_ERR_BREAK (1<<3) 82 83/**** Serial Operations ****/ 84#define USB_OP_FLUSH 0 85#define USB_OP_FLUSH_RX 1 86#define USB_OP_FLUSH_TX 2 87#define USB_OP_BREAK_OFF 3 88#define USB_OP_BREAK_ON 4 89#define USB_OP_BAUD_RD 5 90#define USB_OP_BAUD_WR 6 91#define USB_OP_FMT_RD 7 92#define USB_OP_FMT_WR 8 93#define USB_OP_SIG_RD 9 94#define USB_OP_SIG_WR 10 95#define USB_OP_FC_RD 11 96#define USB_OP_FC_WR 12 97 98typedef UINT8 tUSB_OP; 99 100 101/**** Serial feature types ****/ 102#define USB_FEAT_PORT_1 0 103#define USB_FEAT_PORT_2 1 104#define USB_FEAT_PORT_3 2 105#define USB_FEAT_PORT_4 3 106#define USB_FEAT_BAUD_AUTO 4 107#define USB_FEAT_BAUD_300 5 108#define USB_FEAT_BAUD_600 6 109#define USB_FEAT_BAUD_1200 7 110#define USB_FEAT_BAUD_2400 8 111#define USB_FEAT_BAUD_9600 9 112#define USB_FEAT_BAUD_19200 10 113#define USB_FEAT_BAUD_57600 11 114#define USB_FEAT_BAUD_115200 12 115#define USB_FEAT_BAUD_230400 13 116#define USB_FEAT_BAUD_460800 14 117#define USB_FEAT_BAUD_921600 15 118#define USB_FEAT_STOPBITS_1 16 119#define USB_FEAT_STOPBITS_1_5 17 120#define USB_FEAT_STOPBITS_2 18 121#define USB_FEAT_PARITY_NONE 19 122#define USB_FEAT_PARITY_EVEN 20 123#define USB_FEAT_PARITY_ODD 21 124#define USB_FEAT_DATABITS_5 22 125#define USB_FEAT_DATABITS_6 23 126#define USB_FEAT_DATABITS_7 24 127#define USB_FEAT_DATABITS_8 25 128#define USB_FEAT_FC_NONE 26 129#define USB_FEAT_FC_HW 27 130#define USB_FEAT_FC_SW 28 131#define USB_FEAT_BUF_BYTE 29 132#define USB_FEAT_BUF_GKI 30 133#define USB_FEAT_SIG_RTS 31 134#define USB_FEAT_SIG_CTS 32 135#define USB_FEAT_SIG_DSR 33 136#define USB_FEAT_SIG_DTR 34 137#define USB_FEAT_SIG_RI 35 138#define USB_FEAT_SIG_CD 36 139#define USB_FEAT_OP_FLUSH 37 140#define USB_FEAT_OP_FLUSH_RX 38 141#define USB_FEAT_OP_FLUSH_TX 39 142#define USB_FEAT_OP_BREAK 40 143#define USB_FEAT_OP_BAUD_RD 41 144#define USB_FEAT_OP_BAUD_WR 42 145#define USB_FEAT_OP_FMT_RD 43 146#define USB_FEAT_OP_FMT_WR 44 147#define USB_FEAT_OP_SIG_RD 45 148#define USB_FEAT_OP_SIG_WR 46 149#define USB_FEAT_OP_FC_RD 47 150#define USB_FEAT_OP_FC_WR 48 151 152typedef UINT8 tUSB_FEATURE; 153 154 155/**** Event types ****/ 156#define USB_RX_READY_EVT 0 157#define USB_TX_DONE_EVT 1 158#define USB_SIG_EVT 2 159#define USB_ERR_EVT 3 160 161typedef UINT8 tUSB_EVT; 162 163 164/* Structure used to configure serial port during open */ 165typedef struct 166{ 167 UINT16 fmt; /* Data format */ 168 UINT8 baud; /* Baud rate */ 169 UINT8 fc; /* Flow control */ 170 UINT8 buf; /* Data buffering mechanism */ 171 UINT8 pool; /* GKI buffer pool for received data */ 172 UINT16 size; /* Size of GKI buffer pool */ 173 UINT16 offset; /* Offset in GKI buffer pool */ 174} tUSB_OPEN_CFG; 175 176/* Union used to pass ioctl arguments */ 177typedef union 178{ 179 UINT16 fmt; 180 UINT8 baud; 181 UINT8 fc; 182 UINT8 sigs; 183} tUSB_IOCTL_DATA; 184 185 186/* Union to pass event data */ 187typedef union 188{ 189 UINT8 sigs; 190 UINT8 error; 191} tUSB_EVT_DATA; 192 193/* callback for events */ 194typedef void (tUSB_CBACK)(tUSB_PORT, tUSB_EVT, tUSB_EVT_DATA *); 195 196 197/******************************************************************************* 198** Function Prototypes 199*******************************************************************************/ 200 201#ifdef __cplusplus 202extern "C" { 203#endif 204 205UDRV_API extern void USB_Init(void *); 206UDRV_API extern void USB_Open(tUSB_PORT, tUSB_OPEN_CFG *, tUSB_CBACK *); 207UDRV_API extern void USB_ReadBuf(tUSB_PORT, BT_HDR **); 208UDRV_API extern UINT16 USB_Read(tUSB_PORT, UINT8 *, UINT16); 209UDRV_API extern BOOLEAN USB_WriteBuf(tUSB_PORT, BT_HDR *); 210UDRV_API extern UINT16 USB_Write(tUSB_PORT, UINT8 *, UINT16); 211UDRV_API extern void USB_Ioctl(tUSB_PORT, tUSB_OP, tUSB_IOCTL_DATA *); 212UDRV_API extern void USB_Close(tUSB_PORT); 213UDRV_API extern BOOLEAN USB_Feature(tUSB_FEATURE); 214 215#ifdef __cplusplus 216} 217#endif 218 219#endif /* USB_H */ 220