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 NCI transport internal definitions and functions. 22 * 23 ******************************************************************************/ 24 25 #ifndef NFC_HAL_INT_H 26 #define NFC_HAL_INT_H 27 28 #include "gki.h" 29 #include "nci_defs.h" 30 #include "nfc_brcm_defs.h" 31 #include "nfc_hal_api.h" 32 #include "nfc_hal_int_api.h" 33 #include "nfc_hal_target.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 /**************************************************************************** 40 ** NFC HAL TASK transport definitions 41 ****************************************************************************/ 42 /* NFC HAL Task event masks */ 43 #define NFC_HAL_TASK_EVT_DATA_RDY EVENT_MASK(APPL_EVT_0) 44 #define NFC_HAL_TASK_EVT_INITIALIZE EVENT_MASK(APPL_EVT_5) 45 #define NFC_HAL_TASK_EVT_TERMINATE EVENT_MASK(APPL_EVT_6) 46 #define NFC_HAL_TASK_EVT_POWER_CYCLE EVENT_MASK(APPL_EVT_7) 47 48 #define NFC_HAL_TASK_EVT_MBOX (TASK_MBOX_0_EVT_MASK) 49 50 /* NFC HAL Task mailbox definitions */ 51 #define NFC_HAL_TASK_MBOX (TASK_MBOX_0) 52 53 /* NFC HAL Task Timer events */ 54 #ifndef NFC_HAL_QUICK_TIMER_EVT_MASK 55 #define NFC_HAL_QUICK_TIMER_EVT_MASK (TIMER_0_EVT_MASK) 56 #endif 57 58 #ifndef NFC_HAL_QUICK_TIMER_ID 59 #define NFC_HAL_QUICK_TIMER_ID (TIMER_0) 60 #endif 61 62 /* NFC HAL Task Timer types */ 63 #define NFC_HAL_TTYPE_NCI_WAIT_RSP 0 64 #define NFC_HAL_TTYPE_POWER_CYCLE 1 65 #define NFC_HAL_TTYPE_NFCC_ENABLE 2 66 67 /* NFC HAL Task Wait Response flag */ 68 /* wait response on an NCI command */ 69 #define NFC_HAL_WAIT_RSP_CMD 0x10 70 /* wait response on an NCI vendor specific command */ 71 #define NFC_HAL_WAIT_RSP_VSC 0x20 72 /* wait response on a proprietary command */ 73 #define NFC_HAL_WAIT_RSP_PROP 0x40 74 /* not waiting for anything */ 75 #define NFC_HAL_WAIT_RSP_NONE 0x00 76 77 typedef uint8_t tNFC_HAL_WAIT_RSP; 78 79 #if (NFC_HAL_HCI_INCLUDED == TRUE) 80 81 typedef uint16_t tNFC_HAL_HCI_EVT; 82 83 #define NFC_HAL_HCI_PIPE_INFO_SIZE 5 84 85 #define NFC_HAL_HCI_ANY_SET_PARAMETER 0x01 86 #define NFC_HAL_HCI_ANY_GET_PARAMETER 0x02 87 #define NFC_HAL_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15 88 89 #define NFC_HAL_HCI_SESSION_IDENTITY_INDEX 0x01 90 #define NFC_HAL_HCI_WHITELIST_INDEX 0x03 91 92 #define NFC_HAL_HCI_ADMIN_PIPE 0x01 93 /* Host ID for UICC 0 */ 94 #define NFC_HAL_HCI_HOST_ID_UICC0 0x02 95 /* Host ID for UICC 1 */ 96 #define NFC_HAL_HCI_HOST_ID_UICC1 0x03 97 /* Host ID for UICC 2 */ 98 #define NFC_HAL_HCI_HOST_ID_UICC2 0x04 99 #define NFC_HAL_HCI_COMMAND_TYPE 0x00 100 #define NFC_HAL_HCI_RESPONSE_TYPE 0x02 101 102 /* NFC HAL HCI responses */ 103 #define NFC_HAL_HCI_ANY_OK 0x00 104 105 #endif 106 107 /* Flag defintions for tNFC_HAL_NVM */ 108 /* No NVM available */ 109 #define NFC_HAL_NVM_FLAGS_NO_NVM 0x01 110 /* FPM patch in NVM failed CRC check */ 111 #define NFC_HAL_NVM_FLAGS_LPM_BAD 0x02 112 /* LPM patch in NVM failed CRC check */ 113 #define NFC_HAL_NVM_FLAGS_FPM_BAD 0x04 114 /* Patch is present in NVM */ 115 #define NFC_HAL_NVM_FLAGS_PATCH_PRESENT 0x08 116 117 /* NFC HAL transport configuration */ 118 typedef struct { 119 bool shared_transport; /* TRUE if using shared HCI/NCI transport */ 120 uint8_t userial_baud; 121 uint8_t userial_fc; 122 } tNFC_HAL_TRANS_CFG; 123 124 #ifdef TESTER 125 /* For Insight, ncit_cfg is runtime-configurable */ 126 #define NFC_HAL_TRANS_CFG_QUALIFIER 127 #else 128 /* For all other platforms, ncit_cfg is constant */ 129 #define NFC_HAL_TRANS_CFG_QUALIFIER const 130 #endif 131 extern NFC_HAL_TRANS_CFG_QUALIFIER tNFC_HAL_TRANS_CFG nfc_hal_trans_cfg; 132 133 /***************************************************************************** 134 * BT HCI definitions 135 *****************************************************************************/ 136 137 /* Tranport message type */ 138 #define HCIT_TYPE_COMMAND 0x01 139 #define HCIT_TYPE_EVENT 0x04 140 #define HCIT_TYPE_NFC 0x10 141 142 /* Vendor-Specific BT HCI definitions */ 143 #define HCI_SUCCESS 0x00 144 #define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00 */ 145 #define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC) 146 #define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */ 147 #define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS) 148 #define HCI_COMMAND_COMPLETE_EVT 0x0E 149 #define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 12 150 #define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06 151 #define HCIE_PREAMBLE_SIZE 2 152 #define HCI_BRCM_PRE_SET_MEM (0x000C | HCI_GRP_VENDOR_SPECIFIC) 153 #define HCI_BRCM_PRE_SET_MEM_LENGTH 10 154 #define HCI_BRCM_PRE_SET_MEM_TYPE 8 155 156 /**************************************************************************** 157 ** Internal constants and definitions 158 ****************************************************************************/ 159 160 /* NFC HAL receiving states */ 161 enum { 162 NFC_HAL_RCV_IDLE_ST, /* waiting for packet type byte */ 163 NFC_HAL_RCV_NCI_MSG_ST, /* waiting for the first byte of NCI header */ 164 NFC_HAL_RCV_NCI_HDR_ST, /* reading NCI header */ 165 NFC_HAL_RCV_NCI_PAYLOAD_ST, /* reading NCI payload */ 166 NFC_HAL_RCV_BT_MSG_ST, /* waiting for the first byte of BT header */ 167 NFC_HAL_RCV_BT_HDR_ST, /* reading BT HCI header */ 168 NFC_HAL_RCV_BT_PAYLOAD_ST /* reading BT HCI payload */ 169 }; 170 171 /* errors during NCI packet reassembly process */ 172 #define NFC_HAL_NCI_RAS_TOO_BIG 0x01 173 #define NFC_HAL_NCI_RAS_ERROR 0x02 174 typedef uint8_t tNFC_HAL_NCI_RAS; 175 176 /* NFC HAL power mode */ 177 enum { 178 NFC_HAL_POWER_MODE_FULL, /* NFCC is full power mode */ 179 NFC_HAL_POWER_MODE_LAST 180 }; 181 typedef uint8_t tNFC_HAL_POWER_MODE; 182 183 /* NFC HAL event for low power mode */ 184 enum { 185 NFC_HAL_LP_TX_DATA_EVT, /* DH is sending data to NFCC */ 186 NFC_HAL_LP_RX_DATA_EVT, /* DH received data from NFCC */ 187 NFC_HAL_LP_TIMEOUT_EVT, /* Timeout */ 188 NFC_HAL_LP_LAST_EVT 189 }; 190 typedef uint8_t tNFC_HAL_LP_EVT; 191 192 #define NFC_HAL_ASSERT_NFC_WAKE 0x00 /* assert NFC_WAKE */ 193 #define NFC_HAL_DEASSERT_NFC_WAKE 0x01 /* deassert NFC_WAKE */ 194 195 #define NFC_HAL_BT_HCI_CMD_HDR_SIZE 3 /* opcode (2) + length (1) */ 196 #define NFC_HAL_CMD_TOUT (2000) /* timeout for NCI CMD (in ms) */ 197 198 #define NFC_HAL_SAVED_HDR_SIZE (2) 199 #define NFC_HAL_SAVED_CMD_SIZE (2) 200 201 #ifndef NFC_HAL_DEBUG 202 #define NFC_HAL_DEBUG TRUE 203 #endif 204 205 #if (NFC_HAL_DEBUG == TRUE) 206 extern const char* const nfc_hal_init_state_str[]; 207 #define NFC_HAL_SET_INIT_STATE(state) \ 208 HAL_TRACE_DEBUG3("init state: %d->%d(%s)", \ 209 nfc_hal_cb.dev_cb.initializing_state, state, \ 210 nfc_hal_init_state_str[state]); \ 211 nfc_hal_cb.dev_cb.initializing_state = state; 212 #else 213 #define NFC_HAL_SET_INIT_STATE(state) \ 214 nfc_hal_cb.dev_cb.initializing_state = state; 215 #endif 216 217 /* NFC HAL - NFCC initializing state */ 218 enum { 219 NFC_HAL_INIT_STATE_IDLE, /* Initialization is done */ 220 NFC_HAL_INIT_STATE_W4_XTAL_SET, /* Waiting for crystal setting rsp */ 221 NFC_HAL_INIT_STATE_POST_XTAL_SET, /* Waiting for reset ntf after xtal set */ 222 NFC_HAL_INIT_STATE_W4_NFCC_ENABLE, /* Waiting for reset ntf atter REG_PU up */ 223 NFC_HAL_INIT_STATE_W4_BUILD_INFO, /* Waiting for build info rsp */ 224 NFC_HAL_INIT_STATE_W4_PATCH_INFO, /* Waiting for patch info rsp */ 225 NFC_HAL_INIT_STATE_W4_APP_COMPLETE, /* Waiting for complete from application 226 */ 227 NFC_HAL_INIT_STATE_W4_POST_INIT_DONE, /* Waiting for complete of post init */ 228 NFC_HAL_INIT_STATE_W4_CONTROL_DONE, /* Waiting for control release */ 229 NFC_HAL_INIT_STATE_W4_PREDISCOVER_DONE, /* Waiting for complete of prediscover 230 */ 231 NFC_HAL_INIT_STATE_W4_NFCC_TURN_OFF, /* Waiting for NFCC to turn OFF */ 232 NFC_HAL_INIT_STATE_CLOSING /* Shutting down */ 233 }; 234 typedef uint8_t tNFC_HAL_INIT_STATE; 235 236 /* NFC HAL - NFCC config items during post initialization */ 237 enum { 238 NFC_HAL_DM_CONFIG_LPTD, 239 NFC_HAL_DM_CONFIG_PLL_325, 240 NFC_HAL_DM_CONFIG_START_UP, 241 NFC_HAL_DM_CONFIG_I93_DATA_RATE, 242 NFC_HAL_DM_CONFIG_FW_FSM, 243 NFC_HAL_DM_CONFIG_START_UP_VSC, 244 NFC_HAL_DM_CONFIG_NONE 245 }; 246 typedef uint8_t tNFC_HAL_DM_CONFIG; 247 248 /* callback function prototype */ 249 typedef struct { 250 uint16_t opcode; 251 uint16_t param_len; 252 uint8_t* p_param_buf; 253 } tNFC_HAL_BTVSC_CPLT; 254 255 typedef void(tNFC_HAL_BTVSC_CPLT_CBACK)(tNFC_HAL_BTVSC_CPLT* p1); 256 257 #if (NFC_HAL_HCI_INCLUDED == TRUE) 258 259 /* data type for NFC_HAL_HCI_RSP_NV_READ_EVT */ 260 typedef struct { 261 NFC_HDR hdr; 262 uint8_t block; 263 uint16_t size; 264 tHAL_NFC_STATUS status; 265 } tNFC_HAL_HCI_RSP_NV_READ_EVT; 266 267 /* data type for NFC_HAL_HCI_RSP_NV_WRITE_EVT */ 268 typedef struct { 269 NFC_HDR hdr; 270 tHAL_NFC_STATUS status; 271 } tNFC_HAL_HCI_RSP_NV_WRITE_EVT; 272 273 /* union of all event data types */ 274 typedef union { 275 NFC_HDR hdr; 276 /* Internal events */ 277 tNFC_HAL_HCI_RSP_NV_READ_EVT nv_read; 278 tNFC_HAL_HCI_RSP_NV_WRITE_EVT nv_write; 279 } tNFC_HAL_HCI_EVENT_DATA; 280 281 #endif 282 /***************************************************************************** 283 ** Control block for NFC HAL 284 *****************************************************************************/ 285 286 /* Patch RAM Download Control block */ 287 288 /* PRM states */ 289 enum { 290 NFC_HAL_PRM_ST_IDLE, 291 292 /* Secure patch download stated */ 293 NFC_HAL_PRM_ST_SPD_COMPARE_VERSION, 294 NFC_HAL_PRM_ST_SPD_GET_PATCH_HEADER, 295 NFC_HAL_PRM_ST_SPD_DOWNLOADING, 296 NFC_HAL_PRM_ST_SPD_AUTHENTICATING, 297 NFC_HAL_PRM_ST_SPD_AUTH_DONE, 298 NFC_HAL_PRM_ST_W4_GET_VERSION 299 }; 300 typedef uint8_t tNFC_HAL_PRM_STATE; 301 302 /* Maximum number of patches (currently 2: LPM and FPM) */ 303 #define NFC_HAL_PRM_MAX_PATCH_COUNT 2 304 #define NFC_HAL_PRM_PATCH_MASK_ALL 0xFFFFFFFF 305 #define NFC_HAL_PRM_MAX_CHIP_VER_LEN 8 306 307 /* Structures for PRM Control Block */ 308 typedef struct { 309 uint8_t power_mode; 310 uint16_t len; 311 } tNFC_HAL_PRM_PATCHDESC; 312 313 typedef struct { 314 tNFC_HAL_PRM_STATE state; /* download state */ 315 uint32_t flags; /* internal flags */ 316 uint16_t 317 cur_patch_len_remaining; /* bytes remaining in patchfile to process */ 318 const uint8_t* 319 p_cur_patch_data; /* pointer to patch currently being downloaded */ 320 uint16_t cur_patch_offset; /* offset of next byte to process */ 321 uint32_t dest_ram; 322 TIMER_LIST_ENT timer; /* Timer for patch download */ 323 void* p_param; /* general purpose param for PRM */ 324 uint8_t param_idx; /* information related to general purpose param*/ 325 326 /* Secure Patch Download */ 327 uint32_t 328 spd_patch_needed_mask; /* Mask of patches that need to be downloaded */ 329 uint8_t spd_patch_count; /* Number of patches left to download */ 330 uint8_t spd_cur_patch_idx; /* Current patch being downloaded */ 331 332 tNFC_HAL_PRM_PATCHDESC spd_patch_desc[NFC_HAL_PRM_MAX_PATCH_COUNT]; 333 334 /* I2C-patch */ 335 uint8_t* p_spd_patch; /* pointer to spd patch */ 336 uint16_t spd_patch_len_remaining; /* patch length */ 337 uint16_t spd_patch_offset; /* offset of next byte to process */ 338 339 tNFC_HAL_PRM_FORMAT format; /* format of patch ram */ 340 tNFC_HAL_PRM_CBACK* p_cback; /* Callback for download status notifications */ 341 uint32_t patchram_delay; /* the dealy after patch */ 342 } tNFC_HAL_PRM_CB; 343 344 /* Information about current patch in NVM */ 345 typedef struct { 346 uint16_t project_id; /* Current project_id of patch in nvm */ 347 uint16_t ver_major; /* Current major version of patch in nvm */ 348 uint16_t ver_minor; /* Current minor version of patch in nvm */ 349 uint16_t fpm_size; /* Current size of FPM patch in nvm */ 350 uint16_t lpm_size; /* Current size of LPM patch in nvm */ 351 uint8_t flags; /* See NFC_HAL_NVM_FLAGS_* flag definitions */ 352 uint8_t nvm_type; /* Current NVM Type - UICC/EEPROM */ 353 uint8_t chip_ver[NFC_HAL_PRM_MAX_CHIP_VER_LEN]; /* patch chip version */ 354 } tNFC_HAL_NVM; 355 356 /* Patch for I2C fix */ 357 typedef struct { 358 uint8_t* p_patch; /* patch for i2c fix */ 359 uint32_t prei2c_delay; /* the dealy after preI2C patch */ 360 uint16_t len; /* i2c patch length */ 361 } tNFC_HAL_PRM_I2C_FIX_CB; 362 363 /* Control block for NCI transport */ 364 typedef struct { 365 uint8_t nci_ctrl_size; /* Max size for NCI messages */ 366 uint8_t rcv_state; /* current rx state */ 367 uint16_t rcv_len; /* bytes remaining to be received in current rx state */ 368 NFC_HDR* p_rcv_msg; /* buffer to receive NCI message */ 369 NFC_HDR* p_frag_msg; /* fragmented NCI message; waiting for last fragment */ 370 NFC_HDR* 371 p_pend_cmd; /* pending NCI message; waiting for NFCC state to be free */ 372 tNFC_HAL_NCI_RAS nci_ras; /* nci reassembly error status */ 373 TIMER_LIST_ENT 374 nci_wait_rsp_timer; /* Timer for waiting for nci command response */ 375 tNFC_HAL_WAIT_RSP nci_wait_rsp; /* nci wait response flag */ 376 uint8_t 377 last_hdr[NFC_HAL_SAVED_HDR_SIZE]; /* part of last NCI command header */ 378 uint8_t 379 last_cmd[NFC_HAL_SAVED_CMD_SIZE]; /* part of last NCI command payload */ 380 void* p_vsc_cback; /* the callback function for last VSC command */ 381 } tNFC_HAL_NCIT_CB; 382 383 /* Control block for device initialization */ 384 typedef struct { 385 tNFC_HAL_INIT_STATE initializing_state; /* state of initializing NFCC */ 386 387 uint32_t brcm_hw_id; /* BRCM NFCC HW ID */ 388 tNFC_HAL_DM_CONFIG next_dm_config; /* next config in post initialization */ 389 uint8_t next_startup_vsc; /* next start-up VSC offset in post init */ 390 391 tNFC_HAL_POWER_MODE power_mode; /* NFCC power mode */ 392 uint8_t snooze_mode; /* current snooze mode */ 393 uint8_t new_snooze_mode; /* next snooze mode after receiving cmpl */ 394 uint8_t nfc_wake_active_mode; /* NFC_HAL_LP_ACTIVE_LOW/HIGH */ 395 TIMER_LIST_ENT lp_timer; /* timer for low power mode */ 396 397 tHAL_NFC_STATUS_CBACK* 398 p_prop_cback; /* callback to notify complete of proprietary update */ 399 } tNFC_HAL_DEV_CB; 400 401 #if (NFC_HAL_HCI_INCLUDED == TRUE) 402 403 /* data members for NFC_HAL-HCI */ 404 typedef struct { 405 TIMER_LIST_ENT 406 hci_timer; /* Timer to avoid indefinitely waiting for response */ 407 uint8_t* 408 p_hci_netwk_info_buf; /* Buffer for reading HCI Network information */ 409 uint8_t* p_hci_netwk_dh_info_buf; /* Buffer for reading HCI Network DH 410 information */ 411 uint8_t hci_netwk_config_block; /* Rsp awaiting for hci network configuration 412 block */ 413 bool b_wait_hcp_conn_create_rsp; /* Waiting for hcp connection create response 414 */ 415 bool clear_all_pipes_to_uicc1; /* UICC1 was restarted for patch download */ 416 bool update_session_id; /* Next response from NFCC is to Get Session id cmd */ 417 bool hci_fw_workaround; /* HAL HCI Workaround need */ 418 bool hci_fw_validate_netwk_cmd; /* Flag to indicate if hci network ntf to 419 validate */ 420 uint8_t hcp_conn_id; /* NCI Connection id for HCP */ 421 uint8_t dh_session_id[1]; /* Byte 0 of DH Session ID */ 422 } tNFC_HAL_HCI_CB; 423 424 #endif 425 426 #define NFC_HAL_FLAGS_NEED_DISABLE_VSC 0x01 427 typedef uint8_t tNFC_HAL_FLAGS; 428 429 typedef struct { 430 tHAL_NFC_CBACK* p_stack_cback; /* Callback for HAL event notification */ 431 tHAL_NFC_DATA_CBACK* p_data_cback; /* Callback for data event notification */ 432 433 TIMER_LIST_Q quick_timer_queue; /* timer list queue */ 434 TIMER_LIST_ENT timer; /* timer for NCI transport task */ 435 436 tNFC_HAL_NCIT_CB ncit_cb; /* NCI transport */ 437 tNFC_HAL_DEV_CB dev_cb; /* device initialization */ 438 tNFC_HAL_NVM nvm_cb; /* Information about current patch in NVM */ 439 440 /* Patchram control block */ 441 tNFC_HAL_PRM_CB prm; 442 tNFC_HAL_PRM_I2C_FIX_CB prm_i2c; 443 444 #if (NFC_HAL_HCI_INCLUDED == TRUE) 445 /* data members for NFC_HAL-HCI */ 446 tNFC_HAL_HCI_CB hci_cb; 447 #endif 448 449 uint8_t pre_discover_done; /* TRUE, when the prediscover config is complete */ 450 tNFC_HAL_FLAGS hal_flags; 451 uint8_t pre_set_mem_idx; 452 453 uint8_t max_rf_credits; /* NFC Max RF data credits */ 454 uint8_t max_ee; /* NFC Max number of NFCEE supported by NFCC */ 455 uint8_t trace_level; /* NFC HAL trace level */ 456 } tNFC_HAL_CB; 457 458 /* Global NCI data */ 459 extern tNFC_HAL_CB nfc_hal_cb; 460 461 extern uint8_t* p_nfc_hal_pre_discover_cfg; 462 463 /**************************************************************************** 464 ** Internal nfc functions 465 ****************************************************************************/ 466 467 /* From nfc_hal_main.c */ 468 uint32_t nfc_hal_main_task(uint32_t param); 469 void nfc_hal_main_init(void); 470 void nfc_hal_main_close(void); 471 void nfc_hal_main_pre_init_done(tHAL_NFC_STATUS); 472 void nfc_hal_main_exit_op_done(tNFC_HAL_NCI_EVT event, uint16_t data_len, 473 uint8_t* p_data); 474 void nfc_hal_main_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type, 475 uint32_t timeout); 476 void nfc_hal_main_stop_quick_timer(TIMER_LIST_ENT* p_tle); 477 void nfc_hal_main_send_error(tHAL_NFC_STATUS status); 478 void nfc_hal_send_nci_msg_to_nfc_task(NFC_HDR* p_msg); 479 480 /* nfc_hal_nci.c */ 481 bool nfc_hal_nci_receive_msg(uint8_t byte); 482 bool nfc_hal_nci_preproc_rx_nci_msg(NFC_HDR* p_msg); 483 NFC_HDR* nfc_hal_nci_postproc_rx_nci_msg(void); 484 void nfc_hal_nci_assemble_nci_msg(void); 485 void nfc_hal_nci_add_nfc_pkt_type(NFC_HDR* p_msg); 486 void nfc_hal_nci_send_cmd(NFC_HDR* p_buf); 487 void nfc_hal_nci_cmd_timeout_cback(void* p_tle); 488 489 /* nfc_hal_dm.c */ 490 void nfc_hal_dm_init(void); 491 void nfc_hal_dm_set_xtal_freq_index(void); 492 void nfc_hal_dm_set_power_level_zero(void); 493 void nfc_hal_dm_send_get_build_info_cmd(void); 494 void nfc_hal_dm_proc_msg_during_init(NFC_HDR* p_msg); 495 void nfc_hal_dm_proc_msg_during_exit(NFC_HDR* p_msg); 496 void nfc_hal_dm_config_nfcc(void); 497 void nfc_hal_dm_send_nci_cmd(const uint8_t* p_data, uint16_t len, 498 tNFC_HAL_NCI_CBACK* p_cback); 499 void nfc_hal_dm_send_bt_cmd(const uint8_t* p_data, uint16_t len, 500 tNFC_HAL_BTVSC_CPLT_CBACK* p_cback); 501 void nfc_hal_dm_set_nfc_wake(uint8_t cmd); 502 void nfc_hal_dm_pre_init_nfcc(void); 503 void nfc_hal_dm_shutting_down_nfcc(void); 504 bool nfc_hal_dm_power_mode_execute(tNFC_HAL_LP_EVT event); 505 void nfc_hal_dm_send_pend_cmd(void); 506 tHAL_NFC_STATUS nfc_hal_dm_set_config(uint8_t tlv_size, uint8_t* p_param_tlvs, 507 tNFC_HAL_NCI_CBACK* p_cback); 508 bool nfc_hal_dm_check_pre_set_mem(void); 509 tNFC_HAL_NCI_CBACK* nfc_hal_dm_got_vs_rsp(void); 510 511 /* nfc_hal_prm.c */ 512 void nfc_hal_prm_spd_reset_ntf(uint8_t reset_reason, uint8_t reset_type); 513 void nfc_hal_prm_nci_command_complete_cback(tNFC_HAL_NCI_EVT event, 514 uint16_t data_len, uint8_t* p_data); 515 void nfc_hal_prm_process_timeout(void* p_tle); 516 517 #if (NFC_HAL_HCI_INCLUDED == TRUE) 518 /* nfc_hal_hci.c */ 519 void nfc_hal_hci_enable(void); 520 void nfc_hal_hci_evt_hdlr(tNFC_HAL_HCI_EVENT_DATA* p_evt_data); 521 void nfc_hal_hci_handle_hci_netwk_info(uint8_t* p_data); 522 void nfc_hal_hci_handle_hcp_pkt_from_hc(uint8_t* p_data); 523 NFC_HDR* nfc_hal_hci_postproc_hcp(void); 524 bool nfc_hal_hci_handle_hcp_pkt_to_hc(uint8_t* p_data); 525 void nfc_hal_hci_timeout_cback(void* p_tle); 526 void nfc_hal_hci_handle_build_info(uint8_t chipverlen, uint8_t* p_chipverstr); 527 #else 528 #define nfc_hal_hci_enable() NFC_HAL_SET_INIT_STATE(NFC_HAL_INIT_STATE_IDLE); 529 #define nfc_hal_hci_handle_build_info(p, a) 530 #define nfc_hal_hci_evt_hdlr(p) ; 531 #endif 532 533 /* Define default NCI protocol trace function (if protocol tracing is enabled) 534 */ 535 #if (NFC_HAL_TRACE_PROTOCOL == TRUE) 536 #if !defined(DISP_NCI) 537 #define DISP_NCI (DispNci) 538 void DispNci(uint8_t* p, uint16_t len, bool is_recv); 539 #endif /* DISP_NCI */ 540 541 /* For displaying vendor-specific HCI commands */ 542 void DispHciCmd(NFC_HDR* p_buf); 543 void DispHciEvt(NFC_HDR* p_buf); 544 #endif /* NFC_HAL_TRACE_PROTOCOL */ 545 546 #ifdef __cplusplus 547 } 548 #endif 549 550 #endif /* NFC_HAL_INT_H */ 551