1/****************************************************************************** 2 * 3 * Copyright (C) 2009-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19/****************************************************************************** 20 * 21 * This file contains 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 "tags_defs.h" 29 30#define RW_T1T_BLD_ADD(a, k, y) a = ((k & 0xF) << 3) | (y&0x7); 31#define RW_T1T_BLD_ADDS(a, s) a = ((s & 0xF) << 4); 32 33#define RW_T1T_FIRST_EVT 0x20 34#define RW_T2T_FIRST_EVT 0x40 35#define RW_T3T_FIRST_EVT 0x60 36#define RW_T4T_FIRST_EVT 0x80 37#define RW_I93_FIRST_EVT 0xA0 38 39enum 40{ 41 /* Note: the order of these events can not be changed */ 42 /* Type 1 tag events for tRW_CBACK */ 43 RW_T1T_RID_EVT = RW_T1T_FIRST_EVT, /* Read ID command completd */ 44 RW_T1T_RALL_CPLT_EVT, /* Read All command completed */ 45 RW_T1T_READ_CPLT_EVT, /* Read byte completed */ 46 RW_T1T_WRITE_E_CPLT_EVT, /* Write byte after erase completed */ 47 RW_T1T_WRITE_NE_CPLT_EVT, /* Write byte with no erase completed */ 48 RW_T1T_RSEG_CPLT_EVT, /* Read segment completed */ 49 RW_T1T_READ8_CPLT_EVT, /* Read block completed */ 50 RW_T1T_WRITE_E8_CPLT_EVT, /* Write block after erase completed */ 51 RW_T1T_WRITE_NE8_CPLT_EVT, /* Write block with no erase completed */ 52 RW_T1T_TLV_DETECT_EVT, /* Lock/Mem/Prop tlv detection complete */ 53 RW_T1T_NDEF_DETECT_EVT, /* NDEF detection complete */ 54 RW_T1T_NDEF_READ_EVT, /* NDEF read completed */ 55 RW_T1T_NDEF_WRITE_EVT, /* NDEF write complete */ 56 RW_T1T_SET_TAG_RO_EVT, /* Tag is set as read only */ 57 RW_T1T_RAW_FRAME_EVT, /* Response of raw frame sent */ 58 RW_T1T_PRESENCE_CHECK_EVT, /* Response to RW_T1tPresenceCheck */ 59 RW_T1T_FORMAT_CPLT_EVT, /* Tag Formated */ 60 RW_T1T_INTF_ERROR_EVT, /* RF Interface error event */ 61 RW_T1T_MAX_EVT, 62 63 /* Type 2 tag events */ 64 RW_T2T_READ_CPLT_EVT = RW_T2T_FIRST_EVT, /* Read completed */ 65 RW_T2T_WRITE_CPLT_EVT, /* Write completed */ 66 RW_T2T_SELECT_CPLT_EVT, /* Sector select completed */ 67 RW_T2T_NDEF_DETECT_EVT, /* NDEF detection complete */ 68 RW_T2T_TLV_DETECT_EVT, /* Lock/Mem/Prop tlv detection complete */ 69 RW_T2T_NDEF_READ_EVT, /* NDEF read completed */ 70 RW_T2T_NDEF_WRITE_EVT, /* NDEF write complete */ 71 RW_T2T_SET_TAG_RO_EVT, /* Tag is set as read only */ 72 RW_T2T_RAW_FRAME_EVT, /* Response of raw frame sent */ 73 RW_T2T_PRESENCE_CHECK_EVT, /* Response to RW_T2tPresenceCheck */ 74 RW_T2T_FORMAT_CPLT_EVT, /* Tag Formated */ 75 RW_T2T_INTF_ERROR_EVT, /* RF Interface error event */ 76 RW_T2T_MAX_EVT, 77 78 /* Type 3 tag events for tRW_CBACK */ 79 RW_T3T_CHECK_CPLT_EVT = RW_T3T_FIRST_EVT, /* Read completed */ 80 RW_T3T_UPDATE_CPLT_EVT, /* Write completed */ 81 RW_T3T_CHECK_EVT, /* Segment of data received from type 3 tag */ 82 RW_T3T_RAW_FRAME_EVT, /* SendRawFrame response */ 83 RW_T3T_NDEF_DETECT_EVT, /* NDEF detection complete */ 84 RW_T3T_PRESENCE_CHECK_EVT, /* Response to RW_T3tPresenceCheck */ 85 RW_T3T_POLL_EVT, /* Response to RW_T3tPoll */ 86 RW_T3T_GET_SYSTEM_CODES_EVT, /* Response to RW_T3tGetSystemCodes */ 87 RW_T3T_FORMAT_CPLT_EVT, /* Tag Formated (Felica-Lite only) */ 88 RW_T3T_INTF_ERROR_EVT, /* RF Interface error event */ 89 RW_T3T_MAX_EVT, 90 91 /* Type 4 tag events for tRW_CBACK */ 92 RW_T4T_NDEF_DETECT_EVT = RW_T4T_FIRST_EVT, /* Result of NDEF detection procedure */ 93 /* Mandatory NDEF file is selected */ 94 RW_T4T_NDEF_READ_EVT, /* Segment of data received from type 4 tag */ 95 RW_T4T_NDEF_READ_CPLT_EVT, /* Read operation completed */ 96 RW_T4T_NDEF_READ_FAIL_EVT, /* Read operation failed */ 97 RW_T4T_NDEF_UPDATE_CPLT_EVT, /* Update operation completed */ 98 RW_T4T_NDEF_UPDATE_FAIL_EVT, /* Update operation failed */ 99 RW_T4T_PRESENCE_CHECK_EVT, /* Response to RW_T4tPresenceCheck */ 100 RW_T4T_RAW_FRAME_EVT, /* Response of raw frame sent */ 101 RW_T4T_INTF_ERROR_EVT, /* RF Interface error event */ 102 RW_T4T_MAX_EVT, 103 104 /* ISO 15693 tag events for tRW_CBACK */ 105 RW_I93_NDEF_DETECT_EVT = RW_I93_FIRST_EVT, /* Result of NDEF detection procedure */ 106 RW_I93_NDEF_READ_EVT, /* Segment of data received from tag */ 107 RW_I93_NDEF_READ_CPLT_EVT, /* Read operation completed */ 108 RW_I93_NDEF_READ_FAIL_EVT, /* Read operation failed */ 109 RW_I93_NDEF_UPDATE_CPLT_EVT, /* Update operation completed */ 110 RW_I93_NDEF_UPDATE_FAIL_EVT, /* Update operation failed */ 111 RW_I93_FORMAT_CPLT_EVT, /* Format procedure complete */ 112 RW_I93_SET_TAG_RO_EVT, /* Set read-only procedure complete */ 113 RW_I93_INVENTORY_EVT, /* Response of Inventory */ 114 RW_I93_DATA_EVT, /* Response of Read, Get Multi Security */ 115 RW_I93_SYS_INFO_EVT, /* Response of System Information */ 116 RW_I93_CMD_CMPL_EVT, /* Command complete */ 117 RW_I93_PRESENCE_CHECK_EVT, /* Response to RW_I93PresenceCheck */ 118 RW_I93_RAW_FRAME_EVT, /* Response of raw frame sent */ 119 RW_I93_INTF_ERROR_EVT, /* RF Interface error event */ 120 RW_I93_MAX_EVT 121}; 122 123#define RW_RAW_FRAME_EVT 0xFF 124 125typedef UINT8 tRW_EVENT; 126 127#define RW_NDEF_FL_READ_ONLY 0x01 /* Tag is read only */ 128#define RW_NDEF_FL_FORMATED 0x02 /* Tag formated for NDEF */ 129#define RW_NDEF_FL_SUPPORTED 0x04 /* NDEF supported by the tag */ 130#define RW_NDEF_FL_UNKNOWN 0x08 /* Unable to find if tag is ndef capable/formated/read only */ 131#define RW_NDEF_FL_FORMATABLE 0x10 /* Tag supports format operation */ 132#define RW_NDEF_FL_SOFT_LOCKABLE 0x20 /* Tag can be soft locked */ 133#define RW_NDEF_FL_HARD_LOCKABLE 0x40 /* Tag can be hard locked */ 134#define RW_NDEF_FL_OTP 0x80 /* Tag is one time programmable */ 135 136typedef struct 137{ 138 tNFC_STATUS status; 139 UINT8 hr[T1T_HR_LEN]; 140 UINT8 uid[T1T_CMD_UID_LEN]; 141} tRW_T1T_RID_EVT; 142 143typedef struct 144{ 145 tNFC_STATUS status; 146 UINT16 msg_len; /* Length of the NDEF message */ 147} tRW_T2T_DETECT; 148 149typedef struct 150{ 151 tNFC_STATUS status; /* Status of the POLL request */ 152 UINT8 rc; /* RC (request code) used in the POLL request */ 153 UINT8 response_num; /* Number of SENSF_RES responses */ 154 UINT8 response_bufsize; /* Size of SENSF_RES responses */ 155 UINT8 *response_buf; /* Buffer of responses (length + SENSF_RES) see $8.1.2.2 of NCI specs */ 156} tRW_T3T_POLL; 157 158typedef struct 159{ 160 tNFC_STATUS status; /* Status of the Get System Codes request */ 161 UINT8 num_system_codes; /* Number of system codes */ 162 UINT16 *p_system_codes; /* Table of system codes */ 163} tRW_T3T_SYSTEM_CODES; 164 165typedef struct 166{ 167 tNFC_STATUS status; /* status of NDEF detection */ 168 tNFC_PROTOCOL protocol; /* protocol used to detect NDEF */ 169 UINT32 max_size; /* max number of bytes available for NDEF data */ 170 UINT32 cur_size; /* current size of stored NDEF data (in bytes) */ 171 UINT8 flags; /* Flags to indicate NDEF capability,formated,formatable and read only */ 172} tRW_DETECT_NDEF_DATA; 173 174typedef struct 175{ 176 tNFC_STATUS status; /* status of NDEF detection */ 177 tNFC_PROTOCOL protocol; /* protocol used to detect TLV */ 178 UINT8 num_bytes; /* number of reserved/lock bytes based on the type of tlv */ 179} tRW_DETECT_TLV_DATA; 180 181typedef struct 182{ 183 tNFC_STATUS status; 184 BT_HDR *p_data; 185} tRW_READ_DATA; 186 187typedef struct 188{ 189 tNFC_STATUS status; 190 UINT8 sw1; 191 UINT8 sw2; 192} tRW_T4T_SW; 193 194typedef struct /* RW_I93_INVENTORY_EVT */ 195{ 196 tNFC_STATUS status; /* status of Inventory command */ 197 UINT8 dsfid; /* DSFID */ 198 UINT8 uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB */ 199} tRW_I93_INVENTORY; 200 201typedef struct /* RW_I93_DATA_EVT */ 202{ 203 tNFC_STATUS status; /* status of Read/Get security status command */ 204 UINT8 command; /* sent command */ 205 BT_HDR *p_data; /* block data of security status */ 206} tRW_I93_DATA; 207 208typedef struct /* RW_I93_SYS_INFO_EVT */ 209{ 210 tNFC_STATUS status; /* status of Get Sys Info command */ 211 UINT8 info_flags; /* information flags */ 212 UINT8 uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB */ 213 UINT8 dsfid; /* DSFID if I93_INFO_FLAG_DSFID */ 214 UINT8 afi; /* AFI if I93_INFO_FLAG_AFI */ 215 UINT16 num_block; /* number of blocks if I93_INFO_FLAG_MEM_SIZE */ 216 UINT8 block_size; /* block size in byte if I93_INFO_FLAG_MEM_SIZE */ 217 UINT8 IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF */ 218} tRW_I93_SYS_INFO; 219 220typedef struct /* RW_I93_CMD_CMPL_EVT */ 221{ 222 tNFC_STATUS status; /* status of sent command */ 223 UINT8 command; /* sent command */ 224 UINT8 error_code; /* error code; I93_ERROR_CODE_XXX */ 225} tRW_I93_CMD_CMPL; 226 227typedef struct 228{ 229 tNFC_STATUS status; 230 BT_HDR *p_data; 231} tRW_RAW_FRAME; 232 233typedef union 234{ 235 tNFC_STATUS status; 236 tRW_T3T_POLL t3t_poll; /* Response to t3t poll command */ 237 tRW_T3T_SYSTEM_CODES t3t_sc; /* Received system codes from t3 tag */ 238 tRW_DETECT_TLV_DATA tlv; /* The information of detected TLV data */ 239 tRW_DETECT_NDEF_DATA ndef; /* The information of detected NDEF data */ 240 tRW_READ_DATA data; /* The received data from a tag */ 241 tRW_RAW_FRAME raw_frame; /* Response of raw frame sent */ 242 tRW_T4T_SW t4t_sw; /* Received status words from a tag */ 243 tRW_I93_INVENTORY i93_inventory; /* ISO 15693 Inventory response */ 244 tRW_I93_DATA i93_data; /* ISO 15693 Data response */ 245 tRW_I93_SYS_INFO i93_sys_info; /* ISO 15693 System Information */ 246 tRW_I93_CMD_CMPL i93_cmd_cmpl; /* ISO 15693 Command complete */ 247} tRW_DATA; 248 249 250typedef void (tRW_CBACK) (tRW_EVENT event, tRW_DATA *p_data); 251 252/******************************************************************************* 253** 254** Function RW_T1tRid 255** 256** Description This function send a RID command for Reader/Writer mode. 257** 258** Returns tNFC_STATUS 259** 260*******************************************************************************/ 261NFC_API extern tNFC_STATUS RW_T1tRid (void); 262 263/******************************************************************************* 264** 265** Function RW_T1tReadAll 266** 267** Description This function send a RALL command for Reader/Writer mode. 268** 269** Returns tNFC_STATUS 270** 271*******************************************************************************/ 272NFC_API extern tNFC_STATUS RW_T1tReadAll (void); 273 274/******************************************************************************* 275** 276** Function RW_T1tRead 277** 278** Description This function send a READ command for Reader/Writer mode. 279** 280** Returns tNFC_STATUS 281** 282*******************************************************************************/ 283NFC_API extern tNFC_STATUS RW_T1tRead (UINT8 block, UINT8 byte); 284 285/******************************************************************************* 286** 287** Function RW_T1tWriteErase 288** 289** Description This function send a WRITE-E command for Reader/Writer mode. 290** 291** Returns tNFC_STATUS 292** 293*******************************************************************************/ 294NFC_API extern tNFC_STATUS RW_T1tWriteErase (UINT8 block, UINT8 byte, UINT8 new_byte); 295 296/******************************************************************************* 297** 298** Function RW_T1tWriteNoErase 299** 300** Description This function send a WRITE-NE command for Reader/Writer mode. 301** 302** Returns tNFC_STATUS 303** 304*******************************************************************************/ 305NFC_API extern tNFC_STATUS RW_T1tWriteNoErase (UINT8 block, UINT8 byte, UINT8 new_byte); 306 307/******************************************************************************* 308** 309** Function RW_T1tReadSeg 310** 311** Description This function send a RSEG command for Reader/Writer mode. 312** 313** Returns tNFC_STATUS 314** 315*******************************************************************************/ 316NFC_API extern tNFC_STATUS RW_T1tReadSeg (UINT8 segment); 317 318/******************************************************************************* 319** 320** Function RW_T1tRead8 321** 322** Description This function send a READ8 command for Reader/Writer mode. 323** 324** Returns tNFC_STATUS 325** 326*******************************************************************************/ 327NFC_API extern tNFC_STATUS RW_T1tRead8 (UINT8 block); 328 329/******************************************************************************* 330** 331** Function RW_T1tWriteErase8 332** 333** Description This function send a WRITE-E8 command for Reader/Writer mode. 334** 335** Returns tNFC_STATUS 336** 337*******************************************************************************/ 338NFC_API extern tNFC_STATUS RW_T1tWriteErase8 (UINT8 block, UINT8 *p_new_dat); 339 340/******************************************************************************* 341** 342** Function RW_T1tWriteNoErase8 343** 344** Description This function send a WRITE-NE8 command for Reader/Writer mode. 345** 346** Returns tNFC_STATUS 347** 348*******************************************************************************/ 349NFC_API extern tNFC_STATUS RW_T1tWriteNoErase8 (UINT8 block, UINT8 *p_new_dat); 350 351/******************************************************************************* 352** 353** Function RW_T1tLocateTlv 354** 355** Description This function is called to find the start of the given TLV 356** 357** Parameters: void 358** 359** Returns NCI_STATUS_OK, if detection was started. Otherwise, error status. 360** 361*******************************************************************************/ 362NFC_API extern tNFC_STATUS RW_T1tLocateTlv (UINT8 tlv_type); 363 364/******************************************************************************* 365** 366** Function RW_T2tDetectNDef 367** 368** Description This function can be called to detect if there is an NDEF 369** message on the tag. 370** 371** Parameters: void 372** 373** Returns NCI_STATUS_OK, if detection was started. Otherwise, error status. 374** 375*******************************************************************************/ 376NFC_API extern tNFC_STATUS RW_T1tDetectNDef (void); 377 378/******************************************************************************* 379** 380** Function RW_T1tReadNDef 381** 382** Description This function can be called to read the NDEF message on the tag. 383** 384** Parameters: p_buffer: The buffer into which to read the NDEF message 385** buf_len: The length of the buffer 386** 387** Returns NCI_STATUS_OK, if read was started. Otherwise, error status. 388** 389*******************************************************************************/ 390NFC_API extern tNFC_STATUS RW_T1tReadNDef (UINT8 *p_buffer, UINT16 buf_len); 391 392/******************************************************************************* 393** 394** Function RW_T1tWriteNDef 395** 396** Description This function can be called to write an NDEF message to the tag. 397** 398** Parameters: msg_len: The length of the buffer 399** p_msg: The NDEF message to write 400** 401** Returns NCI_STATUS_OK, if write was started. Otherwise, error status. 402** 403*******************************************************************************/ 404NFC_API extern tNFC_STATUS RW_T1tWriteNDef (UINT16 msg_len, UINT8 *p_msg); 405 406/******************************************************************************* 407** 408** Function RW_T1tSetTagReadOnly 409** 410** Description This function can be called to set the tag in to read only 411** state 412** 413** Parameters: b_hard_lock: To hard lock or just soft lock the tag 414** 415** Returns NCI_STATUS_OK, if set readonly operation started. 416** Otherwise, error status. 417** 418*******************************************************************************/ 419NFC_API extern tNFC_STATUS RW_T1tSetTagReadOnly (BOOLEAN b_hard_lock); 420 421/***************************************************************************** 422** 423** Function RW_T1tPresenceCheck 424** 425** Description 426** Check if the tag is still in the field. 427** 428** The RW_T1T_PRESENCE_CHECK_EVT w/ status is used to indicate presence 429** or non-presence. 430** 431** Returns 432** NFC_STATUS_OK, if raw data frame sent 433** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 434** NFC_STATUS_FAILED: other error 435** 436*****************************************************************************/ 437NFC_API extern tNFC_STATUS RW_T1tPresenceCheck (void); 438 439/***************************************************************************** 440** 441** Function RW_T1tFormatNDef 442** 443** Description 444** Format Tag content 445** 446** Returns 447** NFC_STATUS_OK, Command sent to format Tag 448** NFC_STATUS_REJECTED: Invalid HR0 and cannot format the tag 449** NFC_STATUS_FAILED: other error 450** 451*****************************************************************************/ 452tNFC_STATUS RW_T1tFormatNDef (void); 453 454/******************************************************************************* 455** 456** Function RW_T2tLocateTlv 457** 458** Description This function is called to find the start of the given TLV 459** 460** Returns Pointer to the TLV, if successful. Otherwise, NULL. 461** 462*******************************************************************************/ 463NFC_API extern tNFC_STATUS RW_T2tLocateTlv(UINT8 tlv_type); 464 465/******************************************************************************* 466** 467** Function RW_T2tRead 468** 469** Description This function issues the Type 2 Tag READ command. When the 470** operation is complete the callback function will be called 471** with a RW_T2T_READ_EVT. 472** 473** Returns tNFC_STATUS 474** 475*******************************************************************************/ 476NFC_API extern tNFC_STATUS RW_T2tRead (UINT16 block); 477 478/******************************************************************************* 479** 480** Function RW_T2tWrite 481** 482** Description This function issues the Type 2 Tag WRITE command. When the 483** operation is complete the callback function will be called 484** with a RW_T2T_WRITE_EVT. 485** 486** p_write_data points to the array of 4 bytes to be written 487** 488** Returns tNFC_STATUS 489** 490*******************************************************************************/ 491NFC_API extern tNFC_STATUS RW_T2tWrite (UINT16 block, UINT8 *p_write_data); 492 493/******************************************************************************* 494** 495** Function RW_T2tSectorSelect 496** 497** Description This function issues the Type 2 Tag SECTOR-SELECT command 498** packet 1. If a NACK is received as the response, the callback 499** function will be called with a RW_T2T_SECTOR_SELECT_EVT. If 500** an ACK is received as the response, the command packet 2 with 501** the given sector number is sent to the peer device. When the 502** response for packet 2 is received, the callback function will 503** be called with a RW_T2T_SECTOR_SELECT_EVT. 504** 505** A sector is 256 contiguous blocks (1024 bytes). 506** 507** Returns tNFC_STATUS 508** 509*******************************************************************************/ 510NFC_API extern tNFC_STATUS RW_T2tSectorSelect (UINT8 sector); 511 512/******************************************************************************* 513** 514** Function RW_T2tDetectNDef 515** 516** Description This function will find NDEF message if any in the Tag 517** 518** Returns tNFC_STATUS 519** 520*******************************************************************************/ 521NFC_API extern tNFC_STATUS RW_T2tDetectNDef (void); 522 523/******************************************************************************* 524** 525** Function RW_T2tReadNDef 526** 527** Description This function can be called to read the NDEF message on the tag. 528** 529** Parameters: p_buffer: The buffer into which to read the NDEF message 530** buf_len: The length of the buffer 531** 532** Returns NCI_STATUS_OK, if read was started. Otherwise, error status. 533** 534*******************************************************************************/ 535NFC_API extern tNFC_STATUS RW_T2tReadNDef (UINT8 *p_buffer, UINT16 buf_len); 536 537/******************************************************************************* 538** 539** Function RW_T2tWriteNDef 540** 541** Description This function can be called to write an NDEF message to the tag. 542** 543** Parameters: msg_len: The length of the buffer 544** p_msg: The NDEF message to write 545** 546** Returns NCI_STATUS_OK, if write was started. Otherwise, error status. 547** 548*******************************************************************************/ 549NFC_API extern tNFC_STATUS RW_T2tWriteNDef (UINT16 msg_len, UINT8 *p_msg ); 550 551/******************************************************************************* 552** 553** Function RW_T2tSetTagReadOnly 554** 555** Description This function can be called to set the tag in to read only 556** state 557** 558** Parameters: b_hard_lock: To indicate hard lock the tag or not 559** 560** Returns NCI_STATUS_OK, if set readonly operation started. 561** Otherwise, error status. 562** 563*******************************************************************************/ 564NFC_API extern tNFC_STATUS RW_T2tSetTagReadOnly (BOOLEAN b_hard_lock); 565 566/***************************************************************************** 567** 568** Function RW_T2tPresenceCheck 569** 570** Description 571** Check if the tag is still in the field. 572** 573** The RW_T2T_PRESENCE_CHECK_EVT w/ status is used to indicate presence 574** or non-presence. 575** 576** Returns 577** NFC_STATUS_OK, if raw data frame sent 578** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 579** NFC_STATUS_FAILED: other error 580** 581*****************************************************************************/ 582NFC_API extern tNFC_STATUS RW_T2tPresenceCheck (void); 583 584/***************************************************************************** 585** 586** Function RW_T2tFormatNDef 587** 588** Description 589** Format Tag content 590** 591** Returns 592** NFC_STATUS_OK, Command sent to format Tag 593** NFC_STATUS_FAILED: otherwise 594** 595*****************************************************************************/ 596tNFC_STATUS RW_T2tFormatNDef (void); 597 598/***************************************************************************** 599** 600** Function RW_T3tDetectNDef 601** 602** Description 603** This function is used to perform NDEF detection on a Type 3 tag, and 604** retrieve the tag's NDEF attribute information (block 0). 605** 606** Before using this API, the application must call RW_SelectTagType to 607** indicate that a Type 3 tag has been activated, and to provide the 608** tag's Manufacture ID (IDm) . 609** 610** Returns 611** NFC_STATUS_OK: ndef detection procedure started 612** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 613** NFC_STATUS_FAILED: other error 614** 615*****************************************************************************/ 616NFC_API extern tNFC_STATUS RW_T3tDetectNDef (void); 617 618/***************************************************************************** 619** 620** Function RW_T3tFormatNDef 621** 622** Description 623** Format a type-3 tag for NDEF. 624** 625** Only Felica-Lite tags are supported by this API. The 626** RW_T3T_FORMAT_CPLT_EVT is used to notify the status of the operation. 627** 628** Returns 629** NFC_STATUS_OK: ndef detection procedure started 630** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 631** NFC_STATUS_FAILED: other error 632** 633*****************************************************************************/ 634NFC_API extern tNFC_STATUS RW_T3tFormatNDef (void); 635 636/***************************************************************************** 637** 638** Function RW_T3tCheckNDef 639** 640** Description 641** Retrieve NDEF contents from a Type3 tag. 642** 643** The RW_T3T_CHECK_EVT event is used to notify the application for each 644** segment of NDEF data received. The RW_T3T_CHECK_CPLT_EVT event is used to 645** notify the application all segments have been received. 646** 647** Before using this API, the RW_T3tDetectNDef function must be called to 648** verify that the tag contains NDEF data, and to retrieve the NDEF 649** attributes. 650** 651** Internally, this command will be separated into multiple Tag 3 Check 652** commands (if necessary) - depending on the tag's Nbr (max number of 653** blocks per read) attribute. 654** 655** Returns 656** NFC_STATUS_OK: check command started 657** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 658** NFC_STATUS_FAILED: other error 659** 660*****************************************************************************/ 661NFC_API extern tNFC_STATUS RW_T3tCheckNDef (void); 662 663/***************************************************************************** 664** 665** Function RW_T3tUpdateNDef 666** 667** Description 668** Write NDEF contents to a Type3 tag. 669** 670** The RW_T3T_UPDATE_CPLT_EVT callback event will be used to notify the 671** application of the response. 672** 673** Before using this API, the RW_T3tDetectNDef function must be called to 674** verify that the tag contains NDEF data, and to retrieve the NDEF 675** attributes. 676** 677** Internally, this command will be separated into multiple Tag 3 Update 678** commands (if necessary) - depending on the tag's Nbw (max number of 679** blocks per write) attribute. 680** 681** Returns 682** NFC_STATUS_OK: check command started 683** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 684** NFC_STATUS_REFUSED: tag is read-only 685** NFC_STATUS_BUFFER_FULL: len exceeds tag's maximum size 686** NFC_STATUS_FAILED: other error 687** 688*****************************************************************************/ 689NFC_API extern tNFC_STATUS RW_T3tUpdateNDef (UINT32 len, UINT8 *p_data); 690 691/***************************************************************************** 692** 693** Function RW_T3tCheck 694** 695** Description 696** Read (non-NDEF) contents from a Type3 tag. 697** 698** The RW_READ_EVT event is used to notify the application for each 699** segment of NDEF data received. The RW_READ_CPLT_EVT event is used to 700** notify the application all segments have been received. 701** 702** Before using this API, the application must call RW_SelectTagType to 703** indicate that a Type 3 tag has been activated, and to provide the 704** tag's Manufacture ID (IDm) . 705** 706** Returns 707** NFC_STATUS_OK: check command started 708** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 709** NFC_STATUS_FAILED: other error 710** 711*****************************************************************************/ 712NFC_API extern tNFC_STATUS RW_T3tCheck (UINT8 num_blocks, tT3T_BLOCK_DESC *t3t_blocks); 713 714/***************************************************************************** 715** 716** Function RW_T3tUpdate 717** 718** Description 719** Write (non-NDEF) contents to a Type3 tag. 720** 721** The RW_WRITE_CPLT_EVT event is used to notify the application all 722** segments have been received. 723** 724** Before using this API, the application must call RW_SelectTagType to 725** indicate that a Type 3 tag has been activated, and to provide the tag's 726** Manufacture ID (IDm) . 727** 728** Returns 729** NFC_STATUS_OK: check command started 730** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 731** NFC_STATUS_FAILED: other error 732** 733*****************************************************************************/ 734NFC_API extern tNFC_STATUS RW_T3tUpdate (UINT8 num_blocks, tT3T_BLOCK_DESC *t3t_blocks, UINT8 *p_data); 735 736/***************************************************************************** 737** 738** Function RW_T3tSendRawFrame 739** 740** Description 741** This function is called to send a raw data frame to the peer device. 742** When type 3 tag receives response from peer, the callback function 743** will be called with a RW_T3T_RAW_FRAME_EVT [Table 6]. 744** 745** Before using this API, the application must call RW_SelectTagType to 746** indicate that a Type 3 tag has been activated. 747** 748** The raw frame should be a properly formatted Type 3 tag message. 749** 750** Returns 751** NFC_STATUS_OK, if raw data frame sent 752** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 753** NFC_STATUS_FAILED: other error 754** 755*****************************************************************************/ 756NFC_API extern tNFC_STATUS RW_T3tSendRawFrame (UINT16 len, UINT8 *p_data); 757 758/***************************************************************************** 759** 760** Function RW_T3tPoll 761** 762** Description 763** Send POLL command 764** 765** Returns 766** NFC_STATUS_OK, if raw data frame sent 767** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 768** NFC_STATUS_FAILED: other error 769** 770*****************************************************************************/ 771NFC_API extern tNFC_STATUS RW_T3tPoll (UINT16 system_code, tT3T_POLL_RC rc, UINT8 tsn); 772 773/***************************************************************************** 774** 775** Function RW_T3tPresenceCheck 776** 777** Description 778** Check if the tag is still in the field. 779** 780** The RW_T3T_PRESENCE_CHECK_EVT w/ status is used to indicate presence 781** or non-presence. 782** 783** Returns 784** NFC_STATUS_OK, if raw data frame sent 785** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 786** NFC_STATUS_FAILED: other error 787** 788*****************************************************************************/ 789NFC_API extern tNFC_STATUS RW_T3tPresenceCheck (void); 790 791/***************************************************************************** 792** 793** Function RW_T3tGetSystemCodes 794** 795** Description 796** Get systems codes supported by the activated tag: 797** Poll for wildcard (FFFF): 798** - If felica-lite code then poll for ndef (12fc) 799** - Otherwise send RequestSystmCode command to get 800** system codes. 801** 802** Before using this API, the application must call RW_SelectTagType to 803** indicate that a Type 3 tag has been activated. 804** 805** Returns 806** NFC_STATUS_OK, if raw data frame sent 807** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 808** NFC_STATUS_FAILED: other error 809** 810*****************************************************************************/ 811NFC_API extern tNFC_STATUS RW_T3tGetSystemCodes (void); 812 813/******************************************************************************* 814** 815** Function RW_T4tDetectNDef 816** 817** Description This function performs NDEF detection procedure 818** 819** RW_T4T_NDEF_DETECT_EVT will be returned 820** 821** Returns NFC_STATUS_OK if success 822** NFC_STATUS_FAILED if T4T is busy or other error 823** 824*******************************************************************************/ 825NFC_API extern tNFC_STATUS RW_T4tDetectNDef (void); 826 827/******************************************************************************* 828** 829** Function RW_T4tReadNDef 830** 831** Description This function performs NDEF read procedure 832** Note: RW_T4tDetectNDef() must be called before using this 833** 834** The following event will be returned 835** RW_T4T_NDEF_READ_EVT for each segmented NDEF message 836** RW_T4T_NDEF_READ_CPLT_EVT for the last segment or complete NDEF 837** RW_T4T_NDEF_READ_FAIL_EVT for failure 838** 839** Returns NFC_STATUS_OK if success 840** NFC_STATUS_FAILED if T4T is busy or other error 841** 842*******************************************************************************/ 843NFC_API extern tNFC_STATUS RW_T4tReadNDef (void); 844 845/******************************************************************************* 846** 847** Function RW_T4tUpdateNDef 848** 849** Description This function performs NDEF update procedure 850** Note: RW_T4tDetectNDef() must be called before using this 851** Updating data must not be removed until returning event 852** 853** The following event will be returned 854** RW_T4T_NDEF_UPDATE_CPLT_EVT for complete 855** RW_T4T_NDEF_UPDATE_FAIL_EVT for failure 856** 857** Returns NFC_STATUS_OK if success 858** NFC_STATUS_FAILED if T4T is busy or other error 859** 860*******************************************************************************/ 861NFC_API extern tNFC_STATUS RW_T4tUpdateNDef (UINT16 length, UINT8 *p_data); 862 863/***************************************************************************** 864** 865** Function RW_T4tPresenceCheck 866** 867** Description 868** Check if the tag is still in the field. 869** 870** The RW_T4T_PRESENCE_CHECK_EVT w/ status is used to indicate presence 871** or non-presence. 872** 873** Returns 874** NFC_STATUS_OK, if raw data frame sent 875** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 876** NFC_STATUS_FAILED: other error 877** 878*****************************************************************************/ 879NFC_API extern tNFC_STATUS RW_T4tPresenceCheck (void); 880 881 882/******************************************************************************* 883** 884** Function RW_I93Inventory 885** 886** Description This function send Inventory command 887** If UID is provided then set UID[0]:MSB, ... UID[7]:LSB 888** 889** RW_I93_RESPONSE_EVT will be returned 890** 891** Returns NFC_STATUS_OK if success 892** NFC_STATUS_NO_BUFFERS if out of buffer 893** NFC_STATUS_FAILED if T4T is busy or other error 894** 895*******************************************************************************/ 896NFC_API extern tNFC_STATUS RW_I93Inventory (UINT8 afi, UINT8 *p_uid); 897 898/******************************************************************************* 899** 900** Function RW_I93StayQuiet 901** 902** Description This function send Inventory command 903** 904** RW_I93_CMD_CMPL_EVT will be returned 905** 906** Returns NFC_STATUS_OK if success 907** NFC_STATUS_NO_BUFFERS if out of buffer 908** NFC_STATUS_BUSY if busy 909** NFC_STATUS_FAILED if other error 910** 911*******************************************************************************/ 912NFC_API extern tNFC_STATUS RW_I93StayQuiet (void); 913 914/******************************************************************************* 915** 916** Function RW_I93ReadSingleBlock 917** 918** Description This function send Read Single Block command 919** 920** RW_I93_RESPONSE_EVT will be returned 921** 922** Returns NFC_STATUS_OK if success 923** NFC_STATUS_NO_BUFFERS if out of buffer 924** NFC_STATUS_BUSY if busy 925** NFC_STATUS_FAILED if other error 926** 927*******************************************************************************/ 928NFC_API extern tNFC_STATUS RW_I93ReadSingleBlock (UINT8 block_number); 929 930/******************************************************************************* 931** 932** Function RW_I93WriteSingleBlock 933** 934** Description This function send Write Single Block command 935** Application must get block size first by calling RW_I93GetSysInfo(). 936** 937** RW_I93_CMD_CMPL_EVT will be returned 938** 939** Returns NFC_STATUS_OK if success 940** NFC_STATUS_NO_BUFFERS if out of buffer 941** NFC_STATUS_BUSY if busy 942** NFC_STATUS_FAILED if other error 943** 944*******************************************************************************/ 945NFC_API extern tNFC_STATUS RW_I93WriteSingleBlock (UINT8 block_number, 946 UINT8 *p_data); 947 948/******************************************************************************* 949** 950** Function RW_I93LockBlock 951** 952** Description This function send Lock Block command 953** 954** RW_I93_CMD_CMPL_EVT will be returned 955** 956** Returns NFC_STATUS_OK if success 957** NFC_STATUS_NO_BUFFERS if out of buffer 958** NFC_STATUS_BUSY if busy 959** NFC_STATUS_FAILED if other error 960** 961*******************************************************************************/ 962NFC_API extern tNFC_STATUS RW_I93LockBlock (UINT8 block_number); 963 964/******************************************************************************* 965** 966** Function RW_I93ReadMultipleBlocks 967** 968** Description This function send Read Multiple Blocks command 969** 970** RW_I93_RESPONSE_EVT will be returned 971** 972** Returns NFC_STATUS_OK if success 973** NFC_STATUS_NO_BUFFERS if out of buffer 974** NFC_STATUS_BUSY if busy 975** NFC_STATUS_FAILED if other error 976** 977*******************************************************************************/ 978NFC_API extern tNFC_STATUS RW_I93ReadMultipleBlocks (UINT8 first_block_number, 979 UINT16 number_blocks); 980 981/******************************************************************************* 982** 983** Function RW_I93WriteMultipleBlocks 984** 985** Description This function send Write Multiple Blocks command 986** 987** RW_I93_CMD_CMPL_EVT will be returned 988** 989** Returns NFC_STATUS_OK if success 990** NFC_STATUS_NO_BUFFERS if out of buffer 991** NFC_STATUS_BUSY if busy 992** NFC_STATUS_FAILED if other error 993** 994*******************************************************************************/ 995NFC_API extern tNFC_STATUS RW_I93WriteMultipleBlocks (UINT8 first_block_number, 996 UINT16 number_blocks, 997 UINT8 *p_data); 998 999/******************************************************************************* 1000** 1001** Function RW_I93Select 1002** 1003** Description This function send Select command 1004** 1005** UID[0]: 0xE0, MSB 1006** UID[1]: IC Mfg Code 1007** ... 1008** UID[7]: LSB 1009** 1010** RW_I93_CMD_CMPL_EVT will be returned 1011** 1012** Returns NFC_STATUS_OK if success 1013** NFC_STATUS_NO_BUFFERS if out of buffer 1014** NFC_STATUS_BUSY if busy 1015** NFC_STATUS_FAILED if other error 1016** 1017*******************************************************************************/ 1018NFC_API extern tNFC_STATUS RW_I93Select (UINT8 *p_uid); 1019 1020/******************************************************************************* 1021** 1022** Function RW_I93ResetToReady 1023** 1024** Description This function send Reset To Ready command 1025** 1026** RW_I93_CMD_CMPL_EVT will be returned 1027** 1028** Returns NFC_STATUS_OK if success 1029** NFC_STATUS_NO_BUFFERS if out of buffer 1030** NFC_STATUS_BUSY if busy 1031** NFC_STATUS_FAILED if other error 1032** 1033*******************************************************************************/ 1034NFC_API extern tNFC_STATUS RW_I93ResetToReady (void); 1035 1036/******************************************************************************* 1037** 1038** Function RW_I93WriteAFI 1039** 1040** Description This function send Write AFI command 1041** 1042** RW_I93_CMD_CMPL_EVT will be returned 1043** 1044** Returns NFC_STATUS_OK if success 1045** NFC_STATUS_NO_BUFFERS if out of buffer 1046** NFC_STATUS_BUSY if busy 1047** NFC_STATUS_FAILED if other error 1048** 1049*******************************************************************************/ 1050NFC_API extern tNFC_STATUS RW_I93WriteAFI (UINT8 afi); 1051 1052/******************************************************************************* 1053** 1054** Function RW_I93LockAFI 1055** 1056** Description This function send Lock AFI command 1057** 1058** RW_I93_CMD_CMPL_EVT will be returned 1059** 1060** Returns NFC_STATUS_OK if success 1061** NFC_STATUS_NO_BUFFERS if out of buffer 1062** NFC_STATUS_BUSY if busy 1063** NFC_STATUS_FAILED if other error 1064** 1065*******************************************************************************/ 1066NFC_API extern tNFC_STATUS RW_I93LockAFI (void); 1067 1068/******************************************************************************* 1069** 1070** Function RW_I93WriteDSFID 1071** 1072** Description This function send Write DSFID command 1073** 1074** RW_I93_CMD_CMPL_EVT will be returned 1075** 1076** Returns NFC_STATUS_OK if success 1077** NFC_STATUS_NO_BUFFERS if out of buffer 1078** NFC_STATUS_BUSY if busy 1079** NFC_STATUS_FAILED if other error 1080** 1081*******************************************************************************/ 1082NFC_API extern tNFC_STATUS RW_I93WriteDSFID (UINT8 dsfid); 1083 1084/******************************************************************************* 1085** 1086** Function RW_I93LockDSFID 1087** 1088** Description This function send Lock DSFID command 1089** 1090** RW_I93_CMD_CMPL_EVT will be returned 1091** 1092** Returns NFC_STATUS_OK if success 1093** NFC_STATUS_NO_BUFFERS if out of buffer 1094** NFC_STATUS_BUSY if busy 1095** NFC_STATUS_FAILED if other error 1096** 1097*******************************************************************************/ 1098NFC_API extern tNFC_STATUS RW_I93LockDSFID (void); 1099 1100/******************************************************************************* 1101** 1102** Function RW_I93GetSysInfo 1103** 1104** Description This function send Get System Information command 1105** If UID is provided then set UID[0]:MSB, ... UID[7]:LSB 1106** 1107** RW_I93_RESPONSE_EVT will be returned 1108** 1109** Returns NFC_STATUS_OK if success 1110** NFC_STATUS_NO_BUFFERS if out of buffer 1111** NFC_STATUS_BUSY if busy 1112** NFC_STATUS_FAILED if other error 1113** 1114*******************************************************************************/ 1115NFC_API extern tNFC_STATUS RW_I93GetSysInfo (UINT8 *p_uid); 1116 1117/******************************************************************************* 1118** 1119** Function RW_I93GetMultiBlockSecurityStatus 1120** 1121** Description This function send Get Multiple Block Security Status command 1122** 1123** RW_I93_RESPONSE_EVT will be returned 1124** 1125** Returns NFC_STATUS_OK if success 1126** NFC_STATUS_NO_BUFFERS if out of buffer 1127** NFC_STATUS_BUSY if busy 1128** NFC_STATUS_FAILED if other error 1129** 1130*******************************************************************************/ 1131NFC_API extern tNFC_STATUS RW_I93GetMultiBlockSecurityStatus (UINT8 first_block_number, 1132 UINT16 number_blocks); 1133 1134/******************************************************************************* 1135** 1136** Function RW_I93DetectNDef 1137** 1138** Description This function performs NDEF detection procedure 1139** 1140** RW_I93_NDEF_DETECT_EVT will be returned 1141** 1142** Returns NFC_STATUS_OK if success 1143** NFC_STATUS_FAILED if busy or other error 1144** 1145*******************************************************************************/ 1146NFC_API extern tNFC_STATUS RW_I93DetectNDef (void); 1147 1148/******************************************************************************* 1149** 1150** Function RW_I93ReadNDef 1151** 1152** Description This function performs NDEF read procedure 1153** Note: RW_I93DetectNDef() must be called before using this 1154** 1155** The following event will be returned 1156** RW_I93_NDEF_READ_EVT for each segmented NDEF message 1157** RW_I93_NDEF_READ_CPLT_EVT for the last segment or complete NDEF 1158** RW_I93_NDEF_READ_FAIL_EVT for failure 1159** 1160** Returns NFC_STATUS_OK if success 1161** NFC_STATUS_FAILED if I93 is busy or other error 1162** 1163*******************************************************************************/ 1164NFC_API extern tNFC_STATUS RW_I93ReadNDef (void); 1165 1166/******************************************************************************* 1167** 1168** Function RW_I93UpdateNDef 1169** 1170** Description This function performs NDEF update procedure 1171** Note: RW_I93DetectNDef() must be called before using this 1172** Updating data must not be removed until returning event 1173** 1174** The following event will be returned 1175** RW_I93_NDEF_UPDATE_CPLT_EVT for complete 1176** RW_I93_NDEF_UPDATE_FAIL_EVT for failure 1177** 1178** Returns NFC_STATUS_OK if success 1179** NFC_STATUS_FAILED if I93 is busy or other error 1180** 1181*******************************************************************************/ 1182NFC_API extern tNFC_STATUS RW_I93UpdateNDef (UINT16 length, UINT8 *p_data); 1183 1184/******************************************************************************* 1185** 1186** Function RW_I93FormatNDef 1187** 1188** Description This function performs formatting procedure 1189** 1190** RW_I93_FORMAT_CPLT_EVT will be returned 1191** 1192** Returns NFC_STATUS_OK if success 1193** NFC_STATUS_FAILED if busy or other error 1194** 1195*******************************************************************************/ 1196NFC_API extern tNFC_STATUS RW_I93FormatNDef (void); 1197 1198/******************************************************************************* 1199** 1200** Function RW_I93SetTagReadOnly 1201** 1202** Description This function performs NDEF read-only procedure 1203** Note: RW_I93DetectNDef() must be called before using this 1204** Updating data must not be removed until returning event 1205** 1206** The RW_I93_SET_TAG_RO_EVT event will be returned. 1207** 1208** Returns NFC_STATUS_OK if success 1209** NFC_STATUS_FAILED if I93 is busy or other error 1210** 1211*******************************************************************************/ 1212NFC_API extern tNFC_STATUS RW_I93SetTagReadOnly (void); 1213 1214/***************************************************************************** 1215** 1216** Function RW_I93PresenceCheck 1217** 1218** Description Check if the tag is still in the field. 1219** 1220** The RW_I93_PRESENCE_CHECK_EVT w/ status is used to indicate 1221** presence or non-presence. 1222** 1223** Returns NFC_STATUS_OK, if raw data frame sent 1224** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation 1225** NFC_STATUS_FAILED: other error 1226** 1227*****************************************************************************/ 1228NFC_API extern tNFC_STATUS RW_I93PresenceCheck (void); 1229 1230/******************************************************************************* 1231** 1232** Function RW_SendRawFrame 1233** 1234** Description This function sends a raw frame to the peer device. 1235** 1236** Returns tNFC_STATUS 1237** 1238*******************************************************************************/ 1239NFC_API extern tNFC_STATUS RW_SendRawFrame (UINT8 *p_raw_data, UINT16 data_len); 1240 1241/******************************************************************************* 1242** 1243** Function RW_SetActivatedTagType 1244** 1245** Description This function sets tag type for Reader/Writer mode. 1246** 1247** Returns tNFC_STATUS 1248** 1249*******************************************************************************/ 1250NFC_API extern tNFC_STATUS RW_SetActivatedTagType (tNFC_ACTIVATE_DEVT *p_activate_params, tRW_CBACK *p_cback); 1251 1252/******************************************************************************* 1253** 1254** Function RW_SetTraceLevel 1255** 1256** Description This function sets the trace level for Reader/Writer mode. 1257** If called with a value of 0xFF, 1258** it simply returns the current trace level. 1259** 1260** Returns The new or current trace level 1261** 1262*******************************************************************************/ 1263NFC_API extern UINT8 RW_SetTraceLevel (UINT8 new_level); 1264 1265#endif /* RW_API_H */ 1266