• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2012-2014 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 #include "nfc_hal_target.h"
29 
30 /*******************************************************************************
31 ** tHAL_HCI_NETWK_CMD Definitions
32 *******************************************************************************/
33 #define HAL_NFC_HCI_NO_UICC_HOST 0x00
34 #define HAL_NFC_HCI_UICC0_HOST 0x01
35 #define HAL_NFC_HCI_UICC1_HOST 0x02
36 #define HAL_NFC_HCI_UICC2_HOST 0x04
37 
38 typedef uint8_t tHAL_NFC_STATUS;
39 typedef void(tHAL_NFC_STATUS_CBACK)(tHAL_NFC_STATUS status);
40 typedef void(tHAL_NFC_CBACK)(uint8_t event, tHAL_NFC_STATUS status);
41 typedef void(tHAL_NFC_DATA_CBACK)(uint16_t data_len, uint8_t* p_data);
42 
43 /*******************************************************************************
44 ** tHAL_NFC_ENTRY HAL entry-point lookup table
45 *******************************************************************************/
46 
47 typedef void(tHAL_API_INITIALIZE)(void);
48 typedef void(tHAL_API_TERMINATE)(void);
49 typedef void(tHAL_API_OPEN)(tHAL_NFC_CBACK* p_hal_cback,
50                             tHAL_NFC_DATA_CBACK* p_data_cback);
51 typedef void(tHAL_API_CLOSE)(void);
52 typedef void(tHAL_API_CORE_INITIALIZED)(uint16_t data_len,
53                                         uint8_t* p_core_init_rsp_params);
54 typedef void(tHAL_API_WRITE)(uint16_t data_len, uint8_t* p_data);
55 typedef bool(tHAL_API_PREDISCOVER)(void);
56 typedef void(tHAL_API_CONTROL_GRANTED)(void);
57 typedef void(tHAL_API_POWER_CYCLE)(void);
58 typedef uint8_t(tHAL_API_GET_MAX_NFCEE)(void);
59 
60 #define NFC_HAL_DM_PRE_SET_MEM_LEN 5
61 typedef struct {
62   uint32_t addr;
63   uint32_t data;
64 } tNFC_HAL_DM_PRE_SET_MEM;
65 
66 /* data members for NFC_HAL-HCI */
67 typedef struct {
68   bool nfc_hal_prm_nvm_required; /* set nfc_hal_prm_nvm_required to TRUE, if the
69                                     platform wants to abort PRM process without
70                                     NVM */
71   uint16_t nfc_hal_nfcc_enable_timeout; /* max time to wait for RESET NTF after
72                                            setting REG_PU to high */
73   uint16_t nfc_hal_post_xtal_timeout;   /* max time to wait for RESET NTF after
74                                            setting Xtal frequency */
75 #if (NFC_HAL_HCI_INCLUDED == TRUE)
76   bool nfc_hal_first_boot; /* set nfc_hal_first_boot to TRUE, if platform
77                               enables NFC for the first time after bootup */
78   uint8_t nfc_hal_hci_uicc_support; /* set nfc_hal_hci_uicc_support to Zero, if
79                                        no UICC is supported otherwise set
80                                        corresponding bit(s) for every supported
81                                        UICC(s) */
82 #endif
83 } tNFC_HAL_CFG;
84 
85 typedef struct {
86   tHAL_API_INITIALIZE* initialize;
87   tHAL_API_TERMINATE* terminate;
88   tHAL_API_OPEN* open;
89   tHAL_API_CLOSE* close;
90   tHAL_API_CORE_INITIALIZED* core_initialized;
91   tHAL_API_WRITE* write;
92   tHAL_API_PREDISCOVER* prediscover;
93   tHAL_API_CONTROL_GRANTED* control_granted;
94   tHAL_API_POWER_CYCLE* power_cycle;
95   tHAL_API_GET_MAX_NFCEE* get_max_ee;
96 
97 } tHAL_NFC_ENTRY;
98 
99 /*******************************************************************************
100 ** HAL API Function Prototypes
101 *******************************************************************************/
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 /*******************************************************************************
107 **
108 ** Function         HAL_NfcInitialize
109 **
110 ** Description      Called when HAL library is loaded.
111 **
112 **                  Initialize GKI and start the HCIT task
113 **
114 ** Returns          void
115 **
116 *******************************************************************************/
117 void HAL_NfcInitialize(void);
118 
119 /*******************************************************************************
120 **
121 ** Function         HAL_NfcTerminate
122 **
123 ** Description      Called to terminate NFC HAL
124 **
125 ** Returns          void
126 **
127 *******************************************************************************/
128 void HAL_NfcTerminate(void);
129 
130 /*******************************************************************************
131 **
132 ** Function         HAL_NfcOpen
133 **
134 ** Description      Open transport and intialize the NFCC, and
135 **                  Register callback for HAL event notifications,
136 **
137 **                  HAL_OPEN_CPLT_EVT will notify when operation is complete.
138 **
139 ** Returns          void
140 **
141 *******************************************************************************/
142 void HAL_NfcOpen(tHAL_NFC_CBACK* p_hal_cback,
143                  tHAL_NFC_DATA_CBACK* p_data_cback);
144 
145 /*******************************************************************************
146 **
147 ** Function         HAL_NfcClose
148 **
149 ** Description      Prepare for shutdown. A HAL_CLOSE_CPLT_EVT will be
150 **                  reported when complete.
151 **
152 ** Returns          void
153 **
154 *******************************************************************************/
155 void HAL_NfcClose(void);
156 
157 /*******************************************************************************
158 **
159 ** Function         HAL_NfcCoreInitialized
160 **
161 ** Description      Called after the CORE_INIT_RSP is received from the NFCC.
162 **                  At this time, the HAL can do any chip-specific
163 **                  configuration, and when finished signal the libnfc-nci with
164 **                  event HAL_POST_INIT_CPLT_EVT.
165 **
166 ** Returns          void
167 **
168 *******************************************************************************/
169 void HAL_NfcCoreInitialized(uint16_t data_len, uint8_t* p_core_init_rsp_params);
170 
171 /*******************************************************************************
172 **
173 ** Function         HAL_NfcWrite
174 **
175 ** Description      Send an NCI control message or data packet to the
176 **                  transport. If an NCI command message exceeds the transport
177 **                  size, HAL is responsible for fragmenting it, Data packets
178 **                  must be of the correct size.
179 **
180 ** Returns          void
181 **
182 *******************************************************************************/
183 void HAL_NfcWrite(uint16_t data_len, uint8_t* p_data);
184 
185 /*******************************************************************************
186 **
187 ** Function         HAL_NfcPreDiscover
188 **
189 ** Description      Perform any vendor-specific pre-discovery actions (if
190 **                  needed). If any actions were performed TRUE will be
191 **                  returned, and HAL_PRE_DISCOVER_CPLT_EVT will notify when
192 **                  actions are completed.
193 **
194 ** Returns          TRUE if vendor-specific pre-discovery actions initialized
195 **                  FALSE if no vendor-specific pre-discovery actions are
196 **                  needed.
197 **
198 *******************************************************************************/
199 bool HAL_NfcPreDiscover(void);
200 
201 /*******************************************************************************
202 **
203 ** Function         HAL_NfcControlGranted
204 **
205 ** Description      Grant control to HAL control for sending NCI commands.
206 **
207 **                  Call in response to HAL_REQUEST_CONTROL_EVT.
208 **
209 **                  Must only be called when there are no NCI commands pending.
210 **
211 **                  HAL_RELEASE_CONTROL_EVT will notify when HAL no longer
212 **                  needs control of NCI.
213 **
214 **
215 ** Returns          void
216 **
217 *******************************************************************************/
218 void HAL_NfcControlGranted(void);
219 
220 /*******************************************************************************
221 **
222 ** Function         HAL_NfcPowerCycle
223 **
224 ** Description      Restart NFCC by power cyle
225 **
226 **                  HAL_OPEN_CPLT_EVT will notify when operation is complete.
227 **
228 ** Returns          void
229 **
230 *******************************************************************************/
231 void HAL_NfcPowerCycle(void);
232 
233 /*******************************************************************************
234 **
235 ** Function         HAL_NfcGetMaxNfcee
236 **
237 ** Description      Retrieve the maximum number of NFCEEs supported by NFCC
238 **
239 ** Returns          the maximum number of NFCEEs supported by NFCC
240 **
241 *******************************************************************************/
242 uint8_t HAL_NfcGetMaxNfcee(void);
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* NFC_HAL_API_H  */
249