Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2009-2014 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This file contains the common data types shared by Reader/Writer mode
     22  *  and Card Emulation.
     23  *
     24  ******************************************************************************/
     25 
     26 #ifndef TAGS_INT_H
     27 #define TAGS_INT_H
     28 
     29 /******************************************************************************
     30 // T1T command and response definitions
     31 ******************************************************************************/
     32 
     33 typedef struct {
     34   uint8_t opcode;
     35   uint8_t cmd_len;
     36   uint8_t uid_offset;
     37   uint8_t rsp_len;
     38 } tT1T_CMD_RSP_INFO;
     39 
     40 typedef struct {
     41   uint8_t tag_model;
     42   uint8_t tms;
     43   uint8_t b_dynamic;
     44   uint8_t lock_tlv[3];
     45   uint8_t mem_tlv[3];
     46 } tT1T_INIT_TAG;
     47 
     48 typedef struct {
     49   uint8_t manufacturer_id;
     50   bool b_multi_version;
     51   uint8_t version_block;
     52   uint16_t version_no;
     53   uint16_t version_bmask;
     54   uint8_t b_calc_cc;
     55   uint8_t tms;
     56   bool b_otp;
     57   uint8_t default_lock_blpb;
     58 } tT2T_INIT_TAG;
     59 
     60 typedef struct {
     61   uint8_t opcode;
     62   uint8_t cmd_len;
     63   uint8_t rsp_len;
     64   uint8_t nack_rsp_len;
     65 } tT2T_CMD_RSP_INFO;
     66 
     67 extern const uint8_t
     68     t4t_v10_ndef_tag_aid[]; /* V1.0 Type 4 Tag Applicaiton ID */
     69 extern const uint8_t
     70     t4t_v20_ndef_tag_aid[]; /* V2.0 Type 4 Tag Applicaiton ID */
     71 
     72 extern const tT1T_CMD_RSP_INFO t1t_cmd_rsp_infos[];
     73 extern const tT1T_INIT_TAG t1t_init_content[];
     74 extern const tT1T_CMD_RSP_INFO* t1t_cmd_to_rsp_info(uint8_t opcode);
     75 extern const tT1T_INIT_TAG* t1t_tag_init_data(uint8_t tag_model);
     76 extern uint8_t t1t_info_to_evt(const tT1T_CMD_RSP_INFO* p_info);
     77 
     78 extern const tT2T_INIT_TAG* t2t_tag_init_data(uint8_t manufacturer_id,
     79                                               bool b_valid_ver,
     80                                               uint16_t version_no);
     81 extern const tT2T_CMD_RSP_INFO t2t_cmd_rsp_infos[];
     82 extern const tT2T_CMD_RSP_INFO* t2t_cmd_to_rsp_info(uint8_t opcode);
     83 extern uint8_t t2t_info_to_evt(const tT2T_CMD_RSP_INFO* p_info);
     84 
     85 extern const char* t1t_info_to_str(const tT1T_CMD_RSP_INFO* p_info);
     86 extern const char* t2t_info_to_str(const tT2T_CMD_RSP_INFO* p_info);
     87 extern int tags_pow(int x, int y);
     88 extern unsigned int tags_log2(register unsigned int x);
     89 
     90 #endif /* TAGS_INT_H */
     91