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