1/******************************************************************************
2 *
3 *  Copyright (C) 2009-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#ifndef UAMP_API_H
26#define UAMP_API_H
27
28/*****************************************************************************
29**  Constant and Type Definitions
30*****************************************************************************/
31
32/* UAMP identifiers */
33#define UAMP_ID_1   1
34#define UAMP_ID_2   2
35typedef UINT8 tUAMP_ID;
36
37/* UAMP event ids (used by UAMP_CBACK) */
38#define UAMP_EVT_RX_READY           0   /* Data from AMP controller is ready to be read */
39#define UAMP_EVT_CTLR_REMOVED       1   /* Controller removed */
40#define UAMP_EVT_CTLR_READY         2   /* Controller added/ready */
41typedef UINT8 tUAMP_EVT;
42
43
44/* UAMP Channels */
45#define UAMP_CH_HCI_CMD            0   /* HCI Command channel */
46#define UAMP_CH_HCI_EVT            1   /* HCI Event channel */
47#define UAMP_CH_HCI_DATA           2   /* HCI ACL Data channel */
48typedef UINT8 tUAMP_CH;
49
50/* tUAMP_EVT_DATA: union for event-specific data, used by UAMP_CBACK */
51typedef union {
52    tUAMP_CH channel;       /* UAMP_EVT_RX_READY: channel for which rx occured */
53} tUAMP_EVT_DATA;
54
55
56
57
58/*****************************************************************************
59**
60** Function:    UAMP_CBACK
61**
62** Description: Callback for events. Register callback using UAMP_Init.
63**
64** Parameters   amp_id:         AMP device identifier that generated the event
65**              amp_evt:        event id
66**              p_amp_evt_data: pointer to event-specific data
67**
68*****************************************************************************/
69typedef void (tUAMP_CBACK)(tUAMP_ID amp_id, tUAMP_EVT amp_evt, tUAMP_EVT_DATA *p_amp_evt_data);
70
71/*****************************************************************************
72**  external function declarations
73*****************************************************************************/
74#ifdef __cplusplus
75extern "C"
76{
77#endif
78
79/*****************************************************************************
80**
81** Function:    UAMP_Init
82**
83** Description: Initialize UAMP driver
84**
85** Parameters   p_cback:    Callback function for UAMP event notification
86**
87*****************************************************************************/
88BT_API BOOLEAN UAMP_Init(tUAMP_CBACK *p_cback);
89
90
91/*****************************************************************************
92**
93** Function:    UAMP_Open
94**
95** Description: Open connection to local AMP device.
96**
97** Parameters   app_id: Application specific AMP identifer. This value
98**                      will be included in AMP messages sent to the
99**                      BTU task, to identify source of the message
100**
101*****************************************************************************/
102BT_API BOOLEAN UAMP_Open(tUAMP_ID amp_id);
103
104/*****************************************************************************
105**
106** Function:    UAMP_Close
107**
108** Description: Close connection to local AMP device.
109**
110** Parameters   app_id: Application specific AMP identifer.
111**
112*****************************************************************************/
113BT_API void UAMP_Close(tUAMP_ID amp_id);
114
115
116/*****************************************************************************
117**
118** Function:    UAMP_Write
119**
120** Description: Send buffer to AMP device.
121**
122**
123** Parameters:  app_id:     AMP identifer.
124**              p_buf:      pointer to buffer to write
125**              num_bytes:  number of bytes to write
126**              channel:    UAMP_CH_HCI_ACL, or UAMP_CH_HCI_CMD
127**
128** Returns:     number of bytes written
129**
130*****************************************************************************/
131BT_API UINT16 UAMP_Write(tUAMP_ID amp_id, UINT8 *p_buf, UINT16 num_bytes, tUAMP_CH channel);
132
133
134/*****************************************************************************
135**
136** Function:    UAMP_WriteBuf
137**
138** Description: Send GKI buffer to AMP device. Frees GKI buffer when done.
139**
140** Parameters   app_amp_id: AMP identifer (BTM_AMP_1, BTM_AMP_2, ...)
141**              p_msg:      message to send.
142**
143*****************************************************************************/
144BT_API UINT16 UAMP_WriteBuf(tUAMP_ID amp_id, BT_HDR *p_msg);
145
146
147/*****************************************************************************
148**
149** Function:    UAMP_Read
150**
151** Description: Read incoming data from AMP. Call after receiving a
152**              UAMP_EVT_RX_READY callback event.
153**
154** Parameters:  app_id:     AMP identifer.
155**              p_buf:      pointer to buffer for holding incoming AMP data
156**              buf_size:   size of p_buf
157**              channel:    UAMP_CH_HCI_ACL, or UAMP_CH_HCI_EVT
158**
159** Returns:     number of bytes read
160**
161*****************************************************************************/
162BT_API UINT16 UAMP_Read(tUAMP_ID amp_id, UINT8 *p_buf, UINT16 buf_size, tUAMP_CH channel);
163
164#ifdef __cplusplus
165}
166#endif
167
168#endif /* UAMP_API_H */
169