1/****************************************************************************** 2 * 3 * Copyright (C) 2009-2013 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 91/******************************************************************************* 92** 93** Function CE_T3tSetLocalNDEFMsg 94** 95** Description Initialise CE Type 3 Tag with mandatory NDEF message 96** 97** Returns NFC_STATUS_OK if success 98** 99*******************************************************************************/ 100NFC_API extern tNFC_STATUS CE_T3tSetLocalNDEFMsg (BOOLEAN read_only, 101 UINT32 size_max, 102 UINT32 size_current, 103 UINT8 *p_buf, 104 UINT8 *p_scratch_buf); 105 106/******************************************************************************* 107** 108** Function CE_T3tSetLocalNDefParams 109** 110** Description Sets T3T-specific NDEF parameters. (Optional - if not 111** called, then CE will use default parameters) 112** 113** Returns NFC_STATUS_OK if success 114** 115*******************************************************************************/ 116NFC_API extern tNFC_STATUS CE_T3tSetLocalNDefParams (UINT8 nbr, UINT8 nbw); 117 118/******************************************************************************* 119** 120** Function CE_T3tSendCheckRsp 121** 122** Description Send CHECK response message 123** 124** Returns NFC_STATUS_OK if success 125** 126*******************************************************************************/ 127NFC_API extern tNFC_STATUS CE_T3tSendCheckRsp (UINT8 status1, UINT8 status2, UINT8 num_blocks, UINT8 *p_block_data); 128 129/******************************************************************************* 130** 131** Function CE_T3tSendUpdateRsp 132** 133** Description Send UPDATE response message 134** 135** Returns NFC_STATUS_OK if success 136** 137*******************************************************************************/ 138NFC_API extern tNFC_STATUS CE_T3tSendUpdateRsp (UINT8 status1, UINT8 status2); 139 140/******************************************************************************* 141** 142** Function CE_T4tSetLocalNDEFMsg 143** 144** Description Initialise CE Type 4 Tag with mandatory NDEF message 145** 146** The following event may be returned 147** CE_T4T_UPDATE_START_EVT for starting update 148** CE_T4T_UPDATE_CPLT_EVT for complete update 149** CE_T4T_UPDATE_ABORT_EVT for failure of update 150** CE_T4T_RAW_FRAME_EVT for raw frame 151** 152** read_only: TRUE if read only 153** ndef_msg_max: Max NDEF message size 154** ndef_msg_len: NDEF message size 155** p_ndef_msg: NDEF message (excluding NLEN) 156** p_scratch_buf: temp storage for update 157** 158** Returns NFC_STATUS_OK if success 159** 160*******************************************************************************/ 161NFC_API extern tNFC_STATUS CE_T4tSetLocalNDEFMsg (BOOLEAN read_only, 162 UINT16 ndef_msg_max, 163 UINT16 ndef_msg_len, 164 UINT8 *p_ndef_msg, 165 UINT8 *p_scratch_buf); 166 167/******************************************************************************* 168** 169** Function CE_T4tRegisterAID 170** 171** Description Register AID in CE T4T 172** 173** aid_len: length of AID (up to NFC_MAX_AID_LEN) 174** p_aid: AID 175** p_cback: Raw frame will be forwarded with CE_RAW_FRAME_EVT 176** 177** Returns tCE_T4T_AID_HANDLE if successful, 178** CE_T4T_AID_HANDLE_INVALID otherwisse 179** 180*******************************************************************************/ 181NFC_API extern tCE_T4T_AID_HANDLE CE_T4tRegisterAID (UINT8 aid_len, 182 UINT8 *p_aid, 183 tCE_CBACK *p_cback); 184 185/******************************************************************************* 186** 187** Function CE_T4tDeregisterAID 188** 189** Description Deregister AID in CE T4T 190** 191** aid_len: length of AID (up to NFC_MAX_AID_LEN) 192** p_aid: AID 193** 194** Returns NFC_STATUS_OK if success 195** 196*******************************************************************************/ 197NFC_API extern void CE_T4tDeregisterAID (tCE_T4T_AID_HANDLE aid_handle); 198 199/******************************************************************************* 200** 201** Function CE_T4TTestSetCC 202** 203** Description Set fields in Capability Container File for testing 204** 205** Returns NFC_STATUS_OK if success 206** 207*******************************************************************************/ 208NFC_API extern tNFC_STATUS CE_T4TTestSetCC (UINT16 cc_len, 209 UINT8 version, 210 UINT16 max_le, 211 UINT16 max_lc); 212 213/******************************************************************************* 214** 215** Function CE_T4TTestSetNDEFCtrlTLV 216** 217** Description Set fields in NDEF File Control TLV for testing 218** 219** Returns NFC_STATUS_OK if success 220** 221*******************************************************************************/ 222NFC_API extern tNFC_STATUS CE_T4TTestSetNDEFCtrlTLV (UINT8 type, 223 UINT8 length, 224 UINT16 file_id, 225 UINT16 max_file_size, 226 UINT8 read_access, 227 UINT8 write_access); 228 229/******************************************************************************* 230** 231** Function CE_SendRawFrame 232** 233** Description This function sends a raw frame to the peer device. 234** 235** Returns tNFC_STATUS 236** 237*******************************************************************************/ 238NFC_API extern tNFC_STATUS CE_SendRawFrame (UINT8 *p_raw_data, UINT16 data_len); 239 240/******************************************************************************* 241** 242** Function CE_SetActivatedTagType 243** 244** Description This function selects the tag type for Reader/Writer mode. 245** 246** Returns tNFC_STATUS 247** 248*******************************************************************************/ 249NFC_API extern tNFC_STATUS CE_SetActivatedTagType (tNFC_ACTIVATE_DEVT *p_activate_params, UINT16 t3t_system_code, tCE_CBACK *p_cback); 250 251/******************************************************************************* 252** 253** Function CE_SetTraceLevel 254** 255** Description This function sets the trace level for Card Emulation mode. 256** If called with a value of 0xFF, 257** it simply returns the current trace level. 258** 259** Returns The new or current trace level 260** 261*******************************************************************************/ 262NFC_API extern UINT8 CE_SetTraceLevel (UINT8 new_level); 263 264#endif /* CE_API_H */ 265