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 * 22 * This file contains the Near Field Communication (NFC) Card Emulation 23 * mode related API function external definitions. 24 * 25 ******************************************************************************/ 26 27#ifndef CE_API_H 28#define CE_API_H 29 30#include "tags_defs.h" 31 32#define CE_T3T_FIRST_EVT 0x60 33#define CE_T4T_FIRST_EVT 0x80 34 35enum 36{ 37 CE_T3T_NDEF_UPDATE_START_EVT = CE_T3T_FIRST_EVT, 38 CE_T3T_NDEF_UPDATE_CPLT_EVT, 39 CE_T3T_UPDATE_EVT, 40 CE_T3T_CHECK_EVT, 41 CE_T3T_RAW_FRAME_EVT, 42 CE_T3T_MAX_EVT, 43 44 CE_T4T_NDEF_UPDATE_START_EVT = CE_T4T_FIRST_EVT, 45 CE_T4T_NDEF_UPDATE_CPLT_EVT, 46 CE_T4T_NDEF_UPDATE_ABORT_EVT, 47 CE_T4T_RAW_FRAME_EVT, 48 CE_T4T_MAX_EVT 49}; 50 51 52#define CE_RAW_FRAME_EVT 0xFF 53 54typedef UINT8 tCE_EVENT; 55 56typedef struct 57{ 58 tNFC_STATUS status; 59 BT_HDR *p_data; 60} tCE_T2T_DATA; 61 62typedef struct 63{ 64 tNFC_STATUS status; 65 UINT8 *p_data; 66 BOOLEAN b_updated; 67 UINT32 length; 68} tCE_UPDATE_INFO; 69 70typedef struct 71{ 72 tNFC_STATUS status; 73 UINT8 aid_handle; 74 BT_HDR *p_data; 75} tCE_RAW_FRAME; 76 77typedef union 78{ 79 tNFC_STATUS status; 80 tCE_UPDATE_INFO update_info; 81 tCE_RAW_FRAME raw_frame; 82} tCE_DATA; 83 84typedef void (tCE_CBACK) (tCE_EVENT event, tCE_DATA *p_data); 85 86 87/* T4T definitions */ 88typedef UINT8 tCE_T4T_AID_HANDLE; /* Handle for AID registration */ 89#define CE_T4T_AID_HANDLE_INVALID 0xFF /* Invalid tCE_T4T_AID_HANDLE */ 90#define CE_T4T_WILDCARD_AID_HANDLE (CE_T4T_MAX_REG_AID) /* reserved handle for wildcard aid */ 91 92/******************************************************************************* 93** 94** Function CE_T3tSetLocalNDEFMsg 95** 96** Description Initialise CE Type 3 Tag with mandatory NDEF message 97** 98** Returns NFC_STATUS_OK if success 99** 100*******************************************************************************/ 101NFC_API extern tNFC_STATUS CE_T3tSetLocalNDEFMsg (BOOLEAN read_only, 102 UINT32 size_max, 103 UINT32 size_current, 104 UINT8 *p_buf, 105 UINT8 *p_scratch_buf); 106 107/******************************************************************************* 108** 109** Function CE_T3tSetLocalNDefParams 110** 111** Description Sets T3T-specific NDEF parameters. (Optional - if not 112** called, then CE will use default parameters) 113** 114** Returns NFC_STATUS_OK if success 115** 116*******************************************************************************/ 117NFC_API extern tNFC_STATUS CE_T3tSetLocalNDefParams (UINT8 nbr, UINT8 nbw); 118 119/******************************************************************************* 120** 121** Function CE_T3tSendCheckRsp 122** 123** Description Send CHECK response message 124** 125** Returns NFC_STATUS_OK if success 126** 127*******************************************************************************/ 128NFC_API extern tNFC_STATUS CE_T3tSendCheckRsp (UINT8 status1, UINT8 status2, UINT8 num_blocks, UINT8 *p_block_data); 129 130/******************************************************************************* 131** 132** Function CE_T3tSendUpdateRsp 133** 134** Description Send UPDATE response message 135** 136** Returns NFC_STATUS_OK if success 137** 138*******************************************************************************/ 139NFC_API extern tNFC_STATUS CE_T3tSendUpdateRsp (UINT8 status1, UINT8 status2); 140 141/******************************************************************************* 142** 143** Function CE_T4tSetLocalNDEFMsg 144** 145** Description Initialise CE Type 4 Tag with mandatory NDEF message 146** 147** The following event may be returned 148** CE_T4T_UPDATE_START_EVT for starting update 149** CE_T4T_UPDATE_CPLT_EVT for complete update 150** CE_T4T_UPDATE_ABORT_EVT for failure of update 151** CE_T4T_RAW_FRAME_EVT for raw frame 152** 153** read_only: TRUE if read only 154** ndef_msg_max: Max NDEF message size 155** ndef_msg_len: NDEF message size 156** p_ndef_msg: NDEF message (excluding NLEN) 157** p_scratch_buf: temp storage for update 158** 159** Returns NFC_STATUS_OK if success 160** 161*******************************************************************************/ 162NFC_API extern tNFC_STATUS CE_T4tSetLocalNDEFMsg (BOOLEAN read_only, 163 UINT16 ndef_msg_max, 164 UINT16 ndef_msg_len, 165 UINT8 *p_ndef_msg, 166 UINT8 *p_scratch_buf); 167 168/******************************************************************************* 169** 170** Function CE_T4tRegisterAID 171** 172** Description Register AID in CE T4T 173** 174** aid_len: length of AID (up to NFC_MAX_AID_LEN) 175** p_aid: AID 176** p_cback: Raw frame will be forwarded with CE_RAW_FRAME_EVT 177** 178** Returns tCE_T4T_AID_HANDLE if successful, 179** CE_T4T_AID_HANDLE_INVALID otherwisse 180** 181*******************************************************************************/ 182NFC_API extern tCE_T4T_AID_HANDLE CE_T4tRegisterAID (UINT8 aid_len, 183 UINT8 *p_aid, 184 tCE_CBACK *p_cback); 185 186/******************************************************************************* 187** 188** Function CE_T4tDeregisterAID 189** 190** Description Deregister AID in CE T4T 191** 192** aid_len: length of AID (up to NFC_MAX_AID_LEN) 193** p_aid: AID 194** 195** Returns NFC_STATUS_OK if success 196** 197*******************************************************************************/ 198NFC_API extern void CE_T4tDeregisterAID (tCE_T4T_AID_HANDLE aid_handle); 199 200/******************************************************************************* 201** 202** Function CE_T4TTestSetCC 203** 204** Description Set fields in Capability Container File for testing 205** 206** Returns NFC_STATUS_OK if success 207** 208*******************************************************************************/ 209NFC_API extern tNFC_STATUS CE_T4TTestSetCC (UINT16 cc_len, 210 UINT8 version, 211 UINT16 max_le, 212 UINT16 max_lc); 213 214/******************************************************************************* 215** 216** Function CE_T4TTestSetNDEFCtrlTLV 217** 218** Description Set fields in NDEF File Control TLV for testing 219** 220** Returns NFC_STATUS_OK if success 221** 222*******************************************************************************/ 223NFC_API extern tNFC_STATUS CE_T4TTestSetNDEFCtrlTLV (UINT8 type, 224 UINT8 length, 225 UINT16 file_id, 226 UINT16 max_file_size, 227 UINT8 read_access, 228 UINT8 write_access); 229 230/******************************************************************************* 231** 232** Function CE_SendRawFrame 233** 234** Description This function sends a raw frame to the peer device. 235** 236** Returns tNFC_STATUS 237** 238*******************************************************************************/ 239NFC_API extern tNFC_STATUS CE_SendRawFrame (UINT8 *p_raw_data, UINT16 data_len); 240 241/******************************************************************************* 242** 243** Function CE_SetActivatedTagType 244** 245** Description This function selects the tag type for Reader/Writer mode. 246** 247** Returns tNFC_STATUS 248** 249*******************************************************************************/ 250NFC_API extern tNFC_STATUS CE_SetActivatedTagType (tNFC_ACTIVATE_DEVT *p_activate_params, UINT16 t3t_system_code, tCE_CBACK *p_cback); 251 252/******************************************************************************* 253** 254** Function CE_SetTraceLevel 255** 256** Description This function sets the trace level for Card Emulation mode. 257** If called with a value of 0xFF, 258** it simply returns the current trace level. 259** 260** Returns The new or current trace level 261** 262*******************************************************************************/ 263NFC_API extern UINT8 CE_SetTraceLevel (UINT8 new_level); 264 265#endif /* CE_API_H */ 266