1 /*
2  * Copyright (C) 2010 NXP Semiconductors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*!
18 * =========================================================================== *
19 *                                                                             *
20 *                                                                             *
21 * \file  phHciNfc_RFReader.h                                                  *
22 * \brief HCI Header for the RF Reader Management Gate.                        *
23 *                                                                             *
24 *                                                                             *
25 * Project: NFC-FRI-1.1                                                        *
26 *                                                                             *
27 * $Date: Fri Aug 14 17:01:28 2009 $                                           *
28 * $Author: ing04880 $                                                         *
29 * $Revision: 1.17 $                                                            *
30 * $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $                                                                *
31 *                                                                             *
32 * =========================================================================== *
33 */
34 
35 
36 #ifndef PHHCINFC_RFREADER_H
37 #define PHHCINFC_RFREADER_H
38 
39 /*@}*/
40 
41 
42 /**
43  *  \name HCI
44  *
45  * File: \ref phHciNfc_RFReader.h
46  *
47  */
48 /*@{*/
49 #define PHHCINFC_RF_READER_FILEREVISION "$Revision: 1.17 $" /**< \ingroup grp_file_attributes */
50 #define PHHCINFC_RF_READER_FILEALIASES  "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $"   /**< \ingroup grp_file_attributes */
51 /*@}*/
52 
53 /*
54 ***************************** Header File Inclusion ****************************
55 */
56 
57 #include <phHciNfc_Generic.h>
58 
59 /*
60 ****************************** Macro Definitions *******************************
61 */
62 /* Events Requested by the Reader Application Gates */
63 #define EVT_READER_REQUESTED            0x10U
64 #define EVT_END_OPERATION               0x11U
65 
66 /* Events Triggered by the Reader RF Gates */
67 #define EVT_TARGET_DISCOVERED           0x10U
68 
69 /* Commands from ETSI HCI Specification */
70 #define WR_XCHGDATA                     0x10U
71 
72 /* NXP Additional Commands apart from ETSI HCI Specification */
73 /* Command to Check the presence of the card */
74 #define NXP_WR_PRESCHECK                0x30U
75 
76 /* Command to Activate the next card present in the field */
77 #define NXP_WR_ACTIVATE_NEXT            0x31U
78 
79 /* Command to Activate a card with its UID */
80 #define NXP_WR_ACTIVATE_ID              0x32U
81 
82 /* Command to Dispatch the card to UICC */
83 #define NXP_WR_DISPATCH_TO_UICC         0x33U
84 
85 /* NXP Additional Events apart from ETSI HCI Specification */
86 /* Event to Release the Target and Restart The Wheel */
87 #define NXP_EVT_RELEASE_TARGET          0x35U
88 
89 
90 /* Type Macro to Update the  RF Reader Information */
91 
92 #define HCI_RDR_ENABLE_TYPE             0x01U
93 
94 #define UICC_CARD_ACTIVATION_SUCCESS    0x00U
95 #define UICC_CARD_ACTIVATION_ERROR      0x01U
96 #define UICC_RDR_NOT_INTERESTED         0x02U
97 
98 
99 /*
100 ******************** Enumeration and Structure Definition **********************
101 */
102 
103 
104 
105 /*
106 *********************** Function Prototype Declaration *************************
107 */
108 
109 /**
110  * \ingroup grp_hci_nfc
111  *
112  *  The phHciNfc_ReaderMgmt_Initialise function creates and the opens RF Reader
113  *  Management Gate
114  *
115  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
116  *                                      context Structure.
117  *  \param[in]  pHwRef                  pHwRef is the Information of
118  *                                      the Device Interface Link .
119  *
120  *  \retval NFCSTATUS_PENDING           Reader RF Mgmt Gate Initialisation is pending.
121  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
122  *                                      could not be interpreted properly.
123  *  \retval Other errors                Errors related to the other layers
124  *
125  */
126 extern
127 NFCSTATUS
128 phHciNfc_ReaderMgmt_Initialise(
129                                 phHciNfc_sContext_t     *psHciContext,
130                                 void                    *pHwRef
131                          );
132 /**
133  * \ingroup grp_hci_nfc
134  *
135  *  The phHciNfc_ReaderMgmt_Release function closes the opened RF Reader pipes
136  *  between the Host Controller Device and the NFC Device.
137  *
138  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
139  *                                      context Structure.
140  *  \param[in]  pHwRef                  pHwRef is the Information of
141  *                                      the Device Interface Link .
142  *
143  *  \retval NFCSTATUS_PENDING           Release of the Reader RF Management gate
144  *                                      resources are pending.
145  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
146  *                                      could not be interpreted properly.
147  *  \retval Other errors                Errors related to the other layers
148  *
149  */
150 extern
151 NFCSTATUS
152 phHciNfc_ReaderMgmt_Release(
153                                 phHciNfc_sContext_t     *psHciContext,
154                                 void                    *pHwRef
155                      );
156 
157 /**
158  * \ingroup grp_hci_nfc
159  *
160  *  The phHciNfc_ReaderMgmt_Update_Sequence function Resets/Updates the sequence
161  *  to the Specified RF Reader Sequence .
162  *
163  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
164  *                                      context Structure.
165  *  \param[in]  reader_seq              reader_seq is the Type of sequence update
166  *                                      required to reset .
167  *
168  *  \retval NFCSTATUS_SUCCESS           Updates/Resets the Sequence of the Reader
169  *                                       RF Management gate Successsfully.
170  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
171  *                                      could not be interpreted properly.
172  *  \retval
173  *   NFCSTATUS_INVALID_HCI_INFORMATION  The RF Reader Management information is
174  *                                      invalid.
175  *
176  */
177 
178 extern
179 NFCSTATUS
180 phHciNfc_ReaderMgmt_Update_Sequence(
181                                 phHciNfc_sContext_t     *psHciContext,
182                                 phHciNfc_eSeqType_t     reader_seq
183                              );
184 
185 /**
186  * \ingroup grp_hci_nfc
187  *
188  *  The phHciNfc_ReaderMgmt_Enable_Discovery function Enables the RF Reader
189  *  Gates to discover the corresponding PICC Tags .
190  *
191  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
192  *                                      context Structure.
193  *  \param[in]  pHwRef                  pHwRef is the Information of
194  *                                      the Device Interface Link .
195  *
196  *  \retval NFCSTATUS_PENDING           Enable of the Reader RF Management gate
197  *                                      Discovery is pending.
198  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
199  *                                      could not be interpreted properly.
200  *  \retval Other errors                Errors related to the other layers
201  *
202  */
203 
204 extern
205 NFCSTATUS
206 phHciNfc_ReaderMgmt_Enable_Discovery(
207                                 phHciNfc_sContext_t     *psHciContext,
208                                 void                    *pHwRef
209                              );
210 
211 /**
212  * \ingroup grp_hci_nfc
213  *
214  *  The phHciNfc_ReaderMgmt_Discovery function Enables/Disables/Restart/Continue
215  *  the RF Reader Gates to discover the corresponding PICC Tags .
216  *
217  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
218  *                                      context Structure.
219  *  \param[in]  pHwRef                  pHwRef is the Information of
220  *                                      the Device Interface Link .
221  *
222  *  \retval NFCSTATUS_PENDING           Enable of the Reader RF Management gate
223  *                                      Discovery is pending.
224  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
225  *                                      could not be interpreted properly.
226  *  \retval Other errors                Errors related to the other layers
227  *
228  */
229 
230 
231 /**
232  * \ingroup grp_hci_nfc
233  *
234  *  The phHciNfc_ReaderMgmt_Disable_Discovery function Disables the RF Reader
235  *  Gates discovery .
236  *
237  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
238  *                                      context Structure.
239  *  \param[in]  pHwRef                  pHwRef is the Information of
240  *                                      the Device Interface Link .
241  *
242  *  \retval NFCSTATUS_PENDING           Disable of the Reader RF Management gate
243  *                                      Discovery is pending.
244  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
245  *                                      could not be interpreted properly.
246  *  \retval Other errors                Errors related to the other layers
247  *
248  */
249 
250 extern
251 NFCSTATUS
252 phHciNfc_ReaderMgmt_Disable_Discovery(
253                                 phHciNfc_sContext_t     *psHciContext,
254                                 void                    *pHwRef
255                              );
256 
257 
258 /**
259  * \ingroup grp_hci_nfc
260  *
261  *  The phHciNfc_ReaderMgmt_Info_Sequence function Gets the information
262  *  of the Tag discovered .
263  *
264  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
265  *                                      context Structure.
266  *  \param[in]  pHwRef                  pHwRef is the Information of
267  *                                      the Device Interface Link .
268  *
269  *  \retval NFCSTATUS_PENDING           Reception the information of the discoverd
270  *                                      tag is ongoing.
271  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
272  *                                      could not be interpreted properly.
273  *  \retval Other errors                Errors related to the other layers
274  *
275  */
276 
277 extern
278 NFCSTATUS
279 phHciNfc_ReaderMgmt_Info_Sequence(
280                                    phHciNfc_sContext_t      *psHciContext,
281                                    void                     *pHwRef
282                                );
283 
284 /**
285  * \ingroup grp_hci_nfc
286  *
287  *  The phHciNfc_ReaderMgmt_Select function connects the
288  *  the selected tag by performing certain operation.
289  *
290  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
291  *                                      context Structure.
292  *  \param[in]  pHwRef                  pHwRef is the Information of
293  *                                      the Device Interface Link .
294  *  \param[in]  target_type             target_type is the type of the
295  *                                      Target Device to be connected .
296  *
297  *  \retval NFCSTATUS_PENDING           The selected tag initialisation for
298  *                                      transaction ongoing.
299  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
300  *                                      could not be interpreted properly.
301  *  \retval Other errors                Errors related to the other layers
302  *
303  */
304 
305 extern
306 NFCSTATUS
307 phHciNfc_ReaderMgmt_Select(
308                                     phHciNfc_sContext_t     *psHciContext,
309                                     void                    *pHwRef,
310                                     phHal_eRemDevType_t     target_type
311                 );
312 
313 
314 /**
315  * \ingroup grp_hci_nfc
316  *
317  *  The phHciNfc_ReaderMgmt_Reactivate function reactivates the
318  *  the tag by performing reactivate operation.
319  *
320  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
321  *                                      context Structure.
322  *  \param[in]  pHwRef                  pHwRef is the Information of
323  *                                      the Device Interface Link .
324  *  \param[in]  target_type             target_type is the type of the
325  *                                      Target Device to be reactivated .
326  *
327  *  \retval NFCSTATUS_PENDING           The tag reactivation ongoing.
328  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
329  *                                      could not be interpreted properly.
330  *  \retval Other errors                Errors related to the other layers
331  *
332  */
333 
334 
335 extern
336 NFCSTATUS
337 phHciNfc_ReaderMgmt_Reactivate(
338                                     phHciNfc_sContext_t     *psHciContext,
339                                     void                    *pHwRef,
340                                     phHal_eRemDevType_t     target_type
341                 );
342 
343 /**
344 * \ingroup grp_hci_nfc
345 *
346 *   The phHciNfc_ReaderMgmt_Presence_Check function performs presence on ISO
347 *   cards.
348 *
349 *   \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
350 *                                       context Structure.
351 *   \param[in]  pHwRef                  pHwRef is the Information of
352 *                                       the Device Interface Link .
353 *
354 *   \retval NFCSTATUS_PENDING           The presence check for tag is ongoing.
355 *   \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
356 *                                       could not be interpreted properly.
357 *  \retval Other errors                Errors related to the other layers
358 *
359 */
360 
361 extern
362 NFCSTATUS
363 phHciNfc_ReaderMgmt_Presence_Check(
364                                   phHciNfc_sContext_t       *psHciContext,
365                                   void                      *pHwRef
366                                   );
367 
368 /**
369 * \ingroup grp_hci_nfc
370 *
371 *   The phHciNfc_ReaderMgmt_Activate_Next function activates and selects next
372 *   tag or target present in the RF Field .
373 *
374 *   \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
375 *                                       context Structure.
376 *   \param[in]  pHwRef                  pHwRef is the Information of
377 *                                       the Device Interface Link .
378 *
379 *   \retval NFCSTATUS_PENDING           The activation of the next tag is ongoing.
380 *   \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
381 *                                       could not be interpreted properly.
382 *  \retval Other errors                Errors related to the other layers
383 *
384 */
385 
386 extern
387 NFCSTATUS
388 phHciNfc_ReaderMgmt_Activate_Next(
389                                   phHciNfc_sContext_t       *psHciContext,
390                                   void                  *pHwRef
391                                   );
392 
393 
394 /**
395  * \ingroup grp_hci_nfc
396  *
397  *  The phHciNfc_ReaderMgmt_UICC_Dispatch function de-activates the
398  *  the selected tag by de-selecting the tag and dispatch the Card to UICC.
399  *
400  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
401  *                                      context Structure.
402  *  \param[in]  pHwRef                  pHwRef is the Information of
403  *                                      the Device Interface Link .
404  *  \param[in]  target_type             target_type is the type of the
405  *                                      Target Device to be de-selected .
406  *  \param[in]  re_poll                 If True: Start re-polling of the target
407  *                                      after the Target Device is de-activated
408  *                                      or else - continue discovery with next
409  *                                      technology.
410  *
411  *
412  *  \retval NFCSTATUS_PENDING           Dispatching the selected tag to UICC
413  *                                      is ongoing.
414  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
415  *                                      could not be interpreted properly.
416  *  \retval Other errors                Errors related to the other layers
417  *
418  */
419 
420 extern
421 NFCSTATUS
422 phHciNfc_ReaderMgmt_UICC_Dispatch(
423                                     phHciNfc_sContext_t     *psHciContext,
424                                     void                    *pHwRef,
425                                     phHal_eRemDevType_t     target_type
426                 );
427 
428 
429 /**
430  * \ingroup grp_hci_nfc
431  *
432  *  The phHciNfc_ReaderMgmt_Deselect function de-activates the
433  *  the selected tag by de-selecting the tag and restarting the discovery.
434  *
435  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
436  *                                      context Structure.
437  *  \param[in]  pHwRef                  pHwRef is the Information of
438  *                                      the Device Interface Link .
439  *  \param[in]  target_type             target_type is the type of the
440  *                                      Target Device to be de-selected .
441  *
442  *  \retval NFCSTATUS_PENDING           Terminating the operations between selected
443  *                                      tag is ongoing.
444  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
445  *                                      could not be interpreted properly.
446  *  \retval Other errors                Errors related to the other layers
447  *
448  */
449 
450 extern
451 NFCSTATUS
452 phHciNfc_ReaderMgmt_Deselect(
453                                     phHciNfc_sContext_t     *psHciContext,
454                                     void                    *pHwRef,
455                                     phHal_eRemDevType_t     target_type,
456                                     uint8_t                 re_poll
457                 );
458 
459 /**
460  * \ingroup grp_hci_nfc
461  *
462  *  The phHciNfc_ReaderMgmt_Exchange_Data function exchanges the
463  *  data to/from the selected tag .
464  *
465  *  \param[in]  psHciContext            psHciContext is the pointer to HCI Layer
466  *                                      context Structure.
467  *  \param[in]  pHwRef                  pHwRef is the Information of
468  *                                      the Device Interface Link .
469  *  \param[in]  p_xchg_info             The tag exchange info contains the command type,
470  *                                      addr and data to be sent to the connected
471  *                                      remote target device.
472  *
473  *  \retval NFCSTATUS_PENDING           Exchange of the data between the selected
474  *                                      tag is ongoing.
475  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
476  *                                      could not be interpreted properly.
477  *  \retval Other errors                Errors related to the other layers
478  *
479  */
480 
481 extern
482 NFCSTATUS
483 phHciNfc_ReaderMgmt_Exchange_Data(
484                                     phHciNfc_sContext_t     *psHciContext,
485                                     void                    *pHwRef,
486                                     phHciNfc_XchgInfo_t     *p_xchg_info
487                 );
488 
489 
490 
491 /**
492  * \ingroup grp_hci_nfc
493  *
494  *  The phHciNfc_Send_RFReader_Command function sends the HCI Reader Gate
495  *  Specific Commands to the HCI Controller device.
496  *
497  *  \param[in]  psHciContext            psHciContext is the context of
498  *                                      the HCI Layer.
499  *  \param[in]  pHwRef                  pHwRef is the Information of
500  *                                      the Device Interface Link .
501  *  \param[in]  pipe_id                 The Reader pipe to which the
502  *                                      command is being sent.
503  *  \param[in]  cmd                     The HCI Reader Gate specific command
504  *                                      sent to a Reader pipe .
505  *
506  *
507  *  \retval NFCSTATUS_PENDING           ETSI HCI RF Reader gate Command
508  *                                      to be sent is pending.
509  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
510  *                                      could not be interpreted properly.
511  *  \retval Other errors                Errors related to the other layers
512  *
513  */
514 
515 extern
516 NFCSTATUS
517  phHciNfc_Send_RFReader_Command (
518                                 phHciNfc_sContext_t *psHciContext,
519                                 void                *pHwRef,
520                                 uint8_t             pipe_id,
521                                 uint8_t             cmd
522                     );
523 
524 /**
525  * \ingroup grp_hci_nfc
526  *
527  *  The phHciNfc_Send_RFReader_Event function sends the HCI Reader Gate
528  *  Specific Events to the HCI Controller device.
529  *
530  *  \param[in]  psHciContext            psHciContext is the context of
531  *                                      the HCI Layer.
532  *  \param[in]  pHwRef                  pHwRef is the Information of
533  *                                      the Device Interface Link .
534  *  \param[in]  pipe_id                 The Reader pipe to which the
535  *                                      command is being sent.
536  *  \param[in]  event                   The HCI Reader Gate specific event
537  *                                      sent to a Reader pipe .
538  *
539  *
540  *  \retval NFCSTATUS_PENDING           ETSI HCI RF Reader gate Event
541  *                                      to be sent is pending.
542  *  \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters
543  *                                      could not be interpreted properly.
544  *  \retval Other errors                Errors related to the other layers
545  *
546  */
547 
548 extern
549 NFCSTATUS
550  phHciNfc_Send_RFReader_Event (
551                                 phHciNfc_sContext_t *psHciContext,
552                                 void                *pHwRef,
553                                 uint8_t             pipe_id,
554                                 uint8_t             event
555                     );
556 
557 #endif /* PHHCINFC_RFREADER_H */
558 
559