1 /**
2  * Copyright (c) 2015, Realsil Semiconductor Corporation. All rights reserved.
3  */
4 
5 #ifndef _HCI_PROTO_H_
6 #define _HCI_PROTO_H_
7 
8 #include <stdint.h>
9 #include <stdbool.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #define HCI_IF_TASK_PRIORITY            5
16 #define HCI_IF_STACK_SIZE               0x400
17 
18 #define HCI_IF_MSG_OPEN                 0x01    /* hci I/F open request */
19 #define HCI_IF_MSG_CLOSE                0x02    /* hci I/F close request */
20 #define HCI_IF_MSG_READY                0x03    /* hci I/F open succeeded */
21 #define HCI_IF_MSG_FAIL                 0x04    /* hci I/F open failed */
22 #define HCI_IF_MSG_TX_REQ               0x05    /* hci I/F xmit request */
23 #define HCI_IF_MSG_TX_RSP               0x06    /* hci I/F xmit response */
24 #define HCI_IF_MSG_RX_IND               0x07    /* hci I/F rx indicate */
25 #define HCI_IF_MSG_RX_CFM               0x08    /* hci I/F rx confirm */
26 
27 typedef enum
28 {
29     HCI_IF_STATE_IDLE,
30     HCI_IF_STATE_OPEN,
31     HCI_IF_STATE_READY,
32 } T_HCI_IF_STATE;
33 
34 typedef struct
35 {
36     uint8_t    *p_buf;
37     uint16_t    len;
38 } T_HCI_XMIT_DATA;
39 
40 typedef void (*P_HCI_PROTO_OPEN)(void);
41 
42 typedef void (*P_HCI_PROTO_CLOSE)(void);
43 
44 typedef bool (*P_HCI_PROTO_SEND)(uint8_t *p_buf, uint16_t len);
45 
46 typedef void (*P_HCI_PROTO_RECV)(void);
47 
48 typedef void (*P_HCI_PROTO_CFM)(void);
49 
50 typedef struct
51 {
52     P_HCI_PROTO_OPEN    open;
53     P_HCI_PROTO_CLOSE   close;
54     P_HCI_PROTO_SEND    send;
55     P_HCI_PROTO_RECV    recv;
56     P_HCI_PROTO_CFM     cfm;
57 } T_HCI_PROTO;
58 
59 typedef struct
60 {
61     T_HCI_IF_STATE       state;         /* hci I/F state */
62     void                *task_handle;   /* hci I/F task handle */
63     void                *msg_q;         /* task msg queue */
64     void                *xmit_q;        /* tx req queue */
65     void                *cfm_q;         /* rx cfm queue */
66     uint8_t             *tx_buf;        /* tx buffer pointer */
67     uint16_t             tx_len;        /* tx buffer length */
68     P_HCI_IF_CALLBACK    callback;      /* hci I/F event callback */
69     const T_HCI_PROTO   *proto;         /* hci h4/h5 proto interfaces */
70 } T_HCI_IF;
71 
72 extern T_HCI_IF hci_if;
73 extern const T_HCI_PROTO hci_h4_proto;
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* _HCI_PROTO_H_ */
80