nfc_hal_api.h revision e9df6ba5a8fcccf306a80b1670b423be8fe7746a
1/******************************************************************************
2 *
3 *  Copyright (C) 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 *  NFC Hardware Abstraction Layer API
22 *
23 ******************************************************************************/
24#ifndef NFC_HAL_API_H
25#define NFC_HAL_API_H
26#include <hardware/nfc.h>
27#include "data_types.h"
28
29/****************************************************************************
30** NFC_HDR header definition for NFC messages
31*****************************************************************************/
32typedef struct
33{
34    UINT16          event;
35    UINT16          len;
36    UINT16          offset;
37    UINT16          layer_specific;
38} NFC_HDR;
39#define NFC_HDR_SIZE (sizeof (NFC_HDR))
40
41typedef UINT8 tHAL_NFC_STATUS;
42
43typedef void (tHAL_NFC_STATUS_CBACK) (tHAL_NFC_STATUS status);
44typedef void (tHAL_NFC_CBACK) (UINT8 event, tHAL_NFC_STATUS status);
45typedef void (tHAL_NFC_DATA_CBACK) (UINT16 data_len, UINT8   *p_data);
46
47/*******************************************************************************
48** tHAL_NFC_ENTRY HAL entry-point lookup table
49*******************************************************************************/
50
51typedef void (tHAL_API_INITIALIZE) (void);
52typedef void (tHAL_API_TERMINATE) (void);
53typedef void (tHAL_API_OPEN) (tHAL_NFC_CBACK *p_hal_cback, tHAL_NFC_DATA_CBACK *p_data_cback);
54typedef void (tHAL_API_CLOSE) (void);
55typedef void (tHAL_API_CORE_INITIALIZED) (UINT8 *p_core_init_rsp_params);
56typedef void (tHAL_API_WRITE) (UINT16 data_len, UINT8 *p_data);
57typedef BOOLEAN (tHAL_API_PREDISCOVER) (void);
58typedef void (tHAL_API_CONTROL_GRANTED) (void);
59typedef void (tHAL_API_POWER_CYCLE) (void);
60
61
62typedef struct
63{
64    tHAL_API_INITIALIZE *initialize;
65    tHAL_API_TERMINATE *terminate;
66    tHAL_API_OPEN *open;
67    tHAL_API_CLOSE *close;
68    tHAL_API_CORE_INITIALIZED *core_initialized;
69    tHAL_API_WRITE *write;
70    tHAL_API_PREDISCOVER *prediscover;
71    tHAL_API_CONTROL_GRANTED *control_granted;
72    tHAL_API_POWER_CYCLE *power_cycle;
73
74
75} tHAL_NFC_ENTRY;
76
77
78/*******************************************************************************
79** HAL API Function Prototypes
80*******************************************************************************/
81#ifdef __cplusplus
82extern "C"
83{
84#endif
85
86/* Toolset-specific macro for exporting API funcitons */
87#if (defined(NFC_HAL_TARGET) && (NFC_HAL_TARGET == TRUE)) && (defined(_WINDLL))
88#define EXPORT_HAL_API  __declspec(dllexport)
89#else
90#define EXPORT_HAL_API
91#endif
92
93/*******************************************************************************
94**
95** Function         HAL_NfcInitialize
96**
97** Description      Called when HAL library is loaded.
98**
99**                  Initialize GKI and start the HCIT task
100**
101** Returns          void
102**
103*******************************************************************************/
104EXPORT_HAL_API void HAL_NfcInitialize(void);
105
106/*******************************************************************************
107**
108** Function         HAL_NfcTerminate
109**
110** Description      Called to terminate NFC HAL
111**
112** Returns          void
113**
114*******************************************************************************/
115EXPORT_HAL_API void HAL_NfcTerminate(void);
116
117/*******************************************************************************
118**
119** Function         HAL_NfcOpen
120**
121** Description      Open transport and intialize the NFCC, and
122**                  Register callback for HAL event notifications,
123**
124**                  HAL_OPEN_CPLT_EVT will notify when operation is complete.
125**
126** Returns          void
127**
128*******************************************************************************/
129EXPORT_HAL_API void HAL_NfcOpen (tHAL_NFC_CBACK *p_hal_cback, tHAL_NFC_DATA_CBACK *p_data_cback);
130
131/*******************************************************************************
132**
133** Function         HAL_NfcClose
134**
135** Description      Prepare for shutdown. A HAL_CLOSE_CPLT_EVT will be
136**                  reported when complete.
137**
138** Returns          void
139**
140*******************************************************************************/
141EXPORT_HAL_API void HAL_NfcClose (void);
142
143/*******************************************************************************
144**
145** Function         HAL_NfcCoreInitialized
146**
147** Description      Called after the CORE_INIT_RSP is received from the NFCC.
148**                  At this time, the HAL can do any chip-specific configuration,
149**                  and when finished signal the libnfc-nci with event
150**                  HAL_POST_INIT_CPLT_EVT.
151**
152** Returns          void
153**
154*******************************************************************************/
155EXPORT_HAL_API void HAL_NfcCoreInitialized (UINT8 *p_core_init_rsp_params);
156
157/*******************************************************************************
158**
159** Function         HAL_NfcWrite
160**
161** Description      Send an NCI control message or data packet to the
162**                  transport. If an NCI command message exceeds the transport
163**                  size, HAL is responsible for fragmenting it, Data packets
164**                  must be of the correct size.
165**
166** Returns          void
167**
168*******************************************************************************/
169EXPORT_HAL_API void HAL_NfcWrite (UINT16 data_len, UINT8 *p_data);
170
171/*******************************************************************************
172**
173** Function         HAL_NfcPreDiscover
174**
175** Description      Perform any vendor-specific pre-discovery actions (if needed)
176**                  If any actions were performed TRUE will be returned, and
177**                  HAL_PRE_DISCOVER_CPLT_EVT will notify when actions are
178**                  completed.
179**
180** Returns          TRUE if vendor-specific pre-discovery actions initialized
181**                  FALSE if no vendor-specific pre-discovery actions are needed.
182**
183*******************************************************************************/
184EXPORT_HAL_API BOOLEAN HAL_NfcPreDiscover (void);
185
186/*******************************************************************************
187**
188** Function         HAL_NfcControlGranted
189**
190** Description      Grant control to HAL control for sending NCI commands.
191**
192**                  Call in response to HAL_REQUEST_CONTROL_EVT.
193**
194**                  Must only be called when there are no NCI commands pending.
195**
196**                  HAL_RELEASE_CONTROL_EVT will notify when HAL no longer
197**                  needs control of NCI.
198**
199**
200** Returns          void
201**
202*******************************************************************************/
203EXPORT_HAL_API void HAL_NfcControlGranted (void);
204
205/*******************************************************************************
206**
207** Function         HAL_NfcPowerCycle
208**
209** Description      Restart NFCC by power cyle
210**
211**                  HAL_OPEN_CPLT_EVT will notify when operation is complete.
212**
213** Returns          void
214**
215*******************************************************************************/
216EXPORT_HAL_API void HAL_NfcPowerCycle (void);
217
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif /* NFC_HAL_API_H  */
224