xref: /aosp_15_r20/system/nfc/src/nfc/include/rw_api.h (revision 7eba2f3b06c51ae21384f6a4f14577b668a869b3)
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-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  *  This file contains the Near Field Communication (NFC) Reader/Writer mode
22  *  related API function external definitions.
23  *
24  ******************************************************************************/
25 
26 #ifndef RW_API_H
27 #define RW_API_H
28 #include "nfc_api.h"
29 #include "tags_defs.h"
30 
31 #define RW_T1T_BLD_ADD(a, k, y) (a) = (((k) & 0xF) << 3) | ((y) & 0x7);
32 #define RW_T1T_BLD_ADDS(a, s) (a) = (((s) & 0xF) << 4);
33 
34 #define RW_T1T_FIRST_EVT 0x20
35 #define RW_T2T_FIRST_EVT 0x40
36 #define RW_T3T_FIRST_EVT 0x60
37 #define RW_T4T_FIRST_EVT 0x80
38 #define RW_I93_FIRST_EVT 0xA0
39 #define RW_MFC_FIRST_EVT 0xC0
40 #define RW_CI_FIRST_EVT 0xD0
41 
42 enum {
43   /* Note: the order of these events can not be changed */
44   /* Type 1 tag events for tRW_CBACK */
45   RW_T1T_RID_EVT = RW_T1T_FIRST_EVT, /* Read ID command completd              */
46   RW_T1T_RALL_CPLT_EVT,              /* Read All command completed            */
47   RW_T1T_READ_CPLT_EVT,              /* Read byte completed                   */
48   RW_T1T_WRITE_E_CPLT_EVT,           /* Write byte after erase completed      */
49   RW_T1T_WRITE_NE_CPLT_EVT,          /* Write byte with no erase completed    */
50   RW_T1T_RSEG_CPLT_EVT,              /* Read segment completed                */
51   RW_T1T_READ8_CPLT_EVT,             /* Read block completed                  */
52   RW_T1T_WRITE_E8_CPLT_EVT,          /* Write block after erase completed     */
53   RW_T1T_WRITE_NE8_CPLT_EVT,         /* Write block with no erase completed   */
54   RW_T1T_TLV_DETECT_EVT,             /* Lock/Mem/Prop tlv detection complete  */
55   RW_T1T_NDEF_DETECT_EVT,            /* NDEF detection complete               */
56   RW_T1T_NDEF_READ_EVT,              /* NDEF read completed                   */
57   RW_T1T_NDEF_WRITE_EVT,             /* NDEF write complete                   */
58   RW_T1T_SET_TAG_RO_EVT,             /* Tag is set as read only               */
59   RW_T1T_RAW_FRAME_EVT,              /* Response of raw frame sent            */
60   RW_T1T_PRESENCE_CHECK_EVT,         /* Response to RW_T1tPresenceCheck       */
61   RW_T1T_FORMAT_CPLT_EVT,            /* Tag Formated                          */
62   RW_T1T_INTF_ERROR_EVT,             /* RF Interface error event              */
63   RW_T1T_MAX_EVT,
64 
65   /* Type 2 tag events */
66   RW_T2T_READ_CPLT_EVT = RW_T2T_FIRST_EVT, /* Read completed */
67   RW_T2T_WRITE_CPLT_EVT,     /* Write completed                       */
68   RW_T2T_SELECT_CPLT_EVT,    /* Sector select completed               */
69   RW_T2T_NDEF_DETECT_EVT,    /* NDEF detection complete               */
70   RW_T2T_TLV_DETECT_EVT,     /* Lock/Mem/Prop tlv detection complete  */
71   RW_T2T_NDEF_READ_EVT,      /* NDEF read completed                   */
72   RW_T2T_NDEF_WRITE_EVT,     /* NDEF write complete                   */
73   RW_T2T_SET_TAG_RO_EVT,     /* Tag is set as read only               */
74   RW_T2T_RAW_FRAME_EVT,      /* Response of raw frame sent            */
75   RW_T2T_PRESENCE_CHECK_EVT, /* Response to RW_T2tPresenceCheck       */
76   RW_T2T_FORMAT_CPLT_EVT,    /* Tag Formated                          */
77   RW_T2T_INTF_ERROR_EVT,     /* RF Interface error event              */
78   RW_T2T_MAX_EVT,
79 
80   /* Type 3 tag events for tRW_CBACK */
81   RW_T3T_CHECK_CPLT_EVT = RW_T3T_FIRST_EVT, /* Read completed */
82   RW_T3T_UPDATE_CPLT_EVT,        /* Write completed                          */
83   RW_T3T_CHECK_EVT,              /* Segment of data received from type 3 tag */
84   RW_T3T_RAW_FRAME_EVT,          /* SendRawFrame response                    */
85   RW_T3T_NDEF_DETECT_EVT,        /* NDEF detection complete                  */
86   RW_T3T_PRESENCE_CHECK_EVT,     /* Response to RW_T3tPresenceCheck          */
87   RW_T3T_POLL_EVT,               /* Response to RW_T3tPoll                   */
88   RW_T3T_GET_SYSTEM_CODES_EVT,   /* Response to RW_T3tGetSystemCodes         */
89   RW_T3T_FORMAT_CPLT_EVT,        /* Tag Formated (Felica-Lite only)          */
90   RW_T3T_SET_READ_ONLY_CPLT_EVT, /* Tag is set as Read only                  */
91   RW_T3T_INTF_ERROR_EVT,         /* RF Interface error event                 */
92   RW_T3T_MAX_EVT,
93 
94   /* Type 4 tag events for tRW_CBACK */
95   RW_T4T_NDEF_DETECT_EVT =
96       RW_T4T_FIRST_EVT,        /* Result of NDEF detection procedure       */
97                                /* Mandatory NDEF file is selected          */
98   RW_T4T_NDEF_READ_EVT,        /* Segment of data received from type 4 tag */
99   RW_T4T_NDEF_READ_CPLT_EVT,   /* Read operation completed                 */
100   RW_T4T_NDEF_READ_FAIL_EVT,   /* Read operation failed                    */
101   RW_T4T_NDEF_UPDATE_CPLT_EVT, /* Update operation completed               */
102   RW_T4T_NDEF_UPDATE_FAIL_EVT, /* Update operation failed                  */
103   RW_T4T_SET_TO_RO_EVT,        /* Tag is set as read only                  */
104   RW_T4T_PRESENCE_CHECK_EVT,   /* Response to RW_T4tPresenceCheck          */
105   RW_T4T_RAW_FRAME_EVT,        /* Response of raw frame sent               */
106   RW_T4T_INTF_ERROR_EVT,       /* RF Interface error event                 */
107   RW_T4T_NDEF_FORMAT_CPLT_EVT, /* Format operation completed               */
108   RW_T4T_MAX_EVT,
109 
110   /* ISO 15693 tag events for tRW_CBACK */
111   RW_I93_NDEF_DETECT_EVT =
112       RW_I93_FIRST_EVT,        /* Result of NDEF detection procedure */
113   RW_I93_NDEF_READ_EVT,        /* Segment of data received from tag  */
114   RW_I93_NDEF_READ_CPLT_EVT,   /* Read operation completed           */
115   RW_I93_NDEF_READ_FAIL_EVT,   /* Read operation failed              */
116   RW_I93_NDEF_UPDATE_CPLT_EVT, /* Update operation completed         */
117   RW_I93_NDEF_UPDATE_FAIL_EVT, /* Update operation failed            */
118   RW_I93_FORMAT_CPLT_EVT,      /* Format procedure complete          */
119   RW_I93_SET_TAG_RO_EVT,       /* Set read-only procedure complete   */
120   RW_I93_INVENTORY_EVT,        /* Response of Inventory              */
121   RW_I93_DATA_EVT,             /* Response of Read, Get Multi Security */
122   RW_I93_SYS_INFO_EVT,         /* Response of System Information     */
123   RW_I93_CMD_CMPL_EVT,         /* Command complete                   */
124   RW_I93_PRESENCE_CHECK_EVT,   /* Response to RW_I93PresenceCheck    */
125   RW_I93_RAW_FRAME_EVT,        /* Response of raw frame sent         */
126   RW_I93_INTF_ERROR_EVT,       /* RF Interface error event           */
127   RW_I93_MAX_EVT,
128 
129   /* Mifare Classic tag events for tRW_CBACK */
130   RW_MFC_NDEF_DETECT_EVT =
131       RW_MFC_FIRST_EVT,      /* Result of NDEF detection procedure       */
132                              /* Mandatory NDEF file is selected          */
133   RW_MFC_NDEF_READ_EVT,      /* Segment of data received from mifare tag */
134   RW_MFC_NDEF_READ_CPLT_EVT, /* Read operation completed                 */
135   RW_MFC_NDEF_READ_FAIL_EVT, /* Read operation failed                    */
136 
137   RW_MFC_NDEF_WRITE_CPLT_EVT,  /* Write operation completed               */
138   RW_MFC_NDEF_WRITE_FAIL_EVT,  /* Write operation failed                  */
139   RW_MFC_NDEF_FORMAT_CPLT_EVT, /* Format operation completed              */
140 
141   RW_MFC_RAW_FRAME_EVT,  /* Response of raw frame sent               */
142   RW_MFC_INTF_ERROR_EVT, /* RF Interface error event                 */
143   RW_MFC_MAX_EVT,
144   RW_CI_PRESENCE_CHECK_EVT = RW_CI_FIRST_EVT,
145   RW_CI_INTF_ERROR_EVT,
146   RW_CI_RAW_FRAME_EVT,
147   RW_CI_CPLT_EVT,
148   RW_CI_MAX_EVT
149 };
150 
151 #define RW_RAW_FRAME_EVT 0xFF
152 
153 typedef uint8_t tRW_EVENT;
154 
155 /* Tag is read only              */
156 #define RW_NDEF_FL_READ_ONLY 0x01
157 /* Tag formated for NDEF         */
158 #define RW_NDEF_FL_FORMATED 0x02
159 /* NDEF supported by the tag     */
160 #define RW_NDEF_FL_SUPPORTED 0x04
161 /* Unable to find if tag is ndef capable/formated/read only */
162 #define RW_NDEF_FL_UNKNOWN 0x08
163 /* Tag supports format operation */
164 #define RW_NDEF_FL_FORMATABLE 0x10
165 /* Tag can be soft locked */
166 #define RW_NDEF_FL_SOFT_LOCKABLE 0x20
167 /* Tag can be hard locked */
168 #define RW_NDEF_FL_HARD_LOCKABLE 0x40
169 /* Tag is one time programmable */
170 #define RW_NDEF_FL_OTP 0x80
171 
172 typedef uint8_t tRW_NDEF_FLAG;
173 
174 /* options for RW_T4tPresenceCheck  */
175 #define RW_T4T_CHK_EMPTY_I_BLOCK 1
176 #define RW_T4T_CHK_ISO_DEP_NAK_PRES_CHK 5
177 
178 #define RW_I93_MODE_ADDRESSED 0
179 #define RW_I93_MODE_NON_ADDRESSED 1
180 
181 typedef struct {
182   tNFC_STATUS status;
183   uint16_t msg_len; /* Length of the NDEF message */
184 } tRW_T2T_DETECT;
185 
186 typedef struct {
187   tNFC_STATUS status;       /* Status of the POLL request */
188   uint8_t rc;               /* RC (request code) used in the POLL request */
189   uint8_t response_num;     /* Number of SENSF_RES responses */
190   uint8_t response_bufsize; /* Size of SENSF_RES responses */
191   uint8_t* response_buf;    /* Buffer of responses (length + SENSF_RES) see
192                                $8.1.2.2 of NCI specs */
193 } tRW_T3T_POLL;
194 
195 typedef struct {
196   tNFC_STATUS status;       /* Status of the Get System Codes request */
197   uint8_t num_system_codes; /* Number of system codes */
198   uint16_t* p_system_codes; /* Table of system codes */
199 } tRW_T3T_SYSTEM_CODES;
200 
201 typedef struct {
202   tNFC_STATUS status;     /* status of NDEF detection */
203   tNFC_PROTOCOL protocol; /* protocol used to detect NDEF */
204   uint32_t max_size;      /* max number of bytes available for NDEF data */
205   uint32_t cur_size;      /* current size of stored NDEF data (in bytes) */
206   tRW_NDEF_FLAG
207       flags; /* Flags to indicate NDEF capability,formated,formatable and read
208                 only */
209 } tRW_DETECT_NDEF_DATA;
210 
211 typedef struct {
212   tNFC_STATUS status;     /* status of NDEF detection */
213   tNFC_PROTOCOL protocol; /* protocol used to detect TLV */
214   uint8_t
215       num_bytes; /* number of reserved/lock bytes based on the type of tlv */
216 } tRW_DETECT_TLV_DATA;
217 
218 typedef struct {
219   tNFC_STATUS status;
220   NFC_HDR* p_data;
221 } tRW_READ_DATA;
222 
223 typedef struct {
224   tNFC_STATUS status;
225   uint8_t sw1;
226   uint8_t sw2;
227 } tRW_T4T_SW;
228 
229 typedef struct /* RW_I93_INVENTORY_EVT        */
230 {
231   tNFC_STATUS status;            /* status of Inventory command */
232   uint8_t dsfid;                 /* DSFID                       */
233   uint8_t uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB  */
234 } tRW_I93_INVENTORY;
235 
236 typedef struct /* RW_I93_DATA_EVT               */
237 {
238   tNFC_STATUS status; /* status of Read/Get security status command */
239   uint8_t command;    /* sent command                  */
240   NFC_HDR* p_data;    /* block data of security status */
241 } tRW_I93_DATA;
242 
243 typedef struct /* RW_I93_SYS_INFO_EVT             */
244 {
245   tNFC_STATUS status;            /* status of Get Sys Info command  */
246   uint8_t info_flags;            /* information flags               */
247   uint8_t uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB      */
248   uint8_t dsfid;                 /* DSFID if I93_INFO_FLAG_DSFID    */
249   uint8_t afi;                   /* AFI if I93_INFO_FLAG_AFI        */
250   uint16_t num_block;   /* number of blocks if I93_INFO_FLAG_MEM_SIZE   */
251   uint8_t block_size;   /* block size in byte if I93_INFO_FLAG_MEM_SIZE */
252   uint8_t IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF         */
253 } tRW_I93_SYS_INFO;
254 
255 typedef struct /* RW_I93_CMD_CMPL_EVT             */
256 {
257   tNFC_STATUS status; /* status of sent command          */
258   uint8_t command;    /* sent command                    */
259   uint8_t error_code; /* error code; I93_ERROR_CODE_XXX  */
260 } tRW_I93_CMD_CMPL;
261 
262 typedef struct {
263   tNFC_STATUS status;
264   NFC_HDR* p_data;
265 } tRW_RAW_FRAME;
266 
267 typedef struct {
268   uint8_t mbi;
269   uint8_t uid[8];
270 } t_RW_CI_INFO;
271 
272 typedef union {
273   tNFC_STATUS status;
274   tRW_T3T_POLL t3t_poll;           /* Response to t3t poll command          */
275   tRW_T3T_SYSTEM_CODES t3t_sc;     /* Received system codes from t3 tag     */
276   tRW_DETECT_TLV_DATA tlv;         /* The information of detected TLV data  */
277   tRW_DETECT_NDEF_DATA ndef;       /* The information of detected NDEF data */
278   tRW_READ_DATA data;              /* The received data from a tag          */
279   tRW_RAW_FRAME raw_frame;         /* Response of raw frame sent            */
280   tRW_T4T_SW t4t_sw;               /* Received status words from a tag      */
281   tRW_I93_INVENTORY i93_inventory; /* ISO 15693 Inventory response      */
282   tRW_I93_DATA i93_data;           /* ISO 15693 Data response           */
283   tRW_I93_SYS_INFO i93_sys_info;   /* ISO 15693 System Information      */
284   tRW_I93_CMD_CMPL i93_cmd_cmpl;   /* ISO 15693 Command complete        */
285   t_RW_CI_INFO ci_info;
286 } tRW_DATA;
287 
288 typedef void(tRW_CBACK)(tRW_EVENT event, tRW_DATA* p_data);
289 
290 /*******************************************************************************
291 **
292 ** Function         RW_T1tRid
293 **
294 ** Description      This function send a RID command for Reader/Writer mode.
295 **
296 ** Returns          tNFC_STATUS
297 **
298 *******************************************************************************/
299 extern tNFC_STATUS RW_T1tRid(void);
300 
301 /*******************************************************************************
302 **
303 ** Function         RW_T1tReadAll
304 **
305 ** Description      This function send a RALL command for Reader/Writer mode.
306 **
307 ** Returns          tNFC_STATUS
308 **
309 *******************************************************************************/
310 extern tNFC_STATUS RW_T1tReadAll(void);
311 
312 /*******************************************************************************
313 **
314 ** Function         RW_T1tRead
315 **
316 ** Description      This function send a READ command for Reader/Writer mode.
317 **
318 ** Returns          tNFC_STATUS
319 **
320 *******************************************************************************/
321 extern tNFC_STATUS RW_T1tRead(uint8_t block, uint8_t byte);
322 
323 /*******************************************************************************
324 **
325 ** Function         RW_T1tWriteErase
326 **
327 ** Description      This function send a WRITE-E command for Reader/Writer mode.
328 **
329 ** Returns          tNFC_STATUS
330 **
331 *******************************************************************************/
332 extern tNFC_STATUS RW_T1tWriteErase(uint8_t block, uint8_t byte,
333                                     uint8_t new_byte);
334 
335 /*******************************************************************************
336 **
337 ** Function         RW_T1tWriteNoErase
338 **
339 ** Description      This function send a WRITE-NE command for Reader/Writer
340 **                  mode.
341 **
342 ** Returns          tNFC_STATUS
343 **
344 *******************************************************************************/
345 extern tNFC_STATUS RW_T1tWriteNoErase(uint8_t block, uint8_t byte,
346                                       uint8_t new_byte);
347 
348 /*******************************************************************************
349 **
350 ** Function         RW_T1tReadSeg
351 **
352 ** Description      This function send a RSEG command for Reader/Writer mode.
353 **
354 ** Returns          tNFC_STATUS
355 **
356 *******************************************************************************/
357 extern tNFC_STATUS RW_T1tReadSeg(uint8_t segment);
358 
359 /*******************************************************************************
360 **
361 ** Function         RW_T1tRead8
362 **
363 ** Description      This function send a READ8 command for Reader/Writer mode.
364 **
365 ** Returns          tNFC_STATUS
366 **
367 *******************************************************************************/
368 extern tNFC_STATUS RW_T1tRead8(uint8_t block);
369 
370 /*******************************************************************************
371 **
372 ** Function         RW_T1tWriteErase8
373 **
374 ** Description      This function send a WRITE-E8 command for Reader/Writer
375 **                  mode.
376 **
377 ** Returns          tNFC_STATUS
378 **
379 *******************************************************************************/
380 extern tNFC_STATUS RW_T1tWriteErase8(uint8_t block, uint8_t* p_new_dat);
381 
382 /*******************************************************************************
383 **
384 ** Function         RW_T1tWriteNoErase8
385 **
386 ** Description      This function send a WRITE-NE8 command for Reader/Writer
387 **                  mode.
388 **
389 ** Returns          tNFC_STATUS
390 **
391 *******************************************************************************/
392 extern tNFC_STATUS RW_T1tWriteNoErase8(uint8_t block, uint8_t* p_new_dat);
393 
394 /*******************************************************************************
395 **
396 ** Function         RW_T1tLocateTlv
397 **
398 ** Description      This function is called to find the start of the given TLV
399 **
400 ** Parameters:      void
401 **
402 ** Returns          NCI_STATUS_OK, if detection was started. Otherwise, error
403 **                  status.
404 **
405 *******************************************************************************/
406 extern tNFC_STATUS RW_T1tLocateTlv(uint8_t tlv_type);
407 
408 /*******************************************************************************
409 **
410 ** Function         RW_T1tDetectNDef
411 **
412 ** Description      This function can be called to detect if there is an NDEF
413 **                  message on the tag.
414 **
415 ** Parameters:      void
416 **
417 ** Returns          NCI_STATUS_OK, if detection was started. Otherwise, error
418 **                  status.
419 **
420 *******************************************************************************/
421 extern tNFC_STATUS RW_T1tDetectNDef(void);
422 
423 /*******************************************************************************
424 **
425 ** Function         RW_T1tReadNDef
426 **
427 ** Description      This function can be called to read the NDEF message on the
428 **                  tag.
429 **
430 ** Parameters:      p_buffer:   The buffer into which to read the NDEF message
431 **                  buf_len:    The length of the buffer
432 **
433 ** Returns          NCI_STATUS_OK, if read was started. Otherwise, error status.
434 **
435 *******************************************************************************/
436 extern tNFC_STATUS RW_T1tReadNDef(uint8_t* p_buffer, uint16_t buf_len);
437 
438 /*******************************************************************************
439 **
440 ** Function         RW_T1tWriteNDef
441 **
442 ** Description      This function can be called to write an NDEF message to the
443 **                  tag.
444 **
445 ** Parameters:      msg_len:    The length of the buffer
446 **                  p_msg:      The NDEF message to write
447 **
448 ** Returns          NCI_STATUS_OK, if write was started. Otherwise, error
449 **                  status.
450 **
451 *******************************************************************************/
452 extern tNFC_STATUS RW_T1tWriteNDef(uint16_t msg_len, uint8_t* p_msg);
453 
454 /*******************************************************************************
455 **
456 ** Function         RW_T1tSetTagReadOnly
457 **
458 ** Description      This function can be called to set the tag in to read only
459 **                  state
460 **
461 ** Parameters:      b_hard_lock: To hard lock or just soft lock the tag
462 **
463 ** Returns          NCI_STATUS_OK, if set readonly operation started.
464 **                                 Otherwise, error status.
465 **
466 *******************************************************************************/
467 extern tNFC_STATUS RW_T1tSetTagReadOnly(bool b_hard_lock);
468 
469 /*****************************************************************************
470 **
471 ** Function         RW_T1tPresenceCheck
472 **
473 ** Description
474 **      Check if the tag is still in the field.
475 **
476 **      The RW_T1T_PRESENCE_CHECK_EVT w/ status is used to indicate presence
477 **      or non-presence.
478 **
479 ** Returns
480 **      NFC_STATUS_OK, if raw data frame sent
481 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
482 **      NFC_STATUS_FAILED: other error
483 **
484 *****************************************************************************/
485 extern tNFC_STATUS RW_T1tPresenceCheck(void);
486 
487 /*****************************************************************************
488 **
489 ** Function         RW_T1tFormatNDef
490 **
491 ** Description
492 **      Format Tag content
493 **
494 ** Returns
495 **      NFC_STATUS_OK, Command sent to format Tag
496 **      NFC_STATUS_REJECTED: Invalid HR0 and cannot format the tag
497 **      NFC_STATUS_FAILED: other error
498 **
499 *****************************************************************************/
500 tNFC_STATUS RW_T1tFormatNDef(void);
501 
502 /*******************************************************************************
503 **
504 ** Function         RW_T2tLocateTlv
505 **
506 ** Description      This function is called to find the start of the given TLV
507 **
508 ** Returns          Pointer to the TLV, if successful. Otherwise, NULL.
509 **
510 *******************************************************************************/
511 extern tNFC_STATUS RW_T2tLocateTlv(uint8_t tlv_type);
512 
513 /*******************************************************************************
514 **
515 ** Function         RW_T2tRead
516 **
517 ** Description      This function issues the Type 2 Tag READ command. When the
518 **                  operation is complete the callback function will be called
519 **                  with a RW_T2T_READ_EVT.
520 **
521 ** Returns          tNFC_STATUS
522 **
523 *******************************************************************************/
524 extern tNFC_STATUS RW_T2tRead(uint16_t block);
525 
526 /*******************************************************************************
527 **
528 ** Function         RW_T2tWrite
529 **
530 ** Description      This function issues the Type 2 Tag WRITE command. When the
531 **                  operation is complete the callback function will be called
532 **                  with a RW_T2T_WRITE_EVT.
533 **
534 **                  p_write_data points to the array of 4 bytes to be written
535 **
536 ** Returns          tNFC_STATUS
537 **
538 *******************************************************************************/
539 extern tNFC_STATUS RW_T2tWrite(uint16_t block, uint8_t* p_write_data);
540 
541 /*******************************************************************************
542 **
543 ** Function         RW_T2tSectorSelect
544 **
545 ** Description      This function issues the Type 2 Tag SECTOR-SELECT command
546 **                  packet 1. If a NACK is received as the response, the
547 **                  callback function will be called with a
548 **                  RW_T2T_SECTOR_SELECT_EVT. If an ACK is received as the
549 **                  response, the command packet 2 with the given sector number
550 **                  is sent to the peer device. When the response for packet 2
551 **                  is received, the callback function will be called with a
552 **                  RW_T2T_SECTOR_SELECT_EVT.
553 **
554 **                  A sector is 256 contiguous blocks (1024 bytes).
555 **
556 ** Returns          tNFC_STATUS
557 **
558 *******************************************************************************/
559 extern tNFC_STATUS RW_T2tSectorSelect(uint8_t sector);
560 
561 /*******************************************************************************
562 **
563 ** Function         RW_T2tDetectNDef
564 **
565 ** Description      This function will find NDEF message if any in the Tag
566 **
567 ** Returns          tNFC_STATUS
568 **
569 *******************************************************************************/
570 extern tNFC_STATUS RW_T2tDetectNDef(bool skip_dyn_locks);
571 
572 /*******************************************************************************
573 **
574 ** Function         RW_T2tReadNDef
575 **
576 ** Description      This function can be called to read the NDEF message on the
577 **                  tag.
578 **
579 ** Parameters:      p_buffer:   The buffer into which to read the NDEF message
580 **                  buf_len:    The length of the buffer
581 **
582 ** Returns          NCI_STATUS_OK, if read was started. Otherwise, error status.
583 **
584 *******************************************************************************/
585 extern tNFC_STATUS RW_T2tReadNDef(uint8_t* p_buffer, uint16_t buf_len);
586 
587 /*******************************************************************************
588 **
589 ** Function         RW_T2tWriteNDef
590 **
591 ** Description      This function can be called to write an NDEF message to the
592 **                  tag.
593 **
594 ** Parameters:      msg_len:    The length of the buffer
595 **                  p_msg:      The NDEF message to write
596 **
597 ** Returns          NCI_STATUS_OK, if write was started. Otherwise, error
598 **                  status.
599 **
600 *******************************************************************************/
601 extern tNFC_STATUS RW_T2tWriteNDef(uint16_t msg_len, uint8_t* p_msg);
602 
603 /*******************************************************************************
604 **
605 ** Function         RW_T2tSetTagReadOnly
606 **
607 ** Description      This function can be called to set the tag in to read only
608 **                  state
609 **
610 ** Parameters:      b_hard_lock:   To indicate hard lock the tag or not
611 **
612 ** Returns          NCI_STATUS_OK, if set readonly operation started.
613 **                                 Otherwise, error status.
614 **
615 *******************************************************************************/
616 extern tNFC_STATUS RW_T2tSetTagReadOnly(bool b_hard_lock);
617 
618 /*****************************************************************************
619 **
620 ** Function         RW_T2tPresenceCheck
621 **
622 ** Description
623 **      Check if the tag is still in the field.
624 **
625 **      The RW_T2T_PRESENCE_CHECK_EVT w/ status is used to indicate presence
626 **      or non-presence.
627 **
628 ** Returns
629 **      NFC_STATUS_OK, if raw data frame sent
630 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
631 **      NFC_STATUS_FAILED: other error
632 **
633 *****************************************************************************/
634 extern tNFC_STATUS RW_T2tPresenceCheck(void);
635 
636 /*****************************************************************************
637 **
638 ** Function         RW_T2tFormatNDef
639 **
640 ** Description
641 **      Format Tag content
642 **
643 ** Returns
644 **      NFC_STATUS_OK, Command sent to format Tag
645 **      NFC_STATUS_FAILED: otherwise
646 **
647 *****************************************************************************/
648 tNFC_STATUS RW_T2tFormatNDef(void);
649 
650 /*****************************************************************************
651 **
652 ** Function         RW_T3tDetectNDef
653 **
654 ** Description
655 **      This function is used to perform NDEF detection on a Type 3 tag, and
656 **      retrieve the tag's NDEF attribute information (block 0).
657 **
658 **      Before using this API, the application must call RW_SelectTagType to
659 **      indicate that a Type 3 tag has been activated, and to provide the
660 **      tag's Manufacture ID (IDm) .
661 **
662 ** Returns
663 **      NFC_STATUS_OK: ndef detection procedure started
664 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
665 **      NFC_STATUS_FAILED: other error
666 **
667 *****************************************************************************/
668 extern tNFC_STATUS RW_T3tDetectNDef(void);
669 
670 /*****************************************************************************
671 **
672 ** Function         RW_T3tFormatNDef
673 **
674 ** Description
675 **      Format a type-3 tag for NDEF.
676 **
677 **      Only Felica-Lite tags are supported by this API. The
678 **      RW_T3T_FORMAT_CPLT_EVT is used to notify the status of the operation.
679 **
680 ** Returns
681 **      NFC_STATUS_OK: ndef detection procedure started
682 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
683 **      NFC_STATUS_FAILED: other error
684 **
685 *****************************************************************************/
686 extern tNFC_STATUS RW_T3tFormatNDef(void);
687 
688 /*****************************************************************************
689 **
690 ** Function         RW_T3tSetReadOnly
691 **
692 ** Description
693 **      Set a type-3 tag to Read Only
694 **
695 **      Only Felica-Lite tags are supported by this API.
696 **      RW_T3tDetectNDef() must be called before using this
697 **      The RW_T3T_SET_READ_ONLY_CPLT_EVT event will be returned.
698 **
699 ** Returns
700 **      NFC_STATUS_OK if success
701 **      NFC_STATUS_FAILED if T3T is busy or other error
702 **
703 *****************************************************************************/
704 extern tNFC_STATUS RW_T3tSetReadOnly(bool b_hard_lock);
705 
706 /*****************************************************************************
707 **
708 ** Function         RW_T3tCheckNDef
709 **
710 ** Description
711 **      Retrieve NDEF contents from a Type3 tag.
712 **
713 **      The RW_T3T_CHECK_EVT event is used to notify the application for each
714 **      segment of NDEF data received. The RW_T3T_CHECK_CPLT_EVT event is used
715 **      to notify the application all segments have been received.
716 **
717 **      Before using this API, the RW_T3tDetectNDef function must be called to
718 **      verify that the tag contains NDEF data, and to retrieve the NDEF
719 **      attributes.
720 **
721 **      Internally, this command will be separated into multiple Tag 3 Check
722 **      commands (if necessary) - depending on the tag's Nbr (max number of
723 **      blocks per read) attribute.
724 **
725 ** Returns
726 **      NFC_STATUS_OK: check command started
727 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
728 **      NFC_STATUS_FAILED: other error
729 **
730 *****************************************************************************/
731 extern tNFC_STATUS RW_T3tCheckNDef(void);
732 
733 /*****************************************************************************
734 **
735 ** Function         RW_T3tUpdateNDef
736 **
737 ** Description
738 **      Write NDEF contents to a Type3 tag.
739 **
740 **      The RW_T3T_UPDATE_CPLT_EVT callback event will be used to notify the
741 **      application of the response.
742 **
743 **      Before using this API, the RW_T3tDetectNDef function must be called to
744 **      verify that the tag contains NDEF data, and to retrieve the NDEF
745 **      attributes.
746 **
747 **      Internally, this command will be separated into multiple Tag 3 Update
748 **      commands (if necessary) - depending on the tag's Nbw (max number of
749 **      blocks per write) attribute.
750 **
751 ** Returns
752 **      NFC_STATUS_OK: check command started
753 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
754 **      NFC_STATUS_REFUSED: tag is read-only
755 **      NFC_STATUS_BUFFER_FULL: len exceeds tag's maximum size
756 **      NFC_STATUS_FAILED: other error
757 **
758 *****************************************************************************/
759 extern tNFC_STATUS RW_T3tUpdateNDef(uint32_t len, uint8_t* p_data);
760 
761 /*****************************************************************************
762 **
763 ** Function         RW_T3tCheck
764 **
765 ** Description
766 **      Read (non-NDEF) contents from a Type3 tag.
767 **
768 **      The RW_READ_EVT event is used to notify the application for each
769 **      segment of NDEF data received. The RW_READ_CPLT_EVT event is used to
770 **      notify the application all segments have been received.
771 **
772 **      Before using this API, the application must call RW_SelectTagType to
773 **      indicate that a Type 3 tag has been activated, and to provide the
774 **      tag's Manufacture ID (IDm) .
775 **
776 ** Returns
777 **      NFC_STATUS_OK: check command started
778 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
779 **      NFC_STATUS_FAILED: other error
780 **
781 *****************************************************************************/
782 extern tNFC_STATUS RW_T3tCheck(uint8_t num_blocks, tT3T_BLOCK_DESC* t3t_blocks);
783 
784 /*****************************************************************************
785 **
786 ** Function         RW_T3tUpdate
787 **
788 ** Description
789 **      Write (non-NDEF) contents to a Type3 tag.
790 **
791 **      The RW_WRITE_CPLT_EVT event is used to notify the application all
792 **      segments have been received.
793 **
794 **      Before using this API, the application must call RW_SelectTagType to
795 **      indicate that a Type 3 tag has been activated, and to provide the tag's
796 **      Manufacture ID (IDm) .
797 **
798 ** Returns
799 **      NFC_STATUS_OK: check command started
800 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
801 **      NFC_STATUS_FAILED: other error
802 **
803 *****************************************************************************/
804 extern tNFC_STATUS RW_T3tUpdate(uint8_t num_blocks, tT3T_BLOCK_DESC* t3t_blocks,
805                                 uint8_t* p_data);
806 
807 /*****************************************************************************
808 **
809 ** Function         RW_T3tSendRawFrame
810 **
811 ** Description
812 **      This function is called to send a raw data frame to the peer device.
813 **      When type 3 tag receives response from peer, the callback function
814 **      will be called with a RW_T3T_RAW_FRAME_EVT [Table 6].
815 **
816 **      Before using this API, the application must call RW_SelectTagType to
817 **      indicate that a Type 3 tag has been activated.
818 **
819 **      The raw frame should be a properly formatted Type 3 tag message.
820 **
821 ** Returns
822 **      NFC_STATUS_OK, if raw data frame sent
823 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
824 **      NFC_STATUS_FAILED: other error
825 **
826 *****************************************************************************/
827 extern tNFC_STATUS RW_T3tSendRawFrame(uint16_t len, uint8_t* p_data);
828 
829 /*****************************************************************************
830 **
831 ** Function         RW_T3tPoll
832 **
833 ** Description
834 **      Send POLL command
835 **
836 ** Returns
837 **      NFC_STATUS_OK, if raw data frame sent
838 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
839 **      NFC_STATUS_FAILED: other error
840 **
841 *****************************************************************************/
842 extern tNFC_STATUS RW_T3tPoll(uint16_t system_code, tT3T_POLL_RC rc,
843                               uint8_t tsn);
844 
845 /*****************************************************************************
846 **
847 ** Function         RW_T3tPresenceCheck
848 **
849 ** Description
850 **      Check if the tag is still in the field.
851 **
852 **      The RW_T3T_PRESENCE_CHECK_EVT w/ status is used to indicate presence
853 **      or non-presence.
854 **
855 ** Returns
856 **      NFC_STATUS_OK, if raw data frame sent
857 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
858 **      NFC_STATUS_FAILED: other error
859 **
860 *****************************************************************************/
861 extern tNFC_STATUS RW_T3tPresenceCheck(void);
862 
863 /*****************************************************************************
864 **
865 ** Function         RW_T3tGetSystemCodes
866 **
867 ** Description
868 **      Get systems codes supported by the activated tag:
869 **              Poll for wildcard (FFFF):
870 **                  - If felica-lite code then poll for ndef (12fc)
871 **                  - Otherwise send RequestSystmCode command to get
872 **                    system codes.
873 **
874 **      Before using this API, the application must call RW_SelectTagType to
875 **      indicate that a Type 3 tag has been activated.
876 **
877 ** Returns
878 **      NFC_STATUS_OK, if raw data frame sent
879 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
880 **      NFC_STATUS_FAILED: other error
881 **
882 *****************************************************************************/
883 extern tNFC_STATUS RW_T3tGetSystemCodes(void);
884 
885 /*****************************************************************************
886 **
887 ** Function         RW_T4tFormatNDef
888 **
889 ** Description
890 **      Format a type-4 tag for NDEF.
891 **
892 **      Only Desifire tags are supported by this API. The
893 **      RW_T4T_FORMAT_CPLT_EVT is used to notify the status of the operation.
894 **
895 ** Returns
896 **      NFC_STATUS_OK: if success
897 **      NFC_STATUS_FAILED: other error
898 *****************************************************************************/
899 extern tNFC_STATUS RW_T4tFormatNDef(void);
900 
901 /*******************************************************************************
902 **
903 ** Function         RW_T4tDetectNDef
904 **
905 ** Description      This function performs NDEF detection procedure
906 **
907 **                  RW_T4T_NDEF_DETECT_EVT will be returned
908 **
909 ** Returns          NFC_STATUS_OK if success
910 **                  NFC_STATUS_FAILED if T4T is busy or other error
911 **
912 *******************************************************************************/
913 extern tNFC_STATUS RW_T4tDetectNDef(void);
914 
915 /*******************************************************************************
916 **
917 ** Function         RW_T4tReadNDef
918 **
919 ** Description      This function performs NDEF read procedure
920 **                  Note: RW_T4tDetectNDef() must be called before using this
921 **
922 **                  The following event will be returned
923 **                      RW_T4T_NDEF_READ_EVT for each segmented NDEF message
924 **                      RW_T4T_NDEF_READ_CPLT_EVT for the last segment or
925 **                      complete NDEF
926 **                      RW_T4T_NDEF_READ_FAIL_EVT for failure
927 **
928 ** Returns          NFC_STATUS_OK if success
929 **                  NFC_STATUS_FAILED if T4T is busy or other error
930 **
931 *******************************************************************************/
932 extern tNFC_STATUS RW_T4tReadNDef(void);
933 
934 /*******************************************************************************
935 **
936 ** Function         RW_T4tUpdateNDef
937 **
938 ** Description      This function performs NDEF update procedure
939 **                  Note: RW_T4tDetectNDef() must be called before using this
940 **                        Updating data must not be removed until returning
941 **                        event
942 **
943 **                  The following event will be returned
944 **                      RW_T4T_NDEF_UPDATE_CPLT_EVT for complete
945 **                      RW_T4T_NDEF_UPDATE_FAIL_EVT for failure
946 **
947 ** Returns          NFC_STATUS_OK if success
948 **                  NFC_STATUS_FAILED if T4T is busy or other error
949 **
950 *******************************************************************************/
951 extern tNFC_STATUS RW_T4tUpdateNDef(uint32_t length, uint8_t* p_data);
952 
953 /*****************************************************************************
954 **
955 ** Function         RW_T4tPresenceCheck
956 **
957 ** Description
958 **      Check if the tag is still in the field.
959 **
960 **      The RW_T4T_PRESENCE_CHECK_EVT w/ status is used to indicate presence
961 **      or non-presence.
962 **
963 **      option is RW_T4T_CHK_EMPTY_I_BLOCK, use empty I block for presence
964 **      check.
965 **
966 ** Returns
967 **      NFC_STATUS_OK, if raw data frame sent
968 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
969 **      NFC_STATUS_FAILED: other error
970 **
971 *****************************************************************************/
972 extern tNFC_STATUS RW_T4tPresenceCheck(uint8_t option);
973 
974 /*****************************************************************************
975 **
976 ** Function         RW_T4tSetNDefReadOnly
977 **
978 ** Description      This function performs NDEF read-only procedure
979 **                  Note: RW_T4tDetectNDef() must be called before using this
980 **
981 **                  The RW_T4T_SET_TO_RO_EVT event will be returned.
982 **
983 ** Returns          NFC_STATUS_OK if success
984 **                  NFC_STATUS_FAILED if T4T is busy or other error
985 **
986 *****************************************************************************/
987 extern tNFC_STATUS RW_T4tSetNDefReadOnly(void);
988 
989 /*******************************************************************************
990 **
991 ** Function         RW_I93Inventory
992 **
993 ** Description      This function send Inventory command with/without AFI
994 **                  If UID is provided then set UID[0]:MSB, ... UID[7]:LSB
995 **
996 **                  RW_I93_RESPONSE_EVT will be returned
997 **
998 ** Returns          NFC_STATUS_OK if success
999 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1000 **                  NFC_STATUS_FAILED if T4T is busy or other error
1001 **
1002 *******************************************************************************/
1003 extern tNFC_STATUS RW_I93Inventory(bool including_afi, uint8_t afi,
1004                                    uint8_t* p_uid);
1005 
1006 /*******************************************************************************
1007 **
1008 ** Function         RW_I93StayQuiet
1009 **
1010 ** Description      This function send Inventory command
1011 **
1012 **                  RW_I93_CMD_CMPL_EVT will be returned
1013 **
1014 ** Returns          NFC_STATUS_OK if success
1015 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1016 **                  NFC_STATUS_BUSY if busy
1017 **                  NFC_STATUS_FAILED if other error
1018 **
1019 *******************************************************************************/
1020 extern tNFC_STATUS RW_I93StayQuiet(uint8_t* p_uid);
1021 
1022 /*******************************************************************************
1023 **
1024 ** Function         RW_I93ReadSingleBlock
1025 **
1026 ** Description      This function send Read Single Block command
1027 **
1028 **                  RW_I93_RESPONSE_EVT will be returned
1029 **
1030 ** Returns          NFC_STATUS_OK if success
1031 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1032 **                  NFC_STATUS_BUSY if busy
1033 **                  NFC_STATUS_FAILED if other error
1034 **
1035 *******************************************************************************/
1036 extern tNFC_STATUS RW_I93ReadSingleBlock(uint16_t block_number);
1037 
1038 /*******************************************************************************
1039 **
1040 ** Function         RW_I93WriteSingleBlock
1041 **
1042 ** Description      This function send Write Single Block command
1043 **                  Application must get block size first by calling
1044 **                  RW_I93GetSysInfo().
1045 **
1046 **                  RW_I93_CMD_CMPL_EVT will be returned
1047 **
1048 ** Returns          NFC_STATUS_OK if success
1049 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1050 **                  NFC_STATUS_BUSY if busy
1051 **                  NFC_STATUS_FAILED if other error
1052 **
1053 *******************************************************************************/
1054 extern tNFC_STATUS RW_I93WriteSingleBlock(uint16_t block_number,
1055                                           uint8_t* p_data);
1056 
1057 /*******************************************************************************
1058 **
1059 ** Function         RW_I93LockBlock
1060 **
1061 ** Description      This function send Lock Block command
1062 **
1063 **                  RW_I93_CMD_CMPL_EVT will be returned
1064 **
1065 ** Returns          NFC_STATUS_OK if success
1066 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1067 **                  NFC_STATUS_BUSY if busy
1068 **                  NFC_STATUS_FAILED if other error
1069 **
1070 *******************************************************************************/
1071 extern tNFC_STATUS RW_I93LockBlock(uint8_t block_number);
1072 
1073 /*******************************************************************************
1074 **
1075 ** Function         RW_I93ReadMultipleBlocks
1076 **
1077 ** Description      This function send Read Multiple Blocks command
1078 **
1079 **                  RW_I93_RESPONSE_EVT will be returned
1080 **
1081 ** Returns          NFC_STATUS_OK if success
1082 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1083 **                  NFC_STATUS_BUSY if busy
1084 **                  NFC_STATUS_FAILED if other error
1085 **
1086 *******************************************************************************/
1087 extern tNFC_STATUS RW_I93ReadMultipleBlocks(uint16_t first_block_number,
1088                                             uint16_t number_blocks);
1089 
1090 /*******************************************************************************
1091 **
1092 ** Function         RW_I93WriteMultipleBlocks
1093 **
1094 ** Description      This function send Write Multiple Blocks command
1095 **
1096 **                  RW_I93_CMD_CMPL_EVT will be returned
1097 **
1098 ** Returns          NFC_STATUS_OK if success
1099 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1100 **                  NFC_STATUS_BUSY if busy
1101 **                  NFC_STATUS_FAILED if other error
1102 **
1103 *******************************************************************************/
1104 extern tNFC_STATUS RW_I93WriteMultipleBlocks(uint16_t first_block_number,
1105                                              uint16_t number_blocks,
1106                                              uint8_t* p_data);
1107 
1108 /*******************************************************************************
1109 **
1110 ** Function         RW_I93Select
1111 **
1112 ** Description      This function send Select command
1113 **
1114 **                  UID[0]: 0xE0, MSB
1115 **                  UID[1]: IC Mfg Code
1116 **                  ...
1117 **                  UID[7]: LSB
1118 **
1119 **                  RW_I93_CMD_CMPL_EVT will be returned
1120 **
1121 ** Returns          NFC_STATUS_OK if success
1122 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1123 **                  NFC_STATUS_BUSY if busy
1124 **                  NFC_STATUS_FAILED if other error
1125 **
1126 *******************************************************************************/
1127 extern tNFC_STATUS RW_I93Select(uint8_t* p_uid);
1128 
1129 /*******************************************************************************
1130 **
1131 ** Function         RW_I93ResetToReady
1132 **
1133 ** Description      This function send Reset To Ready command
1134 **
1135 **                  RW_I93_CMD_CMPL_EVT will be returned
1136 **
1137 ** Returns          NFC_STATUS_OK if success
1138 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1139 **                  NFC_STATUS_BUSY if busy
1140 **                  NFC_STATUS_FAILED if other error
1141 **
1142 *******************************************************************************/
1143 extern tNFC_STATUS RW_I93ResetToReady(void);
1144 
1145 /*******************************************************************************
1146 **
1147 ** Function         RW_I93WriteAFI
1148 **
1149 ** Description      This function send Write AFI command
1150 **
1151 **                  RW_I93_CMD_CMPL_EVT will be returned
1152 **
1153 ** Returns          NFC_STATUS_OK if success
1154 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1155 **                  NFC_STATUS_BUSY if busy
1156 **                  NFC_STATUS_FAILED if other error
1157 **
1158 *******************************************************************************/
1159 extern tNFC_STATUS RW_I93WriteAFI(uint8_t afi);
1160 
1161 /*******************************************************************************
1162 **
1163 ** Function         RW_I93LockAFI
1164 **
1165 ** Description      This function send Lock AFI command
1166 **
1167 **                  RW_I93_CMD_CMPL_EVT will be returned
1168 **
1169 ** Returns          NFC_STATUS_OK if success
1170 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1171 **                  NFC_STATUS_BUSY if busy
1172 **                  NFC_STATUS_FAILED if other error
1173 **
1174 *******************************************************************************/
1175 extern tNFC_STATUS RW_I93LockAFI(void);
1176 
1177 /*******************************************************************************
1178 **
1179 ** Function         RW_I93WriteDSFID
1180 **
1181 ** Description      This function send Write DSFID command
1182 **
1183 **                  RW_I93_CMD_CMPL_EVT will be returned
1184 **
1185 ** Returns          NFC_STATUS_OK if success
1186 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1187 **                  NFC_STATUS_BUSY if busy
1188 **                  NFC_STATUS_FAILED if other error
1189 **
1190 *******************************************************************************/
1191 extern tNFC_STATUS RW_I93WriteDSFID(uint8_t dsfid);
1192 
1193 /*******************************************************************************
1194 **
1195 ** Function         RW_I93LockDSFID
1196 **
1197 ** Description      This function send Lock DSFID command
1198 **
1199 **                  RW_I93_CMD_CMPL_EVT will be returned
1200 **
1201 ** Returns          NFC_STATUS_OK if success
1202 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1203 **                  NFC_STATUS_BUSY if busy
1204 **                  NFC_STATUS_FAILED if other error
1205 **
1206 *******************************************************************************/
1207 extern tNFC_STATUS RW_I93LockDSFID(void);
1208 
1209 /*******************************************************************************
1210 **
1211 ** Function         RW_I93GetSysInfo
1212 **
1213 ** Description      This function send Get System Information command
1214 **                  If UID is provided then set UID[0]:MSB, ... UID[7]:LSB
1215 **
1216 **                  RW_I93_RESPONSE_EVT will be returned
1217 **
1218 ** Returns          NFC_STATUS_OK if success
1219 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1220 **                  NFC_STATUS_BUSY if busy
1221 **                  NFC_STATUS_FAILED if other error
1222 **
1223 *******************************************************************************/
1224 extern tNFC_STATUS RW_I93GetSysInfo(uint8_t* p_uid);
1225 
1226 /*******************************************************************************
1227 **
1228 ** Function         RW_I93GetMultiBlockSecurityStatus
1229 **
1230 ** Description      This function send Get Multiple Block Security Status
1231 **                  command
1232 **
1233 **                  RW_I93_RESPONSE_EVT will be returned
1234 **
1235 ** Returns          NFC_STATUS_OK if success
1236 **                  NFC_STATUS_NO_BUFFERS if out of buffer
1237 **                  NFC_STATUS_BUSY if busy
1238 **                  NFC_STATUS_FAILED if other error
1239 **
1240 *******************************************************************************/
1241 extern tNFC_STATUS RW_I93GetMultiBlockSecurityStatus(
1242     uint16_t first_block_number, uint16_t number_blocks);
1243 
1244 /*******************************************************************************
1245 **
1246 ** Function         RW_I93DetectNDef
1247 **
1248 ** Description      This function performs NDEF detection procedure
1249 **
1250 **                  RW_I93_NDEF_DETECT_EVT will be returned
1251 **
1252 ** Returns          NFC_STATUS_OK if success
1253 **                  NFC_STATUS_FAILED if busy or other error
1254 **
1255 *******************************************************************************/
1256 extern tNFC_STATUS RW_I93DetectNDef(void);
1257 
1258 /*******************************************************************************
1259 **
1260 ** Function         RW_I93ReadNDef
1261 **
1262 ** Description      This function performs NDEF read procedure
1263 **                  Note: RW_I93DetectNDef() must be called before using this
1264 **
1265 **                  The following event will be returned
1266 **                      RW_I93_NDEF_READ_EVT for each segmented NDEF message
1267 **                      RW_I93_NDEF_READ_CPLT_EVT for the last segment or
1268 **                      complete NDEF
1269 **                      RW_I93_NDEF_READ_FAIL_EVT for failure
1270 **
1271 ** Returns          NFC_STATUS_OK if success
1272 **                  NFC_STATUS_FAILED if I93 is busy or other error
1273 **
1274 *******************************************************************************/
1275 extern tNFC_STATUS RW_I93ReadNDef(void);
1276 
1277 /*******************************************************************************
1278 **
1279 ** Function         RW_I93UpdateNDef
1280 **
1281 ** Description      This function performs NDEF update procedure
1282 **                  Note: RW_I93DetectNDef() must be called before using this
1283 **                        Updating data must not be removed until returning
1284 **                        event
1285 **
1286 **                  The following event will be returned
1287 **                      RW_I93_NDEF_UPDATE_CPLT_EVT for complete
1288 **                      RW_I93_NDEF_UPDATE_FAIL_EVT for failure
1289 **
1290 ** Returns          NFC_STATUS_OK if success
1291 **                  NFC_STATUS_FAILED if I93 is busy or other error
1292 **
1293 *******************************************************************************/
1294 extern tNFC_STATUS RW_I93UpdateNDef(uint32_t length, uint8_t* p_data);
1295 
1296 /*******************************************************************************
1297 **
1298 ** Function         RW_I93FormatNDef
1299 **
1300 ** Description      This function performs formatting procedure
1301 **
1302 **                  RW_I93_FORMAT_CPLT_EVT will be returned
1303 **
1304 ** Returns          NFC_STATUS_OK if success
1305 **                  NFC_STATUS_FAILED if busy or other error
1306 **
1307 *******************************************************************************/
1308 extern tNFC_STATUS RW_I93FormatNDef(void);
1309 
1310 /*******************************************************************************
1311 **
1312 ** Function         RW_I93SetTagReadOnly
1313 **
1314 ** Description      This function performs NDEF read-only procedure
1315 **                  Note: RW_I93DetectNDef() must be called before using this
1316 **                        Updating data must not be removed until returning
1317 **                        event
1318 **
1319 **                  The RW_I93_SET_TAG_RO_EVT event will be returned.
1320 **
1321 ** Returns          NFC_STATUS_OK if success
1322 **                  NFC_STATUS_FAILED if I93 is busy or other error
1323 **
1324 *******************************************************************************/
1325 extern tNFC_STATUS RW_I93SetTagReadOnly(void);
1326 
1327 /*****************************************************************************
1328 **
1329 ** Function         RW_I93PresenceCheck
1330 **
1331 ** Description      Check if the tag is still in the field.
1332 **
1333 **                  The RW_I93_PRESENCE_CHECK_EVT w/ status is used to indicate
1334 **                  presence or non-presence.
1335 **
1336 ** Returns          NFC_STATUS_OK, if raw data frame sent
1337 **                  NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this
1338 **                  operation
1339 **                  NFC_STATUS_FAILED: other error
1340 **
1341 *****************************************************************************/
1342 extern tNFC_STATUS RW_I93PresenceCheck(void);
1343 
1344 /*****************************************************************************
1345 **
1346 ** Function         RW_I93CheckLegacyProduct
1347 **
1348 ** Description      Returns if the product is part of the legacy product list,
1349 **                  requiring (Extended)GetSystemInfo ISO commands to provide
1350 **                  memory information (number and size of blocks).
1351 **
1352 ** Returns          true, if product is a legacy one
1353 **                  false, if full NFC forum T5T compliant
1354 **
1355 *****************************************************************************/
1356 extern bool RW_I93CheckLegacyProduct(uint8_t ic_manuf, uint8_t pdt_code);
1357 
1358 /*****************************************************************************
1359 **
1360 ** Function         RW_I93SetAddressingMode
1361 **
1362 ** Description      Set if the tag must be addressed with UID or not.
1363 **
1364 **                  The addressing mode (addressed or non-addressed) must be
1365 **                  done at the module initialization prior to the Tag
1366 **                  activation.
1367 **
1368 ** Returns          NFC_STATUS_OK, if mode is stored
1369 **                  NFC_STATUS_FAILED: other error
1370 **
1371 *****************************************************************************/
1372 extern tNFC_STATUS RW_I93SetAddressingMode(bool mode);
1373 
1374 /*******************************************************************************
1375 **
1376 ** Function         RW_SendRawFrame
1377 **
1378 ** Description      This function sends a raw frame to the peer device.
1379 **
1380 ** Returns          tNFC_STATUS
1381 **
1382 *******************************************************************************/
1383 extern tNFC_STATUS RW_SendRawFrame(uint8_t* p_raw_data, uint16_t data_len);
1384 
1385 /*******************************************************************************
1386 **
1387 ** Function         RW_SetActivatedTagType
1388 **
1389 ** Description      This function sets tag type for Reader/Writer mode.
1390 **
1391 ** Returns          tNFC_STATUS
1392 **
1393 *******************************************************************************/
1394 extern tNFC_STATUS RW_SetActivatedTagType(tNFC_ACTIVATE_DEVT* p_activate_params,
1395                                           tRW_CBACK* p_cback);
1396 /*******************************************************************************
1397 **
1398 ** Function         RW_MfcDetectNDef
1399 **
1400 ** Description      This function performs NDEF detection procedure
1401 **
1402 **                  RW_MFC_NDEF_DETECT_EVT will be returned
1403 **
1404 ** Returns          NFC_STATUS_OK if success
1405 **                  NFC_STATUS_FAILED if Mifare classic tag is busy or other
1406 *error
1407 **
1408 *******************************************************************************/
1409 extern tNFC_STATUS RW_MfcDetectNDef(void);
1410 
1411 /*******************************************************************************
1412 **
1413 ** Function         RW_MfcReadNDef
1414 **
1415 ** Description      This function can be called to read the NDEF message on the
1416 *tag.
1417 **
1418 ** Parameters:      p_buffer:   The buffer into which to read the NDEF message
1419 **                  buf_len:    The length of the buffer
1420 **
1421 ** Returns          NCI_STATUS_OK, if read was started. Otherwise, error status.
1422 **
1423 *******************************************************************************/
1424 extern tNFC_STATUS RW_MfcReadNDef(uint8_t* p_buffer, uint16_t buf_len);
1425 
1426 /*******************************************************************************
1427 **
1428 ** Function         RW_T4tNfceeSelectApplication
1429 **
1430 ** Description      Selects T4T application using T4T AID
1431 **
1432 ** Returns          NFC_STATUS_OK if success else NFC_STATUS_FAILED
1433 **
1434 *******************************************************************************/
1435 extern tNFC_STATUS RW_T4tNfceeSelectApplication(void);
1436 
1437 /*******************************************************************************
1438 **
1439 ** Function         RW_T4tNfceeUpdateCC
1440 **
1441 ** Description      Updates the T4T data structures with CC info
1442 **
1443 ** Returns          None
1444 **
1445 *******************************************************************************/
1446 void RW_T4tNfceeUpdateCC(uint8_t* ccInfo);
1447 
1448 /*******************************************************************************
1449 **
1450 ** Function         rw_ci_select
1451 **
1452 ** Description      This function send Select command for Chinese Id card.
1453 **
1454 ** Returns          NFC_STATUS_OK if success
1455 **
1456 *******************************************************************************/
1457 extern tNFC_STATUS rw_ci_select(void);
1458 
1459 /*****************************************************************************
1460 **
1461 ** Function         RW_CiPresenceCheck
1462 **
1463 ** Description
1464 **      Check if the tag is still in the field.
1465 **
1466 **      The RW_CI_PRESENCE_CHECK_EVT w/ status is used to indicate presence
1467 **      or non-presence.
1468 **
1469 ** Returns
1470 **      NFC_STATUS_OK, if raw data frame sent
1471 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
1472 **      NFC_STATUS_FAILED: other error
1473 **
1474 *****************************************************************************/
1475 extern tNFC_STATUS RW_CiPresenceCheck(void);
1476 
1477 /*****************************************************************************
1478 **
1479 ** Function         RW_CiSendAttrib
1480 **
1481 ** Description
1482 **      Send the Attrib to the Endpoint.
1483 **
1484 ** Returns
1485 **      NFC_STATUS_OK, if raw data frame sent
1486 **      NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation
1487 **      NFC_STATUS_FAILED: other error
1488 **
1489 *****************************************************************************/
1490 extern tNFC_STATUS RW_CiSendAttrib(uint8_t* nfcid0);
1491 
1492 /*******************************************************************************
1493 **
1494 ** Function         RW_T4tNfceeSelectFile
1495 **
1496 ** Description      Selects T4T Nfcee File
1497 **
1498 ** Returns          NFC_STATUS_OK if success
1499 **
1500 *******************************************************************************/
1501 extern tNFC_STATUS RW_T4tNfceeSelectFile(uint16_t fileId);
1502 
1503 /*******************************************************************************
1504 **
1505 ** Function         RW_T4tNfceeReadDataLen
1506 **
1507 ** Description      Reads proprietary data Len
1508 **
1509 ** Returns          NFC_STATUS_OK if success
1510 **
1511 *******************************************************************************/
1512 extern tNFC_STATUS RW_T4tNfceeReadDataLen();
1513 
1514 /*******************************************************************************
1515 **
1516 ** Function         RW_T4tNfceeStartUpdateFile
1517 **
1518 ** Description      starts writing data to the currently selected file
1519 **
1520 ** Returns          NFC_STATUS_OK if success
1521 **
1522 *******************************************************************************/
1523 extern tNFC_STATUS RW_T4tNfceeStartUpdateFile(uint16_t length, uint8_t* p_data);
1524 
1525 /*******************************************************************************
1526 **
1527 ** Function         RW_T4tNfceeUpdateFile
1528 **
1529 ** Description      writes requested data to the currently selected file
1530 **
1531 ** Returns          NFC_STATUS_OK if success else NFC_STATUS_FAILED
1532 **
1533 *******************************************************************************/
1534 extern tNFC_STATUS RW_T4tNfceeUpdateFile();
1535 
1536 /*******************************************************************************
1537 **
1538 ** Function         RW_T4tIsUpdateComplete
1539 **
1540 ** Description      Return true if no more data to write
1541 **
1542 ** Returns          true/false
1543 **
1544 *******************************************************************************/
1545 extern bool RW_T4tIsUpdateComplete(void);
1546 
1547 /*******************************************************************************
1548 **
1549 ** Function         RW_T4tIsReadComplete
1550 **
1551 ** Description      Return true if no more data to be read
1552 **
1553 ** Returns          true/false
1554 **
1555 *******************************************************************************/
1556 extern bool RW_T4tIsReadComplete(void);
1557 
1558 /*******************************************************************************
1559 **
1560 ** Function         RW_T4tNfceeReadFile
1561 **
1562 ** Description      Reads T4T Nfcee File
1563 **
1564 ** Returns          NFC_STATUS_OK if success
1565 **
1566 *******************************************************************************/
1567 extern tNFC_STATUS RW_T4tNfceeReadFile(uint16_t offset, uint16_t Readlen);
1568 
1569 /*******************************************************************************
1570 **
1571 ** Function         RW_T4tNfceeReadPendingData
1572 **
1573 ** Description      Reads pending data from T4T Nfcee File
1574 **
1575 ** Returns          NFC_STATUS_OK if success else NFC_STATUS_FAILED
1576 **
1577 *******************************************************************************/
1578 extern tNFC_STATUS RW_T4tNfceeReadPendingData();
1579 
1580 /*******************************************************************************
1581 **
1582 ** Function         RW_T4tNfceeUpdateNlen
1583 **
1584 ** Description      writes requested length to the file
1585 **
1586 ** Returns          NFC_STATUS_OK if success
1587 **
1588 *******************************************************************************/
1589 extern tNFC_STATUS RW_T4tNfceeUpdateNlen(uint16_t len);
1590 
1591 /*******************************************************************************
1592 **
1593 ** Function         RW_SetT4tNfceeInfo
1594 **
1595 ** Description      This function sets callbacks for T4t operations.
1596 **
1597 ** Returns          tNFC_STATUS
1598 **
1599 *******************************************************************************/
1600 extern tNFC_STATUS RW_SetT4tNfceeInfo(tRW_CBACK* p_cback, uint8_t conn_id);
1601 
1602 /*****************************************************************************
1603 **
1604 ** Function         RW_MfcFormatNDef
1605 **
1606 ** Description
1607 **      Format Tag content
1608 **
1609 ** Returns
1610 **      NFC_STATUS_OK, Command sent to format Tag
1611 **      NFC_STATUS_REJECTED: cannot format the tag
1612 **      NFC_STATUS_FAILED: other error
1613 **
1614 *****************************************************************************/
1615 extern tNFC_STATUS RW_MfcFormatNDef(void);
1616 
1617 /*******************************************************************************
1618 **
1619 ** Function         RW_MfcWriteNDef
1620 **
1621 ** Description      This function can be called to write an NDEF message to the
1622 **                  tag.
1623 **
1624 ** Parameters:      buf_len:    The length of the buffer
1625 **                  p_buffer:   The NDEF message to write
1626 **
1627 ** Returns          NCI_STATUS_OK, if write was started. Otherwise, error
1628 **                  status.
1629 **
1630 *******************************************************************************/
1631 extern tNFC_STATUS RW_MfcWriteNDef(uint16_t buf_len, uint8_t* p_buffer);
1632 
1633 #endif /* RW_API_H */
1634