mtk_nfc_ext_msg.h 26.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2008
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *   mtk_nfc_ext_msg.h
 *
 * Project:
 * --------
 * 
 *
 * Description:
 * ------------
 *   
 *
 *
 ****************************************************************************/
#ifndef _MTK_NFC_EXT_MSG_H_
#define _MTK_NFC_EXT_MSG_H_
 
//#include "nfc_osal.h"
 
#define MTK_NFC_SUCCESS    (0)
#define MTK_NFC_FAIL       (1)

//========================================================
//====Define NFC Service Handler Return Setting/Bitmap ===
//========================================================
#define MTK_NFC_DIS_NOTIF_DURATION      (500)

#define MIFARE4K_LEN        (16)
#define MIFARE1K_LEN        (4)
#define ISO15693_LEN        (4)

#define MIFARE1K_PAGE       (4)
#define MAX_UID_DATA_LEN    (10)
#define UID_DATA_LEN        (7)
#define TAG_RAW_DATA_LEN  (256) 

#define NDEF_DATA_LEN       (512)
#define RAW_COMM_DATA_LEN   (256) 
#define P2P_MAX_LENGTH      (256) //TBD
 
#define NFC_HEADER_LENGTH   (8)
#define ANTENNA_PARA_LEN    (4)

//Reader/card mode/Register_notification Bitmap
#define NOTI_MIFARE_UL     (1<<0)
#define NOTI_MIFARE_STD    (1<<1)
#define NOTI_ISO14443_4A    (1<<2)
#define NOTI_ISO14443_4B    (1<<3)
#define NOTI_JEWEL         (1<<4)
#define NOTI_NFC           (1<<5)
#define NOTI_FELICA        (1<<6)
#define NOTI_ISO15693      (1<<7)

//secure element bitmap
#define START_OF_TRANSACTION     (1<<0)
#define END_OF_TRANSACTION       (1<<1)
#define TRANSACTION              (1<<2)
#define RF_FIELD_ON              (1<<3)
#define RF_FIELD_OFF             (1<<4)
#define CONNECTIVITY             (1<<5)


//Discovery notification bitmap
#define DIS_ISO1443_4A                (1<<0)
#define DIS_ISO1443_4B                (1<<1)
#define DIS_FELICA_212                (1<<2)
#define DIS_FELICA_424                (1<<3)
#define DIS_ISO15693                  (1<<4)
#define DIS_NFC_ACTIVE                (1<<5)
#define DIS_DISCARD_CARD_EMULATION    (1<<6)
#define DIS_DISABLE_P2P_IP_TARGET     (1<<7)

//Tag detect indicator                                        
#define TAG_DETECTED              (0x01)                                        
#define TAG_NEDF_DETECTED         (0x02)
 
//NDEF store data type indicator
#define NDEF_STORE_TYPE_URL             (0x01)
#define NDEF_STORE_TYPE_TEXT            (0x02)
#define NDEF_STORE_TYPE_SMARTPOST       (0x03)

//P2P TARGET/INITATOR
#define P2P_TARGET           (0x01)
#define P2P_INITIATOR        (0x02)


 
typedef enum NFC_MSG_TYPE
{
   MSG_ID_NFC_SETTING_REQ,
   MSG_ID_NFC_SETTING_RSP,
   MSG_ID_NFC_NOTIFICATION_REQ,
   MSG_ID_NFC_NOTIFICATION_RSP,
   MSG_ID_NFC_SE_SET_REQ,
   MSG_ID_NFC_SE_SET_RSP,
   MSG_ID_NFC_DISCOVERY_REQ,
   MSG_ID_NFC_DISCOVERY_RSP,
   MSG_ID_NFC_TAG_DET_RSP,
   MSG_ID_NFC_P2P_DET_RSP,   
   MSG_ID_NFC_TAG_READ_REQ, //10
   MSG_ID_NFC_TAG_READ_RSP,
   MSG_ID_NFC_TAG_WRITE_REQ,
   MSG_ID_NFC_TAG_WRITE_RSP,
   MSG_ID_NFC_TAG_DISCONN_REQ,
   MSG_ID_NFC_TAG_DISCONN_RSP,
   MSG_ID_NFC_TAG_F2NDEF_REQ,
   MSG_ID_NFC_TAG_F2NDEF_RSP,
   MSG_ID_NFC_TAG_RAWCOM_REQ,
   MSG_ID_NFC_TAG_RAWCOM_RSP,
   MSG_ID_NFC_P2P_COMMUNICATION_REQ, //20
   MSG_ID_NFC_P2P_COMMUNICATION_RSP,
   MSG_ID_NFC_RD_COMMUNICATION_REQ,
   MSG_ID_NFC_RD_COMMUNICATION_RSP,
   MSG_ID_NFC_EM_TESTFUN_BEGIN,   // EM test function begin     //24
   /*************************************************************/
   // EM related message need add within this region  BEGIN
   /*************************************************************/
   MSG_ID_NFC_TX_ALWAYSON_TEST_REQ,
   MSG_ID_NFC_TX_ALWAYSON_TEST_RSP,
   MSG_ID_NFC_STOP_TX_ALWAYSON_TEST_REQ,
   MSG_ID_NFC_STOP_TX_ALWAYSON_TEST_RSP,
   MSG_ID_NFC_TX_ALWAYSON_WO_ACK_TEST_REQ,
   MSG_ID_NFC_TX_ALWAYSON_WO_ACK_TEST_RSP,
   MSG_ID_NFC_STOP_TX_ALWAYSON_WO_ACK_TEST_REQ, 
   MSG_ID_NFC_STOP_TX_ALWAYSON_WO_ACK_TEST_RSP,
   MSG_ID_NFC_CARD_EMULATION_MODE_TEST_REQ,
   MSG_ID_NFC_CARD_EMULATION_MODE_TEST_RSP,
   MSG_ID_NFC_READER_MODE_TEST_REQ,
   MSG_ID_NFC_READER_MODE_TEST_RSP,
   MSG_ID_NFC_P2P_MODE_TEST_REQ,
   MSG_ID_NFC_P2P_MODE_TEST_RSP,	
   MSG_ID_NFC_READER_MODE_DISCONN_REQ, //SY
   /*************************************************************/
   // EM related message need add within this region  END
   /*************************************************************/
   MSG_ID_NFC_EM_TESTFUN_END,       // EM test function end  //39
   //
   MSG_ID_NFC_FM_TESTFUN_BEGIN,       // FM test function begin 	//40
   /*************************************************************/
   // FM related message need add within this region  BEGIN
   /*************************************************************/
   MSG_ID_NFC_SWP_SELF_TEST_REQ,        /*NFC SWP self test request*/  
   MSG_ID_NFC_SWP_SELF_TEST_RSP,        /*NFC SWP self test response*/
   MSG_ID_NFC_ANTENNA_SELF_TEST_REQ,    /*NFC Antenna self test request*/
   MSG_ID_NFC_ANTENNA_SELF_TEST_RSP,    /*NFC Antenna self test response*/
   MSG_ID_NFC_TAG_UID_RW_REQ,           /*NFC Tag_Uid_read/write test request*/
   MSG_ID_NFC_TAG_UID_RW_RSP,	          /*NFC Tag_Uid_read/write test response*/
   MSG_ID_NFC_CARD_MODE_TEST_REQ,
   MSG_ID_NFC_CARD_MODE_TEST_RSP,
   MSG_ID_NFC_P2P_DISCONN_REQ,
   MSG_ID_NFC_P2P_DISCONN_RSP,
   /*************************************************************/
   // FM related message need add within this region  END
   /*************************************************************/
   MSG_ID_NFC_FM_TESTFUN_END,       // FM test function end //51
   MSG_ID_NFC_STOP_TEST_REQ,
   MSG_ID_NFC_STOP_TEST_RSP,
   MSG_ID_NFC_EXIT_EMFM,
   MSG_ID_NFC_END
}NFC_MSG_TYPE;

typedef enum
{
   SP_INVALID = -1,
   SP_SOFTWARE_STACK = 0,
   SP_RAW_DATA = 1,
}eSOFTWARE_PROTOCOL;

//======================================================
//====OP REQ/CNF parameters definition of NFC module====
//======================================================
#if !defined(LOCAL_PARA_HDR)
#define LOCAL_PARA_HDR              \
    kal_uint8    ref_count;         \
    kal_uint16   msg_len;
#endif

//======================================================
//====OP REQ/CNF parameters definition of NFC module====
//======================================================
 
/* The Interlayer Message structure, which is exchaged between modules. */

/* Tag TYPE */
typedef enum nfc_tag_type{
    nfc_tag_DEFAULT    = 0,
    nfc_tag_MIFARE_UL  = 1,
    nfc_tag_MIFARE_STD = 2,
    nfc_tag_ISO1443_4A = 3,
    nfc_tag_ISO1443_4B = 4,
    nfc_tag_JEWEL      = 5,
    nfc_tag_NFC        = 6, //P2P mode
    nfc_tag_FELICA     = 7,
    nfc_tag_ISO15693   = 8,
    nfc_NDEF           = 9
}nfc_tag_type;

typedef enum nfc_ndef_type{
    nfc_ndef_DEFAULT   = 0,
    nfc_ndef_URI       = 1,
    nfc_ndef_TEXT      = 2,
    nfc_ndef_SMART_POSTER = 3,
    nfc_ndef_VCARD     = 4,
    nfc_ndef_MEDIA     = 5,
    nfc_ndef_AbsoluteURI = 6, 
    nfc_ndef_ForumExternal = 7,    
    nfc_ndef_OTHERS    = 8
}nfc_ndef_type;

typedef enum nfc_p2p_type{
  nfc_p2p_DefaultP2PMode  =0x00U,
  nfc_p2p_Passive106      =0x01U,           
  nfc_p2p_Passive212      =0x02U,             
  nfc_p2p_Passive424      =0x04U,           
  nfc_p2p_Active          =0x08U,                 
  nfc_p2p_P2P_ALL         =0x0FU,                
  nfc_p2p_InvalidP2PMode  =0xFFU         
}nfc_p2p_type; 

typedef enum nfc_ndef_lang_type{
    nfc_ndef_lang_DEFAULT = 0,
    nfc_ndef_lang_DE = 1,
    nfc_ndef_lang_EN = 2,
    nfc_ndef_lang_FR = 3
}nfc_ndef_lang_type;

typedef enum ndef_url_type
{
    ndef_url_DEFAULT = 0,
    ndef_url_webaddr = 1,
    ndef_url_mailaddr = 2,
    ndef_url_tel = 3
}ndef_url_type;


typedef struct nfc_msg_struct {
	LOCAL_PARA_HDR
  unsigned int    msg_type;           /* message identifier */
  unsigned int    msg_length;         /* length of 'data' */
} nfc_msg_struct;


/*NFC Setting message structure*/
//nfc_setting_request
typedef struct nfc_setting_request {
  unsigned int    nfc_enable;               /* feature enable or disable , 0: disable, 1:enable */
  unsigned int    debug_enable;        /*debug enable or disable , 0: disable, 1:enable */
  unsigned int    sw_protocol;           /*SW protocol,  0: SW stack, 1: raw data mode */
 unsigned int     get_capabilities;      /*get chip capability 0: no request, 1: request*/       
} nfc_setting_request;
//nfc_setting_response
typedef struct nfc_setting_response {
 unsigned int     status;                        /* return setting result*/
  unsigned int    nfc_enable;               /* return feature enable or disable */
  unsigned int    debug_enable;        /* return debug enable or disable*/
  unsigned int    sw_protocol;           /* return SW protocol,*/
 unsigned int     get_capabilities;      /* return chip capability*/     
 unsigned int     sw_ver;                      /* return software version*/ 
 unsigned int     hw_ver;                     /* return hardware version*/
 unsigned int     fw_ver;                       /* return firmware version*/
 unsigned int     reader_mode;          /* return support  format bitmap*/
 unsigned int     card_mode;              /* return support  format bitmap */
} nfc_setting_response;

/*NFC Register Notification*/
//nfc_reg_notification_request
typedef struct nfc_reg_notif_request{
  unsigned int    reg_type;               /* register notification bitmap */       
} nfc_reg_notif_request;

//nfc_reg_notification_response
typedef struct nfc_reg_notif_response{
unsigned int     status;          /* return setting result,0 success, other: fail*/
unsigned int     se;                /* secure element detect, 0: no detect, 1: se typ1 , 2: se type 2*/
unsigned int     se_status; /* secure element status, 0:off, 1:Virtual, 2:Wired*/
unsigned int     se_type;      /* secure element type, bitmap*/
unsigned int length; /* length of data*/
} nfc_reg_notif_response;

/*NFC Secure Element*/
//nfc_se_set_request
typedef struct nfc_se_set_request{
  unsigned int     set_SEtype;      /* setting se  type, 0:off, 1:Virtual, 2:Wired */
} nfc_se_set_request;

//nfc_se_set_response
typedef struct nfc_se_set_response{
unsigned int     status;          /* return setting result, 0:sucess*/
} nfc_se_set_response;


/*NFC Discovery Notification*/
//nfc_dis_notification_request
typedef struct nfc_dis_notif_request{
  unsigned int    dis_type;               /* discovery notification bitmap */
  unsigned int duration;                 /* set duration,(unit:ms) */       
} nfc_dis_notif_request;

/*NFC Tag Detected Response*/
//nfc_tag_det_response
typedef struct nfc_tag_det_response{
  unsigned int    tag_type;               /* return detected tag type*/
  unsigned int    card_type;            /* card type, 1: Mifare classic 1K*/
                                                              /* 2: Mifare classic 4K*/
                                                              /* 3: NDEF*/
  unsigned char   uid[MAX_UID_DATA_LEN];                        /* card Uid*/
  unsigned int    sak;                       /* card sak*/             
  unsigned int    atag;                    /* card atag*/
  unsigned int    appdata;             /* card appdata */
  unsigned int    maxdatarate;    /* card maxdatarate */
} nfc_tag_det_response;

/*NFC Tag Read Request*/
//nfc_tag_read_request
typedef struct nfc_tag_read_request{
  nfc_tag_type    read_type;              /*  which type want to read*/            
  unsigned int    sector;                 /* for Mifare STD used*/
  unsigned int    block;                  /* for Mifare STD/MifareUL/ISO15693 used*/
  unsigned char   AuthentificationKey;    /* for Mifare STD, KEY_A:0 , KEY_B:1 */
} nfc_tag_read_request;

/*NFC Peer to Peer Detected Response*/
//nfc_p2p_det_response
typedef struct nfc_p2p_det_response{
  unsigned int    p2p_type;               /* return detected tag type*/
} nfc_p2p_det_response;

typedef union nfc_dis_notif_result_response_u{
  nfc_tag_det_response nfc_tag_det_resp;
  nfc_p2p_det_response nfc_p2p_det_resp;  
}nfc_dis_notif_result_response_u;

//nfc_dis_notification_response
typedef struct nfc_dis_notif_response{
  unsigned int     status;          /* return setting result, 0:sucess */
  unsigned char    type;           /*1 : Tag ,2: p2p */
  nfc_dis_notif_result_response_u nfc_dis_notif_result;
} nfc_dis_notif_response;

typedef struct nfc_tag_read_Mifare {
  unsigned int    Length;
  unsigned char   data[MIFARE4K_LEN];    
} nfc_tag_read_Mifare;

typedef struct nfc_tag_read_ndef {
  nfc_ndef_type  ndef_type;
  unsigned  char lang[3];
  unsigned  char recordFlags;
  unsigned  char recordId[32];
  unsigned  char recordTnf;
  unsigned  int  length;      
  unsigned  char data[NDEF_DATA_LEN];
} nfc_tag_read_ndef;

typedef struct nfc_tag_read_ISO15693{
  unsigned int  Length;
  unsigned char data[ISO15693_LEN];
} nfc_tag_read_ISO15693;

typedef union nfc_tag_read_result_response_u{
   nfc_tag_read_Mifare nfc_tag_read_Mifare_resp;
   nfc_tag_read_ndef nfc_tag_read_ndef_resp;
   nfc_tag_read_ISO15693 nfc_tag_read_ISO15693_resp;
}nfc_tag_read_result_response_u;

/*NFC Tag Read Response*/
//nfc_tag_read_response
typedef struct nfc_tag_read_response{
  unsigned int    status;               /*  return read status, 0 success*/
  nfc_tag_type    type;                 /*  Check nfc_tag_type */
  nfc_tag_read_result_response_u nfc_tag_read_result;
} nfc_tag_read_response;

/*NFC Tag Write Request*/
typedef struct nfc_tag_write_typeMifare{
  unsigned int    sector;               /* Mifare STD */
  unsigned int    block;                /* Mifare STD, Mifare UL */
  unsigned int    length;               /* Mifare STD, Mifare UL */
  unsigned char   data[MIFARE4K_LEN];   /* Mifare STD, Mifare UL */
  unsigned char   AuthentificationKey;  /* Mifare STD, Mifare UL,KEY_A:0 , KEY_B:1 */
} nfc_tag_write_typeMifare;

typedef struct nfc_tag_write_typeISO15693{
  unsigned int    block;
  unsigned int    length;
  unsigned char   data[ISO15693_LEN];
} nfc_tag_write_typeISO15693;

typedef struct Vcard
{
    char Name[64];
    char Compagny[64];
    char Titlep[64];
    char Tel[32];
    char Email[64];
    char Adress[128];
    char PostalCode[32];
    char City[64];
    char CompagnyUrl[64];
}Vcard_t;

typedef struct SmartPoster
{
	unsigned char  Compagny[64];
	unsigned short CompagnyLength;
    unsigned char CompagnyUrl[64];
    unsigned short CompagnyUrlLength;
}SmartPoster_t;

typedef struct Text
{
	unsigned char data[128];
    unsigned short DataLength;
}Text_t;

typedef struct URL
{
    ndef_url_type URLtype;
	unsigned char URLData[64];
    unsigned short URLLength;
}URL_t;

typedef struct EXTTag
{
    char EXTTagType[64];
    char EXTData[128];
    unsigned short EXTLength;
}EXTTag_t;


typedef union nfc_tag_write_ndef_data
{
    SmartPoster_t  SP_Data;
    Vcard_t        VC_Data;
    Text_t         TX_Data;
    URL_t          URL_Data;
    EXTTag_t       EXT_Data;
}nfc_tag_write_ndef_data;

typedef struct nfc_tag_write_ndef{
  nfc_ndef_type      ndef_type;
  nfc_ndef_lang_type language;
  unsigned  int  length;
  nfc_tag_write_ndef_data ndef_data;
} nfc_tag_write_ndef;

typedef union nfc_tag_write_data_request_u{
  nfc_tag_write_typeMifare   nfc_tag_write_typeMifare_data;
  nfc_tag_write_typeISO15693 nfc_tag_write_typeISO15693_data;
  nfc_tag_write_ndef   nfc_tag_write_ndef_data;
}nfc_tag_write_data_request_u;



//nfc_tag_write_request
typedef struct nfc_tag_write_request{
  nfc_tag_type    write_type;               /*  which type want to write*/
  nfc_tag_write_data_request_u  nfc_tag_write_data;
} nfc_tag_write_request;

/*NFC Tag Write Response*/
//nfc_tag_write_response
typedef struct nfc_tag_write_response{
  nfc_tag_type    type;      /*  return writed type*/
  unsigned int    status;                /*  return read status, 0 success*/               
} nfc_tag_write_response;

/*NFC Tag Disconnect Request*/
//nfc_tag_disconnect_request
typedef struct nfc_tag_disconnect_request{
  unsigned int    action;     /* 1: disconnect, */
} nfc_tag_disconnect_request;
/*NFC Tag Disconnect Response*/
//nfc_tag_disconnect_response
typedef struct nfc_tag_disconnect_response{
  unsigned int    status;      /*0: success*/
} nfc_tag_disconnect_response;

/*NFC Tag format tp Ndef format Request*/
//nfc_tag_format2Ndef_request
typedef struct nfc_tag_fromat2Ndef_request{
  unsigned int    action;      /* 1: format to Ndef, */
} nfc_tag_fromat2Ndef_request;
/*NFC Tag Disconnect Response*/
//nfc_tag_format2Ndef_response
typedef struct nfc_tag_fromat2Ndef_response{
  unsigned int    status;      /*0: success*/ 
} nfc_tag_fromat2Ndef_response;

/*NFC Tag raw command Request*/
//nfc_tag_raw_com_request
typedef struct nfc_tag_raw_com_request{
  nfc_tag_type    type;        /*Type A / Type B/ Jewel/ Felica*/
  unsigned int    length;     /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer in the smart phone*/
  unsigned char   data[TAG_RAW_DATA_LEN];
} nfc_tag_raw_com_request;
/*NFC Tag Disconnect Response*/
//nfc_tag_raw_com_response
typedef struct nfc_tag_raw_com_response{
  nfc_tag_type    type;        /*Type A / Type B/ Jewel/ Felica*/
  unsigned int    status;       /*0 : success*/        
  unsigned int    length;  
  unsigned char   data[TAG_RAW_DATA_LEN];
} nfc_tag_raw_com_response;

// Need to check the length and data behavior
/*NFC Peer to Peer communication*/
//nfc_p2p_com_request
typedef struct nfc_p2p_com_request{
  unsigned int    action;       /* 1 : send, 2 receive*/
  unsigned int    length;      /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer in the smart phone*/
  unsigned char   data[P2P_MAX_LENGTH];
} nfc_p2p_com_request;

//nfc_p2p_com_response
typedef struct nfc_p2p_com_response{
  unsigned int    status;   /* 0:success*/
  unsigned int    length;   /*Length of written data. Unit is byte.*/
  unsigned char   data[P2P_MAX_LENGTH];
} nfc_p2p_com_response;


/*NFC raw data communication*/
//nfc_rd_com_request
typedef struct nfc_rd_com_request{
  unsigned int    action;      /*1:start test, 0:stop test*/
  unsigned int    length;      /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer in the smart phone*/
} nfc_rd_com_request;

//nfc_rd_com_response
typedef struct nfc_rd_com_response{
  unsigned int    status; /*Test result, 0:success*/
  unsigned int    length;   /*Length of written data. Unit is byte.*/
} nfc_rd_com_response;


/*NFC test mode*/
/*for EM, FM, AT command struct*/
//nfc_script_request
typedef struct nfc_script_request{
   unsigned int   type;                /*Test type: currently, always set 1*/
   unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/   
   unsigned int   sessionID;             /*message sequece*/
}nfc_script_request;

//nfc_script_reponse 
typedef struct nfc_script_response{
   signed int   result;         /*Test result,0 :success*/	
   unsigned int   sessionID; 
}nfc_script_response;

/*for META struct*/
//nfc_script_request
typedef struct nfc_meta_script_request{
   unsigned int   type;                /*Test type: currently, always set 1*/
   unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/   
}nfc_meta_script_request;

//nfc_script_reponse 
typedef struct nfc_meta_script_response{
   signed int   result;         /*Test result,0 :success*/	
}nfc_meta_script_response;


/*NFC test mode*/
//nfc_script_request
typedef struct nfc_script_uid_request{
   unsigned int   type;                /*Test type: currently, always set 1*/
   unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/
   unsigned int   sessionID; 
   unsigned int   uid_type;        /* 1: uid 4bytes, 2 : uid 7bytes*/    
   unsigned int   uid_length;        /* uid length*/    
   unsigned char  data[MAX_UID_DATA_LEN];       /*uid content*/
}nfc_script_uid_request;
//nfc_script_reponse 
typedef struct nfc_script_uid_response{
   signed int   result;                 /*Test result, 0: success*/
   unsigned int   sessionID; 
   unsigned int uid_type;         /* 1: uid 4bytes, 2 : uid 7bytes */	
   unsigned int  uid_length;         	   /* uid length*/
   unsigned char data[MAX_UID_DATA_LEN];      /*uid content*/
}nfc_script_uid_response;


//nfc_script_request
typedef struct nfc_meta_script_uid_request{
   unsigned int   type;                /*Test type: currently, always set 1*/
   unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/
   unsigned int   uid_length;           /* uid length*/    
   unsigned char  data[MAX_UID_DATA_LEN];       /*uid content*/
}nfc_meta_script_uid_request;
//nfc_script_reponse 
typedef struct nfc_meta_script_uid_response{
   signed int   result;                 /*Test result, 0: success*/
   unsigned int  uid_length;             /* uid length*/
   unsigned char data[MAX_UID_DATA_LEN];      /*uid content*/
}nfc_meta_script_uid_response;


typedef struct nfc_tx_alwayson_request{ 
unsigned int   type;    /*Test type: currently, always set 1*/
unsigned int   action;	/*Test action, 1: start test, 0:stop test*/  
unsigned int   sessionID;  
unsigned char  modulation_type;   /* 0:type A, 1:type B, 2:type F, 3:No Modulation */
unsigned char  bitrate;           /* 0:106kbps, 1:212kbps, 2:424kbps */ 
} nfc_tx_alwayson_request;

/*for META struct*/
typedef struct nfc_meta_tx_alwayson_request{ 
unsigned int   type;    /*Test type: currently, always set 1*/
unsigned int   action;	/*Test action, 1: start test, 0:stop test*/   
unsigned char  modulation_type;   /* 0:type A, 1:type B, 2:type F, 3:No Modulation */
unsigned char  bitrate;           /* 0:106kbps, 1:212kbps, 2:424kbps */ 
} nfc_meta_tx_alwayson_request;

typedef struct nfc_p2p_request { 
unsigned int   type;           /*Test type: currently, always set 1*/
unsigned int   action;        /*Test action, 1: start test, 0:stop test*/  
unsigned int   sessionID; 
unsigned int   protocols;     /*use Discovery notification bitmap */
unsigned int   P2Pmode;     /*P2P mode bitmap*/
}nfc_p2p_request;

typedef struct nfc_card_emulation_request { 
unsigned int   type;           /*Test type: currently, always set 1*/
unsigned int   action;	       /*Test action, 1: start test, 0:stop test*/  
unsigned int   sessionID; 
}nfc_card_emulation_request;

typedef struct nfc_meta_card_emulation_request { 
unsigned int   type;           /*Test type: currently, always set 1*/
unsigned int   action;	       /*Test action, 1: start test, 0:stop test*/  
unsigned short  technology;    /*bitmask: MifareUL=bit 0, MifareStd=bit1, ISO14443_4A=bit 2, ISO14443_4B=bit 3, Jewel=bit 4, Felica=bit 5, ISO15693=bit 6 */
unsigned short  protocols;     /*bitmask: Iso14443A=bit 0, Iso14443B=bit 1, Felica212=bit 2, Felica424=bit 3, Iso15693=bit 4 */ 
}nfc_meta_card_emulation_request;

typedef struct nfc_reader_mode_request { 
unsigned int   type;           /*Test type: currently, always set 1*/
unsigned int   action;        /*Test action, 1: start test, 0:stop test*/  
unsigned int   sessionID; 
unsigned int   protocols;     /*use Discovery notification bitmap */
}nfc_reader_mode_request;

typedef struct nfc_antenna_request{
   unsigned int   type;                /*Test type: currently, always set 1*/
   unsigned int   action;              /*Test action, 1: start test, 0:stop test*/  
   unsigned int   sessionID; 
   unsigned char  param[ANTENNA_PARA_LEN];       /*antenna para*/ 
}nfc_antenna_request;

typedef struct
{
    unsigned int action; /*1: disconnect*/
}nfc_p2p_disconnect_request;

typedef struct
{
    unsigned int status; /*0: success*/
}nfc_p2p_disconnect_response;

typedef struct
{
    LOCAL_PARA_HDR
    kal_int32 action;   // 1:On, 0:Off
} nfc_init_deinit_req_struct;

typedef struct 
{
    LOCAL_PARA_HDR
    kal_int32 action_result;  // 1:OK, 0:NG
    kal_int32 error_code;     // reserved for future using
} nfc_init_deinit_rsp_struct;

/* NFC callback event to notify MMI */
typedef enum {
    NFC_MMI_NOTIFY_EVENT_NFC_OFF = 0,
    NFC_MMI_NOTIFY_EVENT_NFC_ON,
    NFC_MMI_NOTIFY_EVENT_RESERVE
} NFC_MMI_NOTIFY_EVENT;

typedef struct 
{
    LOCAL_PARA_HDR
    NFC_MMI_NOTIFY_EVENT event;
} nfc_mmi_notify_event_struct;

typedef struct
{
    unsigned int type; /*0:  EM normal exit,1: EM background exit, 2: FM exit*/
}nfc_exit_request;


typedef struct nfc_status{
   unsigned int nfc_state;              /* feature enable or disable , 0: disable, 1:enable */
   unsigned int nfc_debug_state;        /*debug enable or disable , 0: disable, 1:enable */
   unsigned int nfc_protocol_state;     /*SW protocol,  0: SW stack, 1: raw data mode */
   unsigned int nfc_capabilities_state; /*chip capability 0: no request, 1: request*/ 
}nfc_status;


//********************************************************//
//Function Protocol
//********************************************************//
int NFC_STATUS_QUERY(nfc_status *s_nfc_status);

#endif /* _MTK_NFC_EXT_MSG_H_ */