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