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