nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 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 | * |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 20 | * The original Work has been changed by NXP. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 21 | * |
| 22 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 23 | * you may not use this file except in compliance with the License. |
| 24 | * You may obtain a copy of the License at |
| 25 | * |
| 26 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 27 | * |
| 28 | * Unless required by applicable law or agreed to in writing, software |
| 29 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 30 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 31 | * See the License for the specific language governing permissions and |
| 32 | * limitations under the License. |
| 33 | * |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 34 | * Copyright 2018 NXP |
| 35 | * |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 36 | ******************************************************************************/ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 37 | /****************************************************************************** |
| 38 | * |
| 39 | * this file contains the main NFC Upper Layer internal definitions and |
| 40 | * functions. |
| 41 | * |
| 42 | ******************************************************************************/ |
| 43 | |
| 44 | #ifndef NFC_INT_H_ |
| 45 | #define NFC_INT_H_ |
| 46 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 47 | #include "gki.h" |
| 48 | #include "nci_defs.h" |
| 49 | #include "nfc_api.h" |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 50 | #include "nfc_target.h" |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 51 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 52 | /**************************************************************************** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 53 | ** Internal NFC constants and definitions |
| 54 | ****************************************************************************/ |
| 55 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 56 | /**************************************************************************** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 57 | ** NFC_TASK definitions |
| 58 | ****************************************************************************/ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 59 | |
| 60 | /* NFC_TASK event masks */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 61 | #define NFC_TASK_EVT_TRANSPORT_READY EVENT_MASK(APPL_EVT_0) |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 62 | |
| 63 | /* NFC Timer events */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 64 | #define NFC_TTYPE_NCI_WAIT_RSP 0 |
| 65 | #define NFC_TTYPE_WAIT_2_DEACTIVATE 1 |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 66 | #define NFC_WAIT_RSP_RAW_VS 0x02 |
| 67 | #define NFC_TTYPE_WAIT_MODE_SET_NTF 2 |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 68 | #if (NXP_EXTNS == TRUE) |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 69 | #define NFC_TTYPE_NCI_WAIT_DATA_NTF 3 |
nxpandroid | 6154b73 | 2016-01-14 20:39:23 +0530 | [diff] [blame] | 70 | #endif |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 71 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 72 | #define NFC_TTYPE_LLCP_LINK_MANAGER 100 |
| 73 | #define NFC_TTYPE_LLCP_LINK_INACT 101 |
| 74 | #define NFC_TTYPE_LLCP_DATA_LINK 102 |
| 75 | #define NFC_TTYPE_LLCP_DELAY_FIRST_PDU 103 |
| 76 | #define NFC_TTYPE_RW_T1T_RESPONSE 104 |
| 77 | #define NFC_TTYPE_RW_T2T_RESPONSE 105 |
| 78 | #define NFC_TTYPE_RW_T3T_RESPONSE 106 |
| 79 | #define NFC_TTYPE_RW_T4T_RESPONSE 107 |
| 80 | #define NFC_TTYPE_RW_I93_RESPONSE 108 |
| 81 | #define NFC_TTYPE_CE_T4T_UPDATE 109 |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 82 | /* added for p2p prio logic timer */ |
| 83 | #define NFC_TTYPE_P2P_PRIO_RESPONSE 110 |
| 84 | /* added for p2p prio logic clenaup */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 85 | #define NFC_TTYPE_P2P_PRIO_LOGIC_CLEANUP 111 |
| 86 | /* time out for mode set notification */ |
| 87 | #define NFC_MODE_SET_NTF_TIMEOUT 2 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 88 | /* NFC Task event messages */ |
| 89 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 90 | enum { |
| 91 | NFC_STATE_NONE, /* not start up yet */ |
| 92 | NFC_STATE_W4_HAL_OPEN, /* waiting for HAL_NFC_OPEN_CPLT_EVT */ |
| 93 | NFC_STATE_CORE_INIT, /* sending CORE_RESET and CORE_INIT */ |
| 94 | NFC_STATE_W4_POST_INIT_CPLT, /* waiting for HAL_NFC_POST_INIT_CPLT_EVT */ |
| 95 | NFC_STATE_IDLE, /* normal operation (discovery state) */ |
| 96 | NFC_STATE_OPEN, /* NFC link is activated */ |
| 97 | NFC_STATE_CLOSING, /* de-activating */ |
| 98 | NFC_STATE_W4_HAL_CLOSE, /* waiting for HAL_NFC_POST_INIT_CPLT_EVT */ |
| 99 | NFC_STATE_NFCC_POWER_OFF_SLEEP /* NFCC is power-off sleep mode */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 100 | }; |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 101 | typedef uint8_t tNFC_STATE; |
nxpandroid | cdd3044 | 2016-05-27 17:26:18 +0530 | [diff] [blame] | 102 | |
| 103 | /* DM P2P Priority event type */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 104 | enum { |
| 105 | NFA_DM_P2P_PRIO_RSP = 0x01, /* P2P priority event from RSP */ |
| 106 | NFA_DM_P2P_PRIO_NTF /* P2P priority event from NTF */ |
nxpandroid | cdd3044 | 2016-05-27 17:26:18 +0530 | [diff] [blame] | 107 | }; |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 108 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 109 | /* NFC control block flags */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 110 | /* NFC_Deactivate () is called and the NCI cmd is not sent */ |
| 111 | #define NFC_FL_DEACTIVATING 0x0001 |
| 112 | /* restarting NFCC after PowerOffSleep */ |
| 113 | #define NFC_FL_RESTARTING 0x0002 |
| 114 | /* enterning power off sleep mode */ |
| 115 | #define NFC_FL_POWER_OFF_SLEEP 0x0004 |
| 116 | /* Power cycle NFCC */ |
| 117 | #define NFC_FL_POWER_CYCLE_NFCC 0x0008 |
| 118 | /* HAL requested control on NCI command window */ |
| 119 | #define NFC_FL_CONTROL_REQUESTED 0x0010 |
| 120 | /* NCI command window is on the HAL side */ |
| 121 | #define NFC_FL_CONTROL_GRANTED 0x0020 |
| 122 | /* NCI command window is on the HAL side */ |
| 123 | #define NFC_FL_DISCOVER_PENDING 0x0040 |
| 124 | /* NFC_FL_CONTROL_REQUESTED on HAL request */ |
| 125 | #define NFC_FL_HAL_REQUESTED 0x0080 |
| 126 | /* Waiting for NFCEE Mode Set NTF */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 127 | #define NFC_FL_WAIT_MODE_SET_NTF 0x0100 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 128 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 129 | #define NFC_PEND_CONN_ID 0xFE |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 130 | #define NFC_CONN_ID_ID_MASK NCI_CID_MASK |
| 131 | /* set num_buff to this for no flow control */ |
| 132 | #define NFC_CONN_NO_FC 0xFF |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 133 | |
| 134 | #if (NFC_RW_ONLY == FALSE) |
| 135 | /* only allow the entries that the NFCC can support */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 136 | #define NFC_CHECK_MAX_CONN() \ |
| 137 | { \ |
| 138 | if (max > nfc_cb.max_conn) max = nfc_cb.max_conn; \ |
| 139 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 140 | #else |
| 141 | #define NFC_CHECK_MAX_CONN() |
| 142 | #endif |
| 143 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 144 | typedef struct { |
| 145 | tNFC_CONN_CBACK* p_cback; /* the callback function to receive the data */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 146 | BUFFER_Q tx_q; /* transmit queue */ |
| 147 | BUFFER_Q rx_q; /* receive queue */ |
| 148 | uint8_t id; /* NFCEE ID or RF Discovery ID or NFC_TEST_ID */ |
| 149 | uint8_t act_protocol; /* the active protocol on this logical connection */ |
| 150 | uint8_t act_interface; /* the active interface on this logical connection */ |
| 151 | uint8_t conn_id; /* the connection id assigned by NFCC for this conn */ |
| 152 | uint8_t buff_size; /* the max buffer size for this connection. . */ |
| 153 | uint8_t num_buff; /* num of buffers left to send on this connection */ |
| 154 | uint8_t init_credits; /* initial num of buffer credits */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 155 | } tNFC_CONN_CB; |
| 156 | |
| 157 | /* This data type is for NFC task to send a NCI VS command to NCIT task */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 158 | typedef struct { |
| 159 | NFC_HDR bt_hdr; /* the NCI command */ |
| 160 | tNFC_VS_CBACK* p_cback; /* the callback function to receive RSP */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 161 | } tNFC_NCI_VS_MSG; |
| 162 | |
| 163 | /* This data type is for HAL event */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 164 | typedef struct { |
| 165 | NFC_HDR hdr; |
| 166 | uint8_t hal_evt; /* HAL event code */ |
| 167 | uint8_t status; /* tHAL_NFC_STATUS */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 168 | } tNFC_HAL_EVT_MSG; |
| 169 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 170 | /* callback function pointer(8; use 8 to be safe + NFC_SAVED_CMD_SIZE(2) */ |
| 171 | #define NFC_RECEIVE_MSGS_OFFSET (10) |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 172 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 173 | #define NFC_SAVED_HDR_SIZE (2) |
| 174 | /* data Reassembly error (in NFC_HDR.layer_specific) */ |
| 175 | #define NFC_RAS_TOO_BIG 0x08 |
| 176 | #define NFC_RAS_FRAGMENTED 0x01 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 177 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 178 | /* NCI command buffer contains a VSC (in NFC_HDR.layer_specific) */ |
| 179 | #define NFC_WAIT_RSP_VSC 0x01 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 180 | |
| 181 | /* NFC control blocks */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 182 | typedef struct { |
| 183 | uint16_t flags; /* NFC control block flags - NFC_FL_* */ |
| 184 | tNFC_CONN_CB conn_cb[NCI_MAX_CONN_CBS]; |
| 185 | uint8_t conn_id[NFC_MAX_CONN_ID + 1]; /* index: conn_id; conn_id[]: index(1 |
| 186 | based) to conn_cb[] */ |
| 187 | tNFC_DISCOVER_CBACK* p_discv_cback; |
| 188 | tNFC_RESPONSE_CBACK* p_resp_cback; |
| 189 | tNFC_TEST_CBACK* p_test_cback; |
| 190 | tNFC_VS_CBACK* |
| 191 | p_vs_cb[NFC_NUM_VS_CBACKS]; /* Register for vendor specific events */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 192 | |
| 193 | #if (NFC_RW_ONLY == FALSE) |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 194 | /* NFCC information at init rsp */ |
| 195 | uint32_t nci_features; /* the NCI features supported by NFCC */ |
| 196 | uint16_t max_ce_table; /* the max routing table size */ |
| 197 | uint8_t max_conn; /* the num of connections supported by NFCC */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 198 | #endif |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 199 | uint8_t nci_ctrl_size; /* Max Control Packet Payload Size */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 200 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 201 | const tNCI_DISCOVER_MAPS* |
| 202 | p_disc_maps; /* NCI RF Discovery interface mapping */ |
| 203 | uint8_t vs_interface |
| 204 | [NFC_NFCC_MAX_NUM_VS_INTERFACE]; /* the NCI VS interfaces of NFCC */ |
| 205 | uint16_t nci_interfaces; /* the NCI interfaces of NFCC */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 206 | uint8_t nci_intf_extensions; |
| 207 | uint8_t nci_intf_extension_map[NCI_INTERFACE_EXTENSION_MAX]; |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 208 | uint8_t num_disc_maps; /* number of RF Discovery interface mappings */ |
| 209 | void* p_disc_pending; /* the parameters associated with pending |
| 210 | NFC_DiscoveryStart */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 211 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 212 | /* NFC_TASK timer management */ |
| 213 | TIMER_LIST_Q timer_queue; /* 1-sec timer event queue */ |
| 214 | TIMER_LIST_Q quick_timer_queue; |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 215 | TIMER_LIST_ENT mode_set_ntf_timer; /* Timer to wait for deactivation */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 216 | TIMER_LIST_ENT deactivate_timer; /* Timer to wait for deactivation */ |
| 217 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 218 | tNFC_STATE nfc_state; |
| 219 | bool reassembly; /* Reassemble fragmented data pkt */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 220 | uint8_t last_hdr[NFC_SAVED_HDR_SIZE]; /* part of last NCI command header */ |
| 221 | uint8_t last_cmd[NFC_SAVED_CMD_SIZE]; /* part of last NCI command payload */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 222 | void* p_vsc_cback; /* the callback function for last VSC command */ |
| 223 | BUFFER_Q nci_cmd_xmit_q; /* NCI command queue */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 224 | TIMER_LIST_ENT |
| 225 | nci_wait_rsp_timer; /* Timer for waiting for nci command response */ |
| 226 | uint16_t nci_wait_rsp_tout; /* NCI command timeout (in ms) */ |
| 227 | uint8_t nci_wait_rsp; /* layer_specific for last NCI message */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 228 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 229 | uint8_t nci_cmd_window; /* Number of commands the controller can accecpt |
| 230 | without waiting for response */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 231 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 232 | NFC_HDR* p_nci_init_rsp; /* holding INIT_RSP until receiving |
| 233 | HAL_NFC_POST_INIT_CPLT_EVT */ |
| 234 | tHAL_NFC_ENTRY* p_hal; |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 235 | |
| 236 | uint8_t nci_version; /* NCI version used for NCI communication*/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 237 | |
Suraj Uday Kotharkar | 6f7757b | 2018-05-10 15:58:29 +0530 | [diff] [blame] | 238 | bool isScbrSupported; /* indicating if system code based route is supported */ |
| 239 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 240 | uint8_t hci_packet_size; /* maximum hci payload size*/ |
| 241 | |
| 242 | uint8_t hci_conn_credits; /* maximum conn credits for static HCI*/ |
| 243 | |
| 244 | uint16_t nci_max_v_size; /*maximum NFC V rf frame size*/ |
| 245 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 246 | uint8_t rawVsCbflag; |
| 247 | uint8_t deact_reason; |
| 248 | |
| 249 | TIMER_LIST_ENT nci_mode_set_ntf_timer; /*Mode set notification timer*/ |
| 250 | #if (NXP_EXTNS == TRUE) |
| 251 | TIMER_LIST_ENT |
| 252 | nci_wait_data_ntf_timer; /* Timer for waiting for core credit ntf*/ |
| 253 | #endif |
| 254 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 255 | } tNFC_CB; |
| 256 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 257 | #if (NXP_EXTNS == TRUE) |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 258 | typedef struct { |
| 259 | uint8_t fw_update_reqd; |
| 260 | uint8_t rf_update_reqd; |
| 261 | } tNFC_FWUpdate_Info_t; |
nxpandroid | 6154b73 | 2016-01-14 20:39:23 +0530 | [diff] [blame] | 262 | #endif |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 263 | /***************************************************************************** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 264 | ** EXTERNAL FUNCTION DECLARATIONS |
| 265 | *****************************************************************************/ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 266 | |
| 267 | /* Global NFC data */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 268 | extern tNFC_CB nfc_cb; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 269 | |
| 270 | /**************************************************************************** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 271 | ** Internal nfc functions |
| 272 | ****************************************************************************/ |
| 273 | |
| 274 | #define NCI_CALCULATE_ACK(a, v) \ |
| 275 | { (a) &= ((1 << (v)) - 1); } |
| 276 | #define MAX_NUM_VALID_BITS_FOR_ACK 0x07 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 277 | |
| 278 | /* from nfc_utils.c */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 279 | extern tNFC_CONN_CB* nfc_alloc_conn_cb(tNFC_CONN_CBACK* p_cback); |
| 280 | extern tNFC_CONN_CB* nfc_find_conn_cb_by_conn_id(uint8_t conn_id); |
| 281 | extern tNFC_CONN_CB* nfc_find_conn_cb_by_handle(uint8_t target_handle); |
| 282 | extern void nfc_set_conn_id(tNFC_CONN_CB* p_cb, uint8_t conn_id); |
| 283 | extern void nfc_free_conn_cb(tNFC_CONN_CB* p_cb); |
| 284 | extern void nfc_reset_all_conn_cbs(void); |
| 285 | extern void nfc_data_event(tNFC_CONN_CB* p_cb); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 286 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 287 | extern uint8_t nfc_ncif_send_data(tNFC_CONN_CB* p_cb, NFC_HDR* p_data); |
| 288 | extern void nfc_ncif_cmd_timeout(void); |
| 289 | extern void nfc_wait_2_deactivate_timeout(void); |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 290 | extern void nfc_mode_set_ntf_timeout(void); |
| 291 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 292 | extern bool nfc_ncif_process_event(NFC_HDR* p_msg); |
| 293 | extern void nfc_ncif_check_cmd_queue(NFC_HDR* p_buf); |
| 294 | extern void nfc_ncif_send_cmd(NFC_HDR* p_buf); |
| 295 | extern void nfc_ncif_proc_discover_ntf(uint8_t* p, uint16_t plen); |
| 296 | extern void nfc_ncif_rf_management_status(tNFC_DISCOVER_EVT event, |
| 297 | uint8_t status); |
| 298 | extern void nfc_ncif_set_config_status(uint8_t* p, uint8_t len); |
| 299 | extern void nfc_ncif_event_status(tNFC_RESPONSE_EVT event, uint8_t status); |
| 300 | extern void nfc_ncif_error_status(uint8_t conn_id, uint8_t status); |
| 301 | extern void nfc_ncif_proc_credits(uint8_t* p, uint16_t plen); |
| 302 | extern void nfc_ncif_proc_activate(uint8_t* p, uint8_t len); |
| 303 | extern void nfc_ncif_proc_deactivate(uint8_t status, uint8_t deact_type, |
| 304 | bool is_ntf); |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 305 | #if (NFC_NFCEE_INCLUDED == TRUE && NFC_RW_ONLY == FALSE) |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 306 | extern void nfc_ncif_proc_ee_action(uint8_t* p, uint16_t plen); |
| 307 | extern void nfc_ncif_proc_ee_discover_req(uint8_t* p, uint16_t plen); |
| 308 | extern void nfc_ncif_proc_get_routing(uint8_t* p, uint8_t len); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 309 | #endif |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 310 | extern void nfc_ncif_proc_conn_create_rsp(uint8_t* p, uint16_t plen, |
| 311 | uint8_t dest_type); |
| 312 | extern void nfc_ncif_report_conn_close_evt(uint8_t conn_id, tNFC_STATUS status); |
| 313 | extern void nfc_ncif_proc_t3t_polling_ntf(uint8_t* p, uint16_t plen); |
| 314 | extern void nfc_ncif_proc_reset_rsp(uint8_t* p, bool is_ntf); |
| 315 | extern void nfc_ncif_proc_init_rsp(NFC_HDR* p_msg); |
| 316 | extern void nfc_ncif_proc_get_config_rsp(NFC_HDR* p_msg); |
| 317 | extern void nfc_ncif_proc_data(NFC_HDR* p_msg); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 318 | extern bool nfa_dm_p2p_prio_logic(uint8_t event, uint8_t* p, uint8_t ntf_rsp); |
| 319 | extern void nfa_dm_p2p_timer_event(); |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 320 | extern bool nfc_ncif_proc_proprietary_rsp(uint8_t mt, uint8_t gid, uint8_t oid); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 321 | extern void nfa_dm_p2p_prio_logic_cleanup(); |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 322 | extern void nfc_ncif_proc_isodep_nak_presence_check_status(uint8_t status, |
| 323 | bool is_ntf); |
| 324 | extern void nfc_ncif_update_window(void); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 325 | #if (NFC_RW_ONLY == FALSE) |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 326 | extern void nfc_ncif_proc_rf_field_ntf(uint8_t rf_status); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 327 | #else |
| 328 | #define nfc_ncif_proc_rf_field_ntf(rf_status) |
| 329 | #endif |
| 330 | |
| 331 | /* From nfc_task.c */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 332 | extern uint32_t nfc_task(uint32_t); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 333 | void nfc_task_shutdown_nfcc(void); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 334 | |
| 335 | /* From nfc_main.c */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 336 | void nfc_enabled(tNFC_STATUS nfc_status, NFC_HDR* p_init_rsp_msg); |
| 337 | void nfc_set_state(tNFC_STATE nfc_state); |
| 338 | void nfc_main_flush_cmd_queue(void); |
| 339 | void nfc_gen_cleanup(void); |
| 340 | void nfc_main_handle_hal_evt(tNFC_HAL_EVT_MSG* p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 341 | |
| 342 | /* Timer functions */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 343 | void nfc_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type, uint32_t timeout); |
| 344 | uint32_t nfc_remaining_time(TIMER_LIST_ENT* p_tle); |
| 345 | void nfc_stop_timer(TIMER_LIST_ENT* p_tle); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 346 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 347 | void nfc_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type, |
| 348 | uint32_t timeout); |
| 349 | void nfc_stop_quick_timer(TIMER_LIST_ENT* p_tle); |
| 350 | void nfc_process_quick_timer_evt(void); |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 351 | #if (NXP_EXTNS == TRUE) |
| 352 | extern void nfc_ncif_credit_ntf_timeout(void); |
nxf24591 | 619d216 | 2018-06-11 13:21:51 +0530 | [diff] [blame] | 353 | void check_nfcee_session_and_reset(); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 354 | #endif |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 355 | #endif /* NFC_INT_H_ */ |