Fork of the GitHub

Committer:
DiegoOstuni
Date:
Thu Nov 14 14:34:50 2019 +0000
Revision:
0:75fc82583a41
Add files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:75fc82583a41 1
DiegoOstuni 0:75fc82583a41 2 /******************************************************************************
DiegoOstuni 0:75fc82583a41 3 * @attention
DiegoOstuni 0:75fc82583a41 4 *
DiegoOstuni 0:75fc82583a41 5 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
DiegoOstuni 0:75fc82583a41 6 *
DiegoOstuni 0:75fc82583a41 7 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
DiegoOstuni 0:75fc82583a41 8 * You may not use this file except in compliance with the License.
DiegoOstuni 0:75fc82583a41 9 * You may obtain a copy of the License at:
DiegoOstuni 0:75fc82583a41 10 *
DiegoOstuni 0:75fc82583a41 11 * http://www.st.com/myliberty
DiegoOstuni 0:75fc82583a41 12 *
DiegoOstuni 0:75fc82583a41 13 * Unless required by applicable law or agreed to in writing, software
DiegoOstuni 0:75fc82583a41 14 * distributed under the License is distributed on an "AS IS" BASIS,
DiegoOstuni 0:75fc82583a41 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
DiegoOstuni 0:75fc82583a41 16 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
DiegoOstuni 0:75fc82583a41 17 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
DiegoOstuni 0:75fc82583a41 18 * See the License for the specific language governing permissions and
DiegoOstuni 0:75fc82583a41 19 * limitations under the License.
DiegoOstuni 0:75fc82583a41 20 *
DiegoOstuni 0:75fc82583a41 21 ******************************************************************************/
DiegoOstuni 0:75fc82583a41 22
DiegoOstuni 0:75fc82583a41 23
DiegoOstuni 0:75fc82583a41 24 /*
DiegoOstuni 0:75fc82583a41 25 * PROJECT: ST25R391x firmware
DiegoOstuni 0:75fc82583a41 26 * $Revision: $
DiegoOstuni 0:75fc82583a41 27 * LANGUAGE: ISO C99
DiegoOstuni 0:75fc82583a41 28 */
DiegoOstuni 0:75fc82583a41 29
DiegoOstuni 0:75fc82583a41 30 /*! \file rfal_nfcDep.h
DiegoOstuni 0:75fc82583a41 31 *
DiegoOstuni 0:75fc82583a41 32 * \author Gustavo Patricio
DiegoOstuni 0:75fc82583a41 33 *
DiegoOstuni 0:75fc82583a41 34 * \brief Implementation of NFC-DEP protocol
DiegoOstuni 0:75fc82583a41 35 *
DiegoOstuni 0:75fc82583a41 36 * NFC-DEP is also known as NFCIP - Near Field Communication
DiegoOstuni 0:75fc82583a41 37 * Interface and Protocol
DiegoOstuni 0:75fc82583a41 38 *
DiegoOstuni 0:75fc82583a41 39 * This implementation was based on the following specs:
DiegoOstuni 0:75fc82583a41 40 * - NFC Forum Digital 1.1
DiegoOstuni 0:75fc82583a41 41 * - ECMA 340 3rd Edition 2013
DiegoOstuni 0:75fc82583a41 42 *
DiegoOstuni 0:75fc82583a41 43 *
DiegoOstuni 0:75fc82583a41 44 * @addtogroup RFAL
DiegoOstuni 0:75fc82583a41 45 * @{
DiegoOstuni 0:75fc82583a41 46 *
DiegoOstuni 0:75fc82583a41 47 * @addtogroup RFAL-AL
DiegoOstuni 0:75fc82583a41 48 * @brief RFAL Abstraction Layer
DiegoOstuni 0:75fc82583a41 49 * @{
DiegoOstuni 0:75fc82583a41 50 *
DiegoOstuni 0:75fc82583a41 51 * @addtogroup NFC-DEP
DiegoOstuni 0:75fc82583a41 52 * @brief RFAL NFC-DEP Module
DiegoOstuni 0:75fc82583a41 53 * @{
DiegoOstuni 0:75fc82583a41 54 */
DiegoOstuni 0:75fc82583a41 55
DiegoOstuni 0:75fc82583a41 56 #ifndef RFAL_NFCDEP_H_
DiegoOstuni 0:75fc82583a41 57 #define RFAL_NFCDEP_H_
DiegoOstuni 0:75fc82583a41 58
DiegoOstuni 0:75fc82583a41 59 /*
DiegoOstuni 0:75fc82583a41 60 ******************************************************************************
DiegoOstuni 0:75fc82583a41 61 * INCLUDES
DiegoOstuni 0:75fc82583a41 62 ******************************************************************************
DiegoOstuni 0:75fc82583a41 63 */
DiegoOstuni 0:75fc82583a41 64 #include "platform1.h"
DiegoOstuni 0:75fc82583a41 65 #include "st_errno.h"
DiegoOstuni 0:75fc82583a41 66 #include "rfal_rf.h"
DiegoOstuni 0:75fc82583a41 67
DiegoOstuni 0:75fc82583a41 68
DiegoOstuni 0:75fc82583a41 69 /*
DiegoOstuni 0:75fc82583a41 70 ******************************************************************************
DiegoOstuni 0:75fc82583a41 71 * DEFINES
DiegoOstuni 0:75fc82583a41 72 ******************************************************************************
DiegoOstuni 0:75fc82583a41 73 */
DiegoOstuni 0:75fc82583a41 74 #define RFAL_NFCDEP_FRAME_SIZE_MAX_LEN 254 /*!< NFCIP Maximum Frame Size Digital 1.0 Table 91 */
DiegoOstuni 0:75fc82583a41 75 #define RFAL_NFCDEP_DEPREQ_HEADER_LEN 5 /*!< DEP_REQ header length: CMD_TYPE + CMD_CMD + PBF + DID + NAD */
DiegoOstuni 0:75fc82583a41 76
DiegoOstuni 0:75fc82583a41 77
DiegoOstuni 0:75fc82583a41 78
DiegoOstuni 0:75fc82583a41 79 /*! Length NFCIP DEP REQ or RES header (incl LEN) */
DiegoOstuni 0:75fc82583a41 80 #define RFAL_NFCDEP_DEP_HEADER ( RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN + RFAL_NFCDEP_DEP_PFB_LEN )
DiegoOstuni 0:75fc82583a41 81 #define RFAL_NFCDEP_HEADER ( RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN ) /*!< NFCIP header length */
DiegoOstuni 0:75fc82583a41 82 #define RFAL_NFCDEP_SB_LEN 1 /*!< SB length on NFCIP fram for NFC-A */
DiegoOstuni 0:75fc82583a41 83 #define RFAL_NFCDEP_LEN_LEN 1 /*!< LEN length on NFCIP frame */
DiegoOstuni 0:75fc82583a41 84 #define RFAL_NFCDEP_CMDTYPE_LEN 1 /*!< Length of the cmd type (REQ | RES) on NFCIP frame */
DiegoOstuni 0:75fc82583a41 85 #define RFAL_NFCDEP_CMD_LEN 1 /*!< Length of the cmd on NFCIP frame */
DiegoOstuni 0:75fc82583a41 86 #define RFAL_NFCDEP_DID_LEN 1 /*!< Length of did on NFCIP frame */
DiegoOstuni 0:75fc82583a41 87 #define RFAL_NFCDEP_DEP_PFB_LEN 1 /*!< Length of the PFB field on NFCIP frame */
DiegoOstuni 0:75fc82583a41 88
DiegoOstuni 0:75fc82583a41 89 #define RFAL_NFCDEP_DSL_RLS_LEN_NO_DID (RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN) /*!< Length of DSL_REQ and RLS_REQ with no DID */
DiegoOstuni 0:75fc82583a41 90 #define RFAL_NFCDEP_DSL_RLS_LEN_DID (RFAL_NFCDEP_DSL_RLS_LEN_NO_DID + RFAL_NFCDEP_DID_LEN) /*!< Length of DSL_REQ and RLS_REQ with DID */
DiegoOstuni 0:75fc82583a41 91
DiegoOstuni 0:75fc82583a41 92 #define RFAL_NFCDEP_FS_VAL_MIN 64 /*!< Minimum LR value */
DiegoOstuni 0:75fc82583a41 93 #define RFAL_NFCDEP_LR_VAL_MASK 0x03 /*!< Bit mask for a LR value */
DiegoOstuni 0:75fc82583a41 94 #define RFAL_NFCDEP_PP_LR_MASK 0x30 /*!< Bit mask for LR value in PP byte on a ATR REQ/RES */
DiegoOstuni 0:75fc82583a41 95 #define RFAL_NFCDEP_PP_LR_SHIFT 4 /*!< Position of LR value in PP byte on a ATR REQ/RES */
DiegoOstuni 0:75fc82583a41 96
DiegoOstuni 0:75fc82583a41 97 #define RFAL_NFCDEP_DID_MAX 14 /*!< Max DID value Digital 14.6.2.3 */
DiegoOstuni 0:75fc82583a41 98 #define RFAL_NFCDEP_DID_KEEP 0xFF /*!< Keep DID value already configured */
DiegoOstuni 0:75fc82583a41 99 #define RFAL_NFCDEP_DID_NO 0x00 /*!< No DID shall be used */
DiegoOstuni 0:75fc82583a41 100 #define RFAL_NFCDEP_NAD_NO 0x00 /*!< No NAD shall be used */
DiegoOstuni 0:75fc82583a41 101
DiegoOstuni 0:75fc82583a41 102 #define RFAL_NFCDEP_OPER_RTOX_REQ_DIS 0x01 /*!< Operation config: RTOX REQ disable */
DiegoOstuni 0:75fc82583a41 103 #define RFAL_NFCDEP_OPER_RTOX_REQ_EN 0x00 /*!< Operation config: RTOX REQ enable */
DiegoOstuni 0:75fc82583a41 104
DiegoOstuni 0:75fc82583a41 105 #define RFAL_NFCDEP_OPER_ATN_DIS 0x00 /*!< Operation config: ATN disable */
DiegoOstuni 0:75fc82583a41 106 #define RFAL_NFCDEP_OPER_ATN_EN 0x02 /*!< Operation config: ATN enable */
DiegoOstuni 0:75fc82583a41 107
DiegoOstuni 0:75fc82583a41 108 #define RFAL_NFCDEP_OPER_EMPTY_DEP_DIS 0x04 /*!< Operation config: empty DEPs disable */
DiegoOstuni 0:75fc82583a41 109 #define RFAL_NFCDEP_OPER_EMPTY_DEP_EN 0x00 /*!< Operation config: empty DEPs enable */
DiegoOstuni 0:75fc82583a41 110
DiegoOstuni 0:75fc82583a41 111 #define RFAL_NFCDEP_OPER_FULL_MI_DIS 0x00 /*!< Operation config: full chaining DEPs disable */
DiegoOstuni 0:75fc82583a41 112 #define RFAL_NFCDEP_OPER_FULL_MI_EN 0x08 /*!< Operation config: full chaining DEPs enable */
DiegoOstuni 0:75fc82583a41 113
DiegoOstuni 0:75fc82583a41 114
DiegoOstuni 0:75fc82583a41 115 #define RFAL_NFCDEP_BRS_MAINTAIN 0xC0 /*!< Value signalling that BR is to be maintained (no PSL) */
DiegoOstuni 0:75fc82583a41 116 #define RFAL_NFCDEP_BRS_Dx_MASK 0x07 /*!< Value signalling that BR is to be maintained (no PSL) */
DiegoOstuni 0:75fc82583a41 117 #define RFAL_NFCDEP_BRS_DSI_POS 3 /*!< Value signalling that BR is to be maintained (no PSL) */
DiegoOstuni 0:75fc82583a41 118
DiegoOstuni 0:75fc82583a41 119 #define RFAL_NFCDEP_WT_DELTA (16 - RFAL_NFCDEP_WT_DELTA_ADJUST) /*!< NFC-DEP dWRT (adjusted) Digital 1.0 A.10 */
DiegoOstuni 0:75fc82583a41 120 #define RFAL_NFCDEP_WT_DELTA_ADJUST 4 /*!< dWRT value adjustment */
DiegoOstuni 0:75fc82583a41 121
DiegoOstuni 0:75fc82583a41 122
DiegoOstuni 0:75fc82583a41 123 #define RFAL_NFCDEP_ATR_REQ_NFCID3_POS 2 /*!< NFCID3 offset in ATR_REQ frame */
DiegoOstuni 0:75fc82583a41 124 #define RFAL_NFCDEP_NFCID3_LEN 10 /*!< NFCID3 Length */
DiegoOstuni 0:75fc82583a41 125
DiegoOstuni 0:75fc82583a41 126 #define RFAL_NFCDEP_LEN_MIN 3 /*!< Minimum length byte LEN value */
DiegoOstuni 0:75fc82583a41 127 #define RFAL_NFCDEP_LEN_MAX 255 /*!< Maximum length byte LEN value */
DiegoOstuni 0:75fc82583a41 128
DiegoOstuni 0:75fc82583a41 129 #define RFAL_NFCDEP_ATRRES_HEADER_LEN 2 /*!< ATR RES Header Len: CmdType: 0xD5 + Cod: 0x01 */
DiegoOstuni 0:75fc82583a41 130 #define RFAL_NFCDEP_ATRRES_MIN_LEN 17 /*!< Minimum length for an ATR RES */
DiegoOstuni 0:75fc82583a41 131 #define RFAL_NFCDEP_ATRRES_MAX_LEN 64 /*!< Maximum length for an ATR RES Digital 1.0 14.6.1 */
DiegoOstuni 0:75fc82583a41 132 #define RFAL_NFCDEP_ATRREQ_MIN_LEN 16 /*!< Minimum length for an ATR REQ */
DiegoOstuni 0:75fc82583a41 133 #define RFAL_NFCDEP_ATRREQ_MAX_LEN RFAL_NFCDEP_ATRRES_MAX_LEN /*!< Maximum length for an ATR REQ Digital 1.0 14.6.1 */
DiegoOstuni 0:75fc82583a41 134
DiegoOstuni 0:75fc82583a41 135 #define RFAL_NFCDEP_GB_MAX_LEN (RFAL_NFCDEP_ATRREQ_MAX_LEN - RFAL_NFCDEP_ATRREQ_MIN_LEN) /*!< Maximum length the General Bytes on ATR Digital 1.1 16.6.3 */
DiegoOstuni 0:75fc82583a41 136
DiegoOstuni 0:75fc82583a41 137 #define RFAL_NFCDEP_WT_INI_DEFAULT RFAL_NFCDEP_WT_INI_MAX /*!< WT Initiator default value Digital 1.0 14.6.3.8 */
DiegoOstuni 0:75fc82583a41 138 #define RFAL_NFCDEP_WT_INI_MIN 0 /*!< WT Initiator minimum value Digital 1.0 14.6.3.8 */
DiegoOstuni 0:75fc82583a41 139 #define RFAL_NFCDEP_WT_INI_MAX 14 /*!< WT Initiator maximum value Digital 1.0 14.6.3.8 A.10*/
DiegoOstuni 0:75fc82583a41 140 #define RFAL_NFCDEP_RWT_INI_MAX rfalNfcDepWT2RWT( RFAL_NFCDEP_WT_INI_MAX ) /*!< RWT Initiator maximum value */
DiegoOstuni 0:75fc82583a41 141
DiegoOstuni 0:75fc82583a41 142 #define RFAL_NFCDEP_WT_TRG_MAX_D10 8 /*!< WT target max Digital 1.0 14.6.3.8 A.10 */
DiegoOstuni 0:75fc82583a41 143 #define RFAL_NFCDEP_WT_TRG_MAX_D11 14 /*!< WT target max Digital 1.1 16.6.3.9 A.9 */
DiegoOstuni 0:75fc82583a41 144 #define RFAL_NFCDEP_WT_TRG_MAX RFAL_NFCDEP_WT_TRG_MAX_D10 /*!< WT target max Digital 1.x */
DiegoOstuni 0:75fc82583a41 145 #define RFAL_NFCDEP_RWT_TRG_MAX rfalNfcDepWT2RWT( RFAL_NFCDEP_WT_TRG_MAX ) /*!< RWT Initiator maximum value */
DiegoOstuni 0:75fc82583a41 146
DiegoOstuni 0:75fc82583a41 147 /*! Maximum Frame Waiting Time = ((256 * 16/fc)*2^FWImax) = ((256*16/fc)*2^14) = (1048576 / 64)/fc = (100000h*64)/fc */
DiegoOstuni 0:75fc82583a41 148 #define RFAL_NFCDEP_MAX_FWT (1<<20)
DiegoOstuni 0:75fc82583a41 149
DiegoOstuni 0:75fc82583a41 150 #define RFAL_NFCDEP_WT_MASK 0x0F /*!< Bit mask for the Wait Time value */
DiegoOstuni 0:75fc82583a41 151
DiegoOstuni 0:75fc82583a41 152 #define RFAL_NFCDEP_BR_MASK_106 1 /*!< Enable mask bit rate 106 */
DiegoOstuni 0:75fc82583a41 153 #define RFAL_NFCDEP_BR_MASK_212 2 /*!< Enable mask bit rate 242 */
DiegoOstuni 0:75fc82583a41 154 #define RFAL_NFCDEP_BR_MASK_424 4 /*!< Enable mask bit rate 424 */
DiegoOstuni 0:75fc82583a41 155
DiegoOstuni 0:75fc82583a41 156 /*
DiegoOstuni 0:75fc82583a41 157 ******************************************************************************
DiegoOstuni 0:75fc82583a41 158 * GLOBAL MACROS
DiegoOstuni 0:75fc82583a41 159 ******************************************************************************
DiegoOstuni 0:75fc82583a41 160 */
DiegoOstuni 0:75fc82583a41 161
DiegoOstuni 0:75fc82583a41 162 #define rfalNfcDepWT2RWT( wt ) (1 << ( (wt & RFAL_NFCDEP_WT_MASK) + 6) ) /*!< Converts WT value to RWT */
DiegoOstuni 0:75fc82583a41 163
DiegoOstuni 0:75fc82583a41 164 /*! Returns the BRS value from the given bit rate */
DiegoOstuni 0:75fc82583a41 165 #define rfalNfcDepDx2BRS( br ) ( (uint8_t) ( (((br)&RFAL_NFCDEP_BRS_Dx_MASK) << RFAL_NFCDEP_BRS_DSI_POS) | ((br) & RFAL_NFCDEP_BRS_Dx_MASK) ))
DiegoOstuni 0:75fc82583a41 166
DiegoOstuni 0:75fc82583a41 167 #define rfalNfcDepBRS2DRI( brs ) ( (uint8_t) ( brs & RFAL_NFCDEP_BRS_Dx_MASK ) ) /*!< Returns the DRI value from the given BRS byte */
DiegoOstuni 0:75fc82583a41 168 #define rfalNfcDepBRS2DSI( brs ) ( (uint8_t) ( (brs >> RFAL_NFCDEP_BRS_DSI_POS) & RFAL_NFCDEP_BRS_Dx_MASK ) ) /*!< Returns the DSI value from the given BRS byte */
DiegoOstuni 0:75fc82583a41 169
DiegoOstuni 0:75fc82583a41 170 #define rfalNfcDepPP2LR( PPx ) ( (uint8_t) ( PPx & RFAL_NFCDEP_PP_LR_MASK ) >> RFAL_NFCDEP_PP_LR_SHIFT) /*!< Returns the LR value from the given PPx byte */
DiegoOstuni 0:75fc82583a41 171 #define rfalNfcDepLR2PP( LRx ) ( (uint8_t) ((LRx << RFAL_NFCDEP_PP_LR_SHIFT) & RFAL_NFCDEP_PP_LR_MASK)) /*!< Returns the PP byte with the given LRx value */
DiegoOstuni 0:75fc82583a41 172
DiegoOstuni 0:75fc82583a41 173 /*! Returns the Frame size value from the given LRx value */
DiegoOstuni 0:75fc82583a41 174 #define rfalNfcDepLR2FS( LRx ) MIN( ((uint8_t) RFAL_NFCDEP_FS_VAL_MIN * (LRx + 1) ), RFAL_NFCDEP_FRAME_SIZE_MAX_LEN )
DiegoOstuni 0:75fc82583a41 175
DiegoOstuni 0:75fc82583a41 176 /*!
DiegoOstuni 0:75fc82583a41 177 * Despite DIGITAL 1.0 14.6.2.1 stating that the last two bytes may filled with
DiegoOstuni 0:75fc82583a41 178 * any value, some devices (Samsung Google Nexus) only accept when these are 0 */
DiegoOstuni 0:75fc82583a41 179 #define rfalNfcDepSetNFCID( dst, src, len ) ST_MEMSET( (dst), 0x00, RFAL_NFCDEP_NFCID3_LEN ); \
DiegoOstuni 0:75fc82583a41 180 ST_MEMCPY( (dst), src, len )
DiegoOstuni 0:75fc82583a41 181
DiegoOstuni 0:75fc82583a41 182 /*
DiegoOstuni 0:75fc82583a41 183 ******************************************************************************
DiegoOstuni 0:75fc82583a41 184 * GLOBAL ENUMERATIONS
DiegoOstuni 0:75fc82583a41 185 ******************************************************************************
DiegoOstuni 0:75fc82583a41 186 */
DiegoOstuni 0:75fc82583a41 187
DiegoOstuni 0:75fc82583a41 188
DiegoOstuni 0:75fc82583a41 189
DiegoOstuni 0:75fc82583a41 190 /*! Enumeration of NFC-DEP bit rate in ATR Digital 1.0 Table 93 and 94 */
DiegoOstuni 0:75fc82583a41 191 enum{
DiegoOstuni 0:75fc82583a41 192 RFAL_NFCDEP_Bx_NO_HIGH_BR = 0x00, /*!< Peer supports no high bit rates */
DiegoOstuni 0:75fc82583a41 193 RFAL_NFCDEP_Bx_08_848 = 0x01, /*!< Peer also supports 848 */
DiegoOstuni 0:75fc82583a41 194 RFAL_NFCDEP_Bx_16_1695 = 0x02, /*!< Peer also supports 1695 */
DiegoOstuni 0:75fc82583a41 195 RFAL_NFCDEP_Bx_32_3390 = 0x04, /*!< Peer also supports 3390 */
DiegoOstuni 0:75fc82583a41 196 RFAL_NFCDEP_Bx_64_6780 = 0x08 /*!< Peer also supports 6780 */
DiegoOstuni 0:75fc82583a41 197 };
DiegoOstuni 0:75fc82583a41 198
DiegoOstuni 0:75fc82583a41 199 /*! Enumeration of NFC-DEP bit rate Dividor in PSL Digital 1.0 Table 100 */
DiegoOstuni 0:75fc82583a41 200 enum{
DiegoOstuni 0:75fc82583a41 201 RFAL_NFCDEP_Dx_01_106 = RFAL_BR_106, /*!< Divisor D = 1 : bit rate = 106 */
DiegoOstuni 0:75fc82583a41 202 RFAL_NFCDEP_Dx_02_212 = RFAL_BR_212, /*!< Divisor D = 2 : bit rate = 212 */
DiegoOstuni 0:75fc82583a41 203 RFAL_NFCDEP_Dx_04_424 = RFAL_BR_424, /*!< Divisor D = 4 : bit rate = 424 */
DiegoOstuni 0:75fc82583a41 204 RFAL_NFCDEP_Dx_08_848 = RFAL_BR_848, /*!< Divisor D = 8 : bit rate = 848 */
DiegoOstuni 0:75fc82583a41 205 RFAL_NFCDEP_Dx_16_1695 = RFAL_BR_1695, /*!< Divisor D = 16 : bit rate = 1695 */
DiegoOstuni 0:75fc82583a41 206 RFAL_NFCDEP_Dx_32_3390 = RFAL_BR_3390, /*!< Divisor D = 32 : bit rate = 3390 */
DiegoOstuni 0:75fc82583a41 207 RFAL_NFCDEP_Dx_64_6780 = RFAL_BR_6780 /*!< Divisor D = 64 : bit rate = 6780 */
DiegoOstuni 0:75fc82583a41 208 };
DiegoOstuni 0:75fc82583a41 209
DiegoOstuni 0:75fc82583a41 210 /*! Enumeration of NFC-DEP Length Reduction (LR) Digital 1.0 Table 91 */
DiegoOstuni 0:75fc82583a41 211 enum{
DiegoOstuni 0:75fc82583a41 212 RFAL_NFCDEP_LR_64 = 0x00, /*!< Maximum payload size is 64 bytes */
DiegoOstuni 0:75fc82583a41 213 RFAL_NFCDEP_LR_128 = 0x01, /*!< Maximum payload size is 128 bytes */
DiegoOstuni 0:75fc82583a41 214 RFAL_NFCDEP_LR_192 = 0x02, /*!< Maximum payload size is 192 bytes */
DiegoOstuni 0:75fc82583a41 215 RFAL_NFCDEP_LR_254 = 0x03 /*!< Maximum payload size is 254 bytes */
DiegoOstuni 0:75fc82583a41 216 };
DiegoOstuni 0:75fc82583a41 217
DiegoOstuni 0:75fc82583a41 218 /*
DiegoOstuni 0:75fc82583a41 219 ******************************************************************************
DiegoOstuni 0:75fc82583a41 220 * GLOBAL DATA TYPES
DiegoOstuni 0:75fc82583a41 221 ******************************************************************************
DiegoOstuni 0:75fc82583a41 222 */
DiegoOstuni 0:75fc82583a41 223
DiegoOstuni 0:75fc82583a41 224 /*! NFC-DEP callback to check if upper layer has deactivation pending */
DiegoOstuni 0:75fc82583a41 225 typedef bool (* rfalNfcDepDeactCallback)(void);
DiegoOstuni 0:75fc82583a41 226
DiegoOstuni 0:75fc82583a41 227
DiegoOstuni 0:75fc82583a41 228 /*! Enumeration of the nfcip communication modes */
DiegoOstuni 0:75fc82583a41 229 typedef enum{
DiegoOstuni 0:75fc82583a41 230 RFAL_NFCDEP_COMM_PASSIVE, /*!< Passive communication mode */
DiegoOstuni 0:75fc82583a41 231 RFAL_NFCDEP_COMM_ACTIVE /*!< Active communication mode */
DiegoOstuni 0:75fc82583a41 232 } rfalNfcDepCommMode;
DiegoOstuni 0:75fc82583a41 233
DiegoOstuni 0:75fc82583a41 234
DiegoOstuni 0:75fc82583a41 235 /*! Enumeration of the nfcip roles */
DiegoOstuni 0:75fc82583a41 236 typedef enum{
DiegoOstuni 0:75fc82583a41 237 RFAL_NFCDEP_ROLE_INITIATOR, /*!< Perform as Initiator */
DiegoOstuni 0:75fc82583a41 238 RFAL_NFCDEP_ROLE_TARGET /*!< Perform as Target */
DiegoOstuni 0:75fc82583a41 239 } rfalNfcDepRole;
DiegoOstuni 0:75fc82583a41 240
DiegoOstuni 0:75fc82583a41 241
DiegoOstuni 0:75fc82583a41 242 /*! Struct that holds all NFCIP configs */
DiegoOstuni 0:75fc82583a41 243 typedef struct{
DiegoOstuni 0:75fc82583a41 244
DiegoOstuni 0:75fc82583a41 245 rfalNfcDepRole role; /*!< Current NFCIP role */
DiegoOstuni 0:75fc82583a41 246 rfalNfcDepCommMode commMode; /*!< Current NFCIP communication mode */
DiegoOstuni 0:75fc82583a41 247 uint8_t oper; /*!< Operation config similar to NCI 1.0 Table 81 */
DiegoOstuni 0:75fc82583a41 248
DiegoOstuni 0:75fc82583a41 249 uint8_t did; /*!< Current Device ID (DID) */
DiegoOstuni 0:75fc82583a41 250 uint8_t nad; /*!< Current Node Addressing (NAD) */
DiegoOstuni 0:75fc82583a41 251 uint8_t bs; /*!< Bit rate in Sending Direction */
DiegoOstuni 0:75fc82583a41 252 uint8_t br; /*!< Bit rate in Receiving Direction */
DiegoOstuni 0:75fc82583a41 253 uint8_t nfcid[RFAL_NFCDEP_NFCID3_LEN]; /*!< Pointer to the NFCID to be used */
DiegoOstuni 0:75fc82583a41 254 uint8_t nfcidLen; /*!< Length of the given NFCID in nfcid */
DiegoOstuni 0:75fc82583a41 255 uint8_t gb[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Pointer General Bytes (GB) to be used */
DiegoOstuni 0:75fc82583a41 256 uint8_t gbLen; /*!< Length of the given GB in gb */
DiegoOstuni 0:75fc82583a41 257 uint8_t lr; /*!< Length Reduction (LR) to be used */
DiegoOstuni 0:75fc82583a41 258 uint8_t to; /*!< Timeout (TO) to be used */
DiegoOstuni 0:75fc82583a41 259 uint32_t fwt; /*!< Frame Waiting Time (FWT) to be used */
DiegoOstuni 0:75fc82583a41 260 uint32_t dFwt; /*!< Delta Frame Waiting Time (dFWT) to be used */
DiegoOstuni 0:75fc82583a41 261 } rfalNfcDepConfigs;
DiegoOstuni 0:75fc82583a41 262
DiegoOstuni 0:75fc82583a41 263
DiegoOstuni 0:75fc82583a41 264 /*! ATR_REQ command Digital 1.1 16.6.2 */
DiegoOstuni 0:75fc82583a41 265 typedef struct {
DiegoOstuni 0:75fc82583a41 266 uint8_t CMD1; /*!< Command format 0xD4 */
DiegoOstuni 0:75fc82583a41 267 uint8_t CMD2; /*!< Command Value */
DiegoOstuni 0:75fc82583a41 268 uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
DiegoOstuni 0:75fc82583a41 269 uint8_t DID; /*!< DID */
DiegoOstuni 0:75fc82583a41 270 uint8_t BSi; /*!< Sending Bitrate for Initiator */
DiegoOstuni 0:75fc82583a41 271 uint8_t BRi; /*!< Receiving Bitrate for Initiator */
DiegoOstuni 0:75fc82583a41 272 uint8_t PPi; /*!< Optional Parameters presence indicator */
DiegoOstuni 0:75fc82583a41 273 uint8_t GBi[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
DiegoOstuni 0:75fc82583a41 274 } rfalNfcDepAtrReq;
DiegoOstuni 0:75fc82583a41 275
DiegoOstuni 0:75fc82583a41 276
DiegoOstuni 0:75fc82583a41 277 /*! ATR_RES response Digital 1.1 16.6.3 */
DiegoOstuni 0:75fc82583a41 278 typedef struct {
DiegoOstuni 0:75fc82583a41 279 uint8_t CMD1; /*!< Response Byte 0xD5 */
DiegoOstuni 0:75fc82583a41 280 uint8_t CMD2; /*!< Command Value */
DiegoOstuni 0:75fc82583a41 281 uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
DiegoOstuni 0:75fc82583a41 282 uint8_t DID; /*!< DID */
DiegoOstuni 0:75fc82583a41 283 uint8_t BSt; /*!< Sending Bitrate for Initiator */
DiegoOstuni 0:75fc82583a41 284 uint8_t BRt; /*!< Receiving Bitrate for Initiator */
DiegoOstuni 0:75fc82583a41 285 uint8_t TO; /*!< Timeout */
DiegoOstuni 0:75fc82583a41 286 uint8_t PPt; /*!< Optional Parameters presence indicator */
DiegoOstuni 0:75fc82583a41 287 uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
DiegoOstuni 0:75fc82583a41 288 } rfalNfcDepAtrRes;
DiegoOstuni 0:75fc82583a41 289
DiegoOstuni 0:75fc82583a41 290
DiegoOstuni 0:75fc82583a41 291 /*! Structure of transmit I-PDU Buffer format from caller */
DiegoOstuni 0:75fc82583a41 292 typedef struct
DiegoOstuni 0:75fc82583a41 293 {
DiegoOstuni 0:75fc82583a41 294 uint8_t prologue[RFAL_NFCDEP_DEPREQ_HEADER_LEN]; /*!< Prologue space for NFC-DEP header*/
DiegoOstuni 0:75fc82583a41 295 uint8_t inf[RFAL_NFCDEP_FRAME_SIZE_MAX_LEN]; /*!< INF | Data area of the buffer */
DiegoOstuni 0:75fc82583a41 296 } rfalNfcDepBufFormat;
DiegoOstuni 0:75fc82583a41 297
DiegoOstuni 0:75fc82583a41 298
DiegoOstuni 0:75fc82583a41 299 /*! Activation info as Initiator and Target */
DiegoOstuni 0:75fc82583a41 300 typedef union {
DiegoOstuni 0:75fc82583a41 301 struct {
DiegoOstuni 0:75fc82583a41 302 rfalNfcDepAtrRes ATR_RES; /*!< ATR RES (Initiator mode) */
DiegoOstuni 0:75fc82583a41 303 uint8_t ATR_RESLen; /*!< ATR RES length (Initiator mode) */
DiegoOstuni 0:75fc82583a41 304 }Target; /*!< Target */
DiegoOstuni 0:75fc82583a41 305 struct {
DiegoOstuni 0:75fc82583a41 306 rfalNfcDepAtrReq ATR_REQ; /*!< ATR REQ (Target mode) */
DiegoOstuni 0:75fc82583a41 307 uint8_t ATR_REQLen; /*!< ATR REQ length (Target mode) */
DiegoOstuni 0:75fc82583a41 308 }Initiator; /*!< Initiator */
DiegoOstuni 0:75fc82583a41 309 } rfalNfcDepActivation;
DiegoOstuni 0:75fc82583a41 310
DiegoOstuni 0:75fc82583a41 311
DiegoOstuni 0:75fc82583a41 312 /*! NFC-DEP device Info */
DiegoOstuni 0:75fc82583a41 313 typedef struct {
DiegoOstuni 0:75fc82583a41 314 uint8_t GBLen; /*!< General Bytes length */
DiegoOstuni 0:75fc82583a41 315 uint8_t WT; /*!< FWT to be used (ignored in Listen Mode) */
DiegoOstuni 0:75fc82583a41 316 uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
DiegoOstuni 0:75fc82583a41 317 uint32_t dFWT; /*!< Delta FWT to be used */
DiegoOstuni 0:75fc82583a41 318 uint8_t LR; /*!< Length Reduction coding the max payload */
DiegoOstuni 0:75fc82583a41 319 uint16_t FS; /*!< Frame Size */
DiegoOstuni 0:75fc82583a41 320 rfalBitRate DSI; /*!< Bit Rate coding from Initiator to Target */
DiegoOstuni 0:75fc82583a41 321 rfalBitRate DRI; /*!< Bit Rate coding from Target to Initiator */
DiegoOstuni 0:75fc82583a41 322 uint8_t DID; /*!< Device ID (RFAL_NFCDEP_DID_NO if no DID) */
DiegoOstuni 0:75fc82583a41 323 uint8_t NAD; /*!< Node ADdress (RFAL_NFCDEP_NAD_NO if no NAD)*/
DiegoOstuni 0:75fc82583a41 324 } rfalNfcDepInfo;
DiegoOstuni 0:75fc82583a41 325
DiegoOstuni 0:75fc82583a41 326
DiegoOstuni 0:75fc82583a41 327 /*! NFC-DEP Device structure */
DiegoOstuni 0:75fc82583a41 328 typedef struct {
DiegoOstuni 0:75fc82583a41 329 rfalNfcDepActivation activation; /*!< Activation Info */
DiegoOstuni 0:75fc82583a41 330 rfalNfcDepInfo info; /*!< NFC-DEP device Info */
DiegoOstuni 0:75fc82583a41 331 } rfalNfcDepDevice;
DiegoOstuni 0:75fc82583a41 332
DiegoOstuni 0:75fc82583a41 333
DiegoOstuni 0:75fc82583a41 334 /*! NFCIP Protocol structure for P2P Target
DiegoOstuni 0:75fc82583a41 335 *
DiegoOstuni 0:75fc82583a41 336 * operParam : derives from NFC-Forum NCI NFC-DEP Operation Parameter
DiegoOstuni 0:75fc82583a41 337 * NCI 1.1 Table 86: NFC-DEP Operation Parameter
DiegoOstuni 0:75fc82583a41 338 * and it's a bit mask composed as:
DiegoOstuni 0:75fc82583a41 339 * [ 0000b
DiegoOstuni 0:75fc82583a41 340 * | Chain SHALL use max. Transport Data Byte[1b]
DiegoOstuni 0:75fc82583a41 341 * | I-PDU with no Transport Data SHALL NOT be sent [1b]
DiegoOstuni 0:75fc82583a41 342 * | NFC-DEP Target SHALL NOT send RTOX request [1b]
DiegoOstuni 0:75fc82583a41 343 * ]
DiegoOstuni 0:75fc82583a41 344 *
DiegoOstuni 0:75fc82583a41 345 */
DiegoOstuni 0:75fc82583a41 346 typedef struct{
DiegoOstuni 0:75fc82583a41 347 rfalNfcDepCommMode commMode; /*!< Initiator in Active P2P or Passive P2P*/
DiegoOstuni 0:75fc82583a41 348 uint8_t operParam; /*!< NFC-DEP Operation Parameter */
DiegoOstuni 0:75fc82583a41 349 uint8_t* nfcid; /*!< Initiator's NFCID2 or NFCID3 */
DiegoOstuni 0:75fc82583a41 350 uint8_t nfcidLen; /*!< Initiator's NFCID length (NFCID2/3) */
DiegoOstuni 0:75fc82583a41 351 uint8_t DID; /*!< Initiator's Device ID DID */
DiegoOstuni 0:75fc82583a41 352 uint8_t NAD; /*!< Initiator's Node ID NAD */
DiegoOstuni 0:75fc82583a41 353 uint8_t BS; /*!< Initiator's Bit Rates supported in Tx */
DiegoOstuni 0:75fc82583a41 354 uint8_t BR; /*!< Initiator's Bit Rates supported in Rx */
DiegoOstuni 0:75fc82583a41 355 uint8_t LR; /*!< Initiator's Length reduction */
DiegoOstuni 0:75fc82583a41 356 uint8_t* GB; /*!< Initiator's General Bytes (Gi) */
DiegoOstuni 0:75fc82583a41 357 uint8_t GBLen; /*!< Initiator's General Bytes length */
DiegoOstuni 0:75fc82583a41 358 } rfalNfcDepAtrParam;
DiegoOstuni 0:75fc82583a41 359
DiegoOstuni 0:75fc82583a41 360
DiegoOstuni 0:75fc82583a41 361 /*! Structure of parameters to be passed in for nfcDepListenStartActivation */
DiegoOstuni 0:75fc82583a41 362 typedef struct
DiegoOstuni 0:75fc82583a41 363 {
DiegoOstuni 0:75fc82583a41 364 rfalNfcDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
DiegoOstuni 0:75fc82583a41 365 uint16_t *rxLen; /*!< Receive INF data length in bytes*/
DiegoOstuni 0:75fc82583a41 366 bool *isRxChaining; /*!< Received data is not complete */
DiegoOstuni 0:75fc82583a41 367 rfalNfcDepDevice *nfcDepDev; /*!< NFC-DEP device info */
DiegoOstuni 0:75fc82583a41 368 } rfalNfcDepListenActvParam;
DiegoOstuni 0:75fc82583a41 369
DiegoOstuni 0:75fc82583a41 370
DiegoOstuni 0:75fc82583a41 371 /*! NFCIP Protocol structure for P2P Target
DiegoOstuni 0:75fc82583a41 372 *
DiegoOstuni 0:75fc82583a41 373 * operParam : derives from NFC-Forum NCI NFC-DEP Operation Parameter
DiegoOstuni 0:75fc82583a41 374 * NCI 1.1 Table 86: NFC-DEP Operation Parameter
DiegoOstuni 0:75fc82583a41 375 * and it's a bit mask composed as:
DiegoOstuni 0:75fc82583a41 376 * [ 0000b
DiegoOstuni 0:75fc82583a41 377 * | Chain SHALL use max. Transport Data Byte[1b]
DiegoOstuni 0:75fc82583a41 378 * | I-PDU with no Transport Data SHALL NOT be sent [1b]
DiegoOstuni 0:75fc82583a41 379 * | NFC-DEP Target SHALL NOT send RTOX request [1b]
DiegoOstuni 0:75fc82583a41 380 * ]
DiegoOstuni 0:75fc82583a41 381 *
DiegoOstuni 0:75fc82583a41 382 */
DiegoOstuni 0:75fc82583a41 383 typedef struct{
DiegoOstuni 0:75fc82583a41 384 rfalNfcDepCommMode commMode; /*!< Target in Active P2P or Passive P2P */
DiegoOstuni 0:75fc82583a41 385 uint8_t nfcid3[RFAL_NFCDEP_NFCID3_LEN]; /*!< Target's NFCID3 */
DiegoOstuni 0:75fc82583a41 386 uint8_t bst; /*!< Target's Bit Rates supported in Tx */
DiegoOstuni 0:75fc82583a41 387 uint8_t brt; /*!< Target's Bit Rates supported in Rx */
DiegoOstuni 0:75fc82583a41 388 uint8_t to; /*!< Target's timeout (TO) value */
DiegoOstuni 0:75fc82583a41 389 uint8_t ppt; /*!< Target's Presence optional Params(PPt)*/
DiegoOstuni 0:75fc82583a41 390 uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Target's General Bytes (Gt) */
DiegoOstuni 0:75fc82583a41 391 uint8_t GBtLen; /*!< Target's General Bytes length */
DiegoOstuni 0:75fc82583a41 392 uint8_t operParam; /*!< NFC-DEP Operation Parameter */
DiegoOstuni 0:75fc82583a41 393 } rfalNfcDepTargetParam;
DiegoOstuni 0:75fc82583a41 394
DiegoOstuni 0:75fc82583a41 395
DiegoOstuni 0:75fc82583a41 396 /*! Structure of parameters to be passed in for nfcDepStartIpduTransceive */
DiegoOstuni 0:75fc82583a41 397 typedef struct
DiegoOstuni 0:75fc82583a41 398 {
DiegoOstuni 0:75fc82583a41 399 rfalNfcDepBufFormat *txBuf; /*!< Transmit Buffer struct reference */
DiegoOstuni 0:75fc82583a41 400 uint16_t txBufLen; /*!< Transmit Buffer INF field length in bytes */
DiegoOstuni 0:75fc82583a41 401 bool isTxChaining; /*!< Transmit data is not complete */
DiegoOstuni 0:75fc82583a41 402 rfalNfcDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
DiegoOstuni 0:75fc82583a41 403 uint16_t *rxLen; /*!< Receive INF data length */
DiegoOstuni 0:75fc82583a41 404 bool *isRxChaining; /*!< Received data is not complete */
DiegoOstuni 0:75fc82583a41 405 uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
DiegoOstuni 0:75fc82583a41 406 uint32_t dFWT; /*!< Delta FWT to be used */
DiegoOstuni 0:75fc82583a41 407 uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
DiegoOstuni 0:75fc82583a41 408 uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
DiegoOstuni 0:75fc82583a41 409 } rfalNfcDepTxRxParam;
DiegoOstuni 0:75fc82583a41 410
DiegoOstuni 0:75fc82583a41 411
DiegoOstuni 0:75fc82583a41 412 /*
DiegoOstuni 0:75fc82583a41 413 * *****************************************************************************
DiegoOstuni 0:75fc82583a41 414 * GLOBAL VARIABLE DECLARATIONS
DiegoOstuni 0:75fc82583a41 415 ******************************************************************************
DiegoOstuni 0:75fc82583a41 416 */
DiegoOstuni 0:75fc82583a41 417
DiegoOstuni 0:75fc82583a41 418
DiegoOstuni 0:75fc82583a41 419 /*
DiegoOstuni 0:75fc82583a41 420 ******************************************************************************
DiegoOstuni 0:75fc82583a41 421 * GLOBAL FUNCTION PROTOTYPES
DiegoOstuni 0:75fc82583a41 422 ******************************************************************************
DiegoOstuni 0:75fc82583a41 423 */
DiegoOstuni 0:75fc82583a41 424
DiegoOstuni 0:75fc82583a41 425 /*!
DiegoOstuni 0:75fc82583a41 426 ******************************************************************************
DiegoOstuni 0:75fc82583a41 427 * \brief NFCIP Initialize
DiegoOstuni 0:75fc82583a41 428 *
DiegoOstuni 0:75fc82583a41 429 * This method resets all NFC-DEP inner states, counters and context and sets
DiegoOstuni 0:75fc82583a41 430 * default values
DiegoOstuni 0:75fc82583a41 431 *
DiegoOstuni 0:75fc82583a41 432 ******************************************************************************
DiegoOstuni 0:75fc82583a41 433 */
DiegoOstuni 0:75fc82583a41 434 void rfalNfcDepInitialize( void );
DiegoOstuni 0:75fc82583a41 435
DiegoOstuni 0:75fc82583a41 436
DiegoOstuni 0:75fc82583a41 437 /*!
DiegoOstuni 0:75fc82583a41 438 ******************************************************************************
DiegoOstuni 0:75fc82583a41 439 * \brief Set deactivating callback
DiegoOstuni 0:75fc82583a41 440 *
DiegoOstuni 0:75fc82583a41 441 * Sets the deactivating callback so that nfcip layer can check if upper layer
DiegoOstuni 0:75fc82583a41 442 * has a deactivation pending, and not perform error recovery upon specific
DiegoOstuni 0:75fc82583a41 443 * errors
DiegoOstuni 0:75fc82583a41 444 *
DiegoOstuni 0:75fc82583a41 445 * \param[in] pFunc : method pointer to deactivation flag check
DiegoOstuni 0:75fc82583a41 446 ******************************************************************************
DiegoOstuni 0:75fc82583a41 447 */
DiegoOstuni 0:75fc82583a41 448 void rfalNfcDepSetDeactivatingCallback( rfalNfcDepDeactCallback pFunc );
DiegoOstuni 0:75fc82583a41 449
DiegoOstuni 0:75fc82583a41 450
DiegoOstuni 0:75fc82583a41 451 /*!
DiegoOstuni 0:75fc82583a41 452 ******************************************************************************
DiegoOstuni 0:75fc82583a41 453 * \brief Calculate Response Waiting Time
DiegoOstuni 0:75fc82583a41 454 *
DiegoOstuni 0:75fc82583a41 455 * Calculates the Response Waiting Time (RWT) from the given Waiting Time (WT)
DiegoOstuni 0:75fc82583a41 456 *
DiegoOstuni 0:75fc82583a41 457 * \param[in] wt : the WT value to calculate RWT
DiegoOstuni 0:75fc82583a41 458 *
DiegoOstuni 0:75fc82583a41 459 * \return RWT value
DiegoOstuni 0:75fc82583a41 460 ******************************************************************************
DiegoOstuni 0:75fc82583a41 461 */
DiegoOstuni 0:75fc82583a41 462 uint32_t rfalNfcDepCalculateRWT( uint8_t wt );
DiegoOstuni 0:75fc82583a41 463
DiegoOstuni 0:75fc82583a41 464
DiegoOstuni 0:75fc82583a41 465 /*!
DiegoOstuni 0:75fc82583a41 466 ******************************************************************************
DiegoOstuni 0:75fc82583a41 467 * \brief NFC-DEP Initiator ATR (Attribute Request)
DiegoOstuni 0:75fc82583a41 468 *
DiegoOstuni 0:75fc82583a41 469 * This method configures the NFC-DEP layer with given parameters and then
DiegoOstuni 0:75fc82583a41 470 * sends an ATR to the Target with and checks for a valid response response
DiegoOstuni 0:75fc82583a41 471 *
DiegoOstuni 0:75fc82583a41 472 * \param[in] param : parameters to initialize and compose the ATR
DiegoOstuni 0:75fc82583a41 473 * \param[out] atrRes : location to store the ATR_RES
DiegoOstuni 0:75fc82583a41 474 * \param[out] atrResLen : length of the ATR_RES received
DiegoOstuni 0:75fc82583a41 475 *
DiegoOstuni 0:75fc82583a41 476 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 477 * \return ERR_TIMEOUT : Timeout occurred
DiegoOstuni 0:75fc82583a41 478 * \return ERR_PROTO : Protocol error occurred
DiegoOstuni 0:75fc82583a41 479 ******************************************************************************
DiegoOstuni 0:75fc82583a41 480 */
DiegoOstuni 0:75fc82583a41 481 ReturnCode rfalNfcDepATR( rfalNfcDepAtrParam* param, rfalNfcDepAtrRes *atrRes, uint8_t* atrResLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 482
DiegoOstuni 0:75fc82583a41 483
DiegoOstuni 0:75fc82583a41 484 /*!
DiegoOstuni 0:75fc82583a41 485 ******************************************************************************
DiegoOstuni 0:75fc82583a41 486 * \brief NFC-DEP Initiator PSL (Parameter Selection)
DiegoOstuni 0:75fc82583a41 487 *
DiegoOstuni 0:75fc82583a41 488 * This method sends a PSL to the Target with the given parameters and checks
DiegoOstuni 0:75fc82583a41 489 * for a valid response response
DiegoOstuni 0:75fc82583a41 490 *
DiegoOstuni 0:75fc82583a41 491 * The parameters must be coded according to Digital 1.1 16.7.1
DiegoOstuni 0:75fc82583a41 492 *
DiegoOstuni 0:75fc82583a41 493 * \param[in] BRS : the selected Bit Rates for Initiator and Target
DiegoOstuni 0:75fc82583a41 494 * \param[in] FSL : the maximum length of Commands and Responses
DiegoOstuni 0:75fc82583a41 495 *
DiegoOstuni 0:75fc82583a41 496 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 497 * \return ERR_TIMEOUT : Timeout occurred
DiegoOstuni 0:75fc82583a41 498 * \return ERR_PROTO : Protocol error occurred
DiegoOstuni 0:75fc82583a41 499 ******************************************************************************
DiegoOstuni 0:75fc82583a41 500 */
DiegoOstuni 0:75fc82583a41 501 ReturnCode rfalNfcDepPSL( uint8_t BRS, uint8_t FSL, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 502
DiegoOstuni 0:75fc82583a41 503
DiegoOstuni 0:75fc82583a41 504 /*!
DiegoOstuni 0:75fc82583a41 505 ******************************************************************************
DiegoOstuni 0:75fc82583a41 506 * \brief NFC-DEP Initiator DSL (Deselect)
DiegoOstuni 0:75fc82583a41 507 *
DiegoOstuni 0:75fc82583a41 508 * This method checks if the NFCIP module is configured as initiator and if
DiegoOstuni 0:75fc82583a41 509 * so sends a DSL REQ, waits the target's response and checks it
DiegoOstuni 0:75fc82583a41 510 *
DiegoOstuni 0:75fc82583a41 511 * In case of performing as target no action is taken
DiegoOstuni 0:75fc82583a41 512 *
DiegoOstuni 0:75fc82583a41 513 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 514 * \return ERR_TIMEOUT : Timeout occurred
DiegoOstuni 0:75fc82583a41 515 * \return ERR_MAX_RERUNS : Timeout occurred
DiegoOstuni 0:75fc82583a41 516 * \return ERR_PROTO : Protocol error occurred
DiegoOstuni 0:75fc82583a41 517 ******************************************************************************
DiegoOstuni 0:75fc82583a41 518 */
DiegoOstuni 0:75fc82583a41 519 ReturnCode rfalNfcDepDSL( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 520
DiegoOstuni 0:75fc82583a41 521
DiegoOstuni 0:75fc82583a41 522 /*!
DiegoOstuni 0:75fc82583a41 523 ******************************************************************************
DiegoOstuni 0:75fc82583a41 524 * \brief NFC-DEP Initiator RLS (Release)
DiegoOstuni 0:75fc82583a41 525 *
DiegoOstuni 0:75fc82583a41 526 * This method checks if the NFCIP module is configured as initiator and if
DiegoOstuni 0:75fc82583a41 527 * so sends a RLS REQ, waits target's response and checks it
DiegoOstuni 0:75fc82583a41 528 *
DiegoOstuni 0:75fc82583a41 529 * In case of performing as target no action is taken
DiegoOstuni 0:75fc82583a41 530 *
DiegoOstuni 0:75fc82583a41 531 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 532 * \return ERR_TIMEOUT : Timeout occurred
DiegoOstuni 0:75fc82583a41 533 * \return ERR_MAX_RERUNS : Timeout occurred
DiegoOstuni 0:75fc82583a41 534 * \return ERR_PROTO : Protocol error occurred
DiegoOstuni 0:75fc82583a41 535 ******************************************************************************
DiegoOstuni 0:75fc82583a41 536 */
DiegoOstuni 0:75fc82583a41 537 ReturnCode rfalNfcDepRLS( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 538
DiegoOstuni 0:75fc82583a41 539
DiegoOstuni 0:75fc82583a41 540 /*!
DiegoOstuni 0:75fc82583a41 541 *****************************************************************************
DiegoOstuni 0:75fc82583a41 542 * \brief NFC-DEP Initiator Handle Activation
DiegoOstuni 0:75fc82583a41 543 *
DiegoOstuni 0:75fc82583a41 544 * This performs a Activation into NFC-DEP layer with the given
DiegoOstuni 0:75fc82583a41 545 * parameters. It sends ATR_REQ and if the higher bit rates are supported by
DiegoOstuni 0:75fc82583a41 546 * both devices it additionally sends PSL
DiegoOstuni 0:75fc82583a41 547 * Once Activated all details of the device are provided on nfcDepDev
DiegoOstuni 0:75fc82583a41 548 *
DiegoOstuni 0:75fc82583a41 549 * \param[in] param : required parameters to initialize and send ATR_REQ
DiegoOstuni 0:75fc82583a41 550 * \param[in] desiredBR : Desired bit rate supported by the Poller
DiegoOstuni 0:75fc82583a41 551 * \param[out] nfcDepDev : NFC-DEP information of the activated Listen device
DiegoOstuni 0:75fc82583a41 552 *
DiegoOstuni 0:75fc82583a41 553 * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
DiegoOstuni 0:75fc82583a41 554 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 555 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 556 * \return ERR_TIMEOUT : Timeout error
DiegoOstuni 0:75fc82583a41 557 * \return ERR_PAR : Parity error detected
DiegoOstuni 0:75fc82583a41 558 * \return ERR_CRC : CRC error detected
DiegoOstuni 0:75fc82583a41 559 * \return ERR_FRAMING : Framing error detected
DiegoOstuni 0:75fc82583a41 560 * \return ERR_PROTO : Protocol error detected
DiegoOstuni 0:75fc82583a41 561 * \return ERR_NONE : No error, activation successful
DiegoOstuni 0:75fc82583a41 562 *****************************************************************************
DiegoOstuni 0:75fc82583a41 563 */
DiegoOstuni 0:75fc82583a41 564 ReturnCode rfalNfcDepInitiatorHandleActivation( rfalNfcDepAtrParam* param, rfalBitRate desiredBR, rfalNfcDepDevice* nfcDepDev, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 565
DiegoOstuni 0:75fc82583a41 566
DiegoOstuni 0:75fc82583a41 567 /*!
DiegoOstuni 0:75fc82583a41 568 ******************************************************************************
DiegoOstuni 0:75fc82583a41 569 * \brief Check if buffer contains valid ATR_REQ
DiegoOstuni 0:75fc82583a41 570 *
DiegoOstuni 0:75fc82583a41 571 * This method checks if the given ATR_REQ is valid
DiegoOstuni 0:75fc82583a41 572 *
DiegoOstuni 0:75fc82583a41 573 *
DiegoOstuni 0:75fc82583a41 574 * \param[in] buf : buffer holding Initiator's received request
DiegoOstuni 0:75fc82583a41 575 * \param[in] bufLen : size of the msg contained on the buf in Bytes
DiegoOstuni 0:75fc82583a41 576 * \param[out] nfcid3 : pointer to where the NFCID3 may be outputed,
DiegoOstuni 0:75fc82583a41 577 * nfcid3 has NFCF_SENSF_NFCID3_LEN as length
DiegoOstuni 0:75fc82583a41 578 * Pass NULL if output parameter not desired
DiegoOstuni 0:75fc82583a41 579 *
DiegoOstuni 0:75fc82583a41 580 * \return true : Valid ATR_REQ received, the ATR_RES has been computed in txBuf
DiegoOstuni 0:75fc82583a41 581 * \return false : Invalid protocol request
DiegoOstuni 0:75fc82583a41 582 *
DiegoOstuni 0:75fc82583a41 583 ******************************************************************************
DiegoOstuni 0:75fc82583a41 584 */
DiegoOstuni 0:75fc82583a41 585 bool rfalNfcDepIsAtrReq( uint8_t* buf, uint16_t bufLen, uint8_t* nfcid3 );
DiegoOstuni 0:75fc82583a41 586
DiegoOstuni 0:75fc82583a41 587
DiegoOstuni 0:75fc82583a41 588 /*!
DiegoOstuni 0:75fc82583a41 589 ******************************************************************************
DiegoOstuni 0:75fc82583a41 590 * \brief Check is Target has received ATR
DiegoOstuni 0:75fc82583a41 591 *
DiegoOstuni 0:75fc82583a41 592 * This method checks if the NFCIP module is configured as target and if a
DiegoOstuni 0:75fc82583a41 593 * ATR REQ has been received ( whether is in activation or in data exchange)
DiegoOstuni 0:75fc82583a41 594 *
DiegoOstuni 0:75fc82583a41 595 * \return true : a ATR has already been received
DiegoOstuni 0:75fc82583a41 596 * \return false : no ATR has been received
DiegoOstuni 0:75fc82583a41 597 ******************************************************************************
DiegoOstuni 0:75fc82583a41 598 */
DiegoOstuni 0:75fc82583a41 599 bool rfalNfcDepTargetRcvdATR( void );
DiegoOstuni 0:75fc82583a41 600
DiegoOstuni 0:75fc82583a41 601 /*!
DiegoOstuni 0:75fc82583a41 602 *****************************************************************************
DiegoOstuni 0:75fc82583a41 603 * \brief NFCDEP Start Listen Activation Handling
DiegoOstuni 0:75fc82583a41 604 *
DiegoOstuni 0:75fc82583a41 605 * Start Activation Handling and setup to receive first frame which may
DiegoOstuni 0:75fc82583a41 606 * contain complete or partial DEP-REQ after activation is completed
DiegoOstuni 0:75fc82583a41 607 *
DiegoOstuni 0:75fc82583a41 608 * Pass in ATR_REQ for NFC-DEP to handle ATR_RES. The Activation Handling
DiegoOstuni 0:75fc82583a41 609 * handles ATR_RES and PSL_RES if a PSL_REQ is received
DiegoOstuni 0:75fc82583a41 610 *
DiegoOstuni 0:75fc82583a41 611 * Activation is completed if PSL_RES is sent or if first I-PDU is received
DiegoOstuni 0:75fc82583a41 612 *
DiegoOstuni 0:75fc82583a41 613 * \ref rfalNfcDepListenGetActivationStatus() provide status of the
DiegoOstuni 0:75fc82583a41 614 * ongoing activation
DiegoOstuni 0:75fc82583a41 615 *
DiegoOstuni 0:75fc82583a41 616 * \warning nfcDepGetTransceiveStatus() shall be called right after activation
DiegoOstuni 0:75fc82583a41 617 * is completed (i.e. rfalNfcDepListenGetActivationStatus() return ERR_NONE)
DiegoOstuni 0:75fc82583a41 618 * to check for first received frame.
DiegoOstuni 0:75fc82583a41 619 *
DiegoOstuni 0:75fc82583a41 620 * \param[in] param : Target parameters to be used
DiegoOstuni 0:75fc82583a41 621 * \param[in] atrReq : reference to buffer containing ATR_REQ
DiegoOstuni 0:75fc82583a41 622 * \param[in] atrReqLength: Length of ATR_REQ
DiegoOstuni 0:75fc82583a41 623 * \param[out] rxParam : references to buffer, length and chaining indication
DiegoOstuni 0:75fc82583a41 624 * for first complete LLCP to be received
DiegoOstuni 0:75fc82583a41 625 *
DiegoOstuni 0:75fc82583a41 626 * \return ERR_NONE : ATR_REQ is valid and activation ongoing
DiegoOstuni 0:75fc82583a41 627 * \return ERR_PARAM : ATR_REQ or other params are invalid
DiegoOstuni 0:75fc82583a41 628 * \return ERR_LINK_LOSS : Remote Field is turned off
DiegoOstuni 0:75fc82583a41 629 *****************************************************************************
DiegoOstuni 0:75fc82583a41 630 */
DiegoOstuni 0:75fc82583a41 631 ReturnCode rfalNfcDepListenStartActivation( rfalNfcDepTargetParam *param, uint8_t *atrReq, uint16_t atrReqLength, rfalNfcDepListenActvParam rxParam, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 632
DiegoOstuni 0:75fc82583a41 633
DiegoOstuni 0:75fc82583a41 634 /*!
DiegoOstuni 0:75fc82583a41 635 *****************************************************************************
DiegoOstuni 0:75fc82583a41 636 * \brief Get the current NFC-DEP Activation Status
DiegoOstuni 0:75fc82583a41 637 *
DiegoOstuni 0:75fc82583a41 638 * \return ERR_NONE : Activation has completed successfully
DiegoOstuni 0:75fc82583a41 639 * \return ERR_BUSY : Activation is ongoing
DiegoOstuni 0:75fc82583a41 640 * \return ERR_LINK_LOSS : Remote Field was turned off
DiegoOstuni 0:75fc82583a41 641 *****************************************************************************
DiegoOstuni 0:75fc82583a41 642 */
DiegoOstuni 0:75fc82583a41 643 ReturnCode rfalNfcDepListenGetActivationStatus( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 644
DiegoOstuni 0:75fc82583a41 645 /*!
DiegoOstuni 0:75fc82583a41 646 *****************************************************************************
DiegoOstuni 0:75fc82583a41 647 * \brief Start Transceive
DiegoOstuni 0:75fc82583a41 648 *
DiegoOstuni 0:75fc82583a41 649 * Transceives a complete or partial DEP block
DiegoOstuni 0:75fc82583a41 650 *
DiegoOstuni 0:75fc82583a41 651 * The txBuf contains complete or partial of DEP to be transmitted.
DiegoOstuni 0:75fc82583a41 652 * The Prologue field of the I-PDU is handled internally
DiegoOstuni 0:75fc82583a41 653 *
DiegoOstuni 0:75fc82583a41 654 * If the buffer contains partial LLCP and is not the last block, then
DiegoOstuni 0:75fc82583a41 655 * isTxChaining must be set to true
DiegoOstuni 0:75fc82583a41 656 *
DiegoOstuni 0:75fc82583a41 657 * \param[in] param: reference parameters to be used for the Transceive
DiegoOstuni 0:75fc82583a41 658 *
DiegoOstuni 0:75fc82583a41 659 * \return ERR_PARAM : Bad request
DiegoOstuni 0:75fc82583a41 660 * \return ERR_WRONG_STATE : The module is not in a proper state
DiegoOstuni 0:75fc82583a41 661 * \return ERR_NONE : The Transceive request has been started
DiegoOstuni 0:75fc82583a41 662 *****************************************************************************
DiegoOstuni 0:75fc82583a41 663 */
DiegoOstuni 0:75fc82583a41 664 ReturnCode rfalNfcDepStartTransceive( rfalNfcDepTxRxParam *param );
DiegoOstuni 0:75fc82583a41 665
DiegoOstuni 0:75fc82583a41 666
DiegoOstuni 0:75fc82583a41 667 /*!
DiegoOstuni 0:75fc82583a41 668 *****************************************************************************
DiegoOstuni 0:75fc82583a41 669 * \brief Return the Transceive status
DiegoOstuni 0:75fc82583a41 670 *
DiegoOstuni 0:75fc82583a41 671 * Returns the status of the NFC-DEP Transceive
DiegoOstuni 0:75fc82583a41 672 *
DiegoOstuni 0:75fc82583a41 673 * \warning When the other device is performing chaining once a chained
DiegoOstuni 0:75fc82583a41 674 * block is received the error ERR_AGAIN is sent. At this point
DiegoOstuni 0:75fc82583a41 675 * caller must handle the received data immediately.
DiegoOstuni 0:75fc82583a41 676 * When ERR_AGAIN is returned an ACK has already been sent to
DiegoOstuni 0:75fc82583a41 677 * the other device and the next block might be incoming.
DiegoOstuni 0:75fc82583a41 678 * If rfalWorker() is called frequently it will place the next
DiegoOstuni 0:75fc82583a41 679 * block on the given buffer
DiegoOstuni 0:75fc82583a41 680 *
DiegoOstuni 0:75fc82583a41 681 * \return ERR_NONE : Transceive has been completed successfully
DiegoOstuni 0:75fc82583a41 682 * \return ERR_BUSY : Transceive is ongoing
DiegoOstuni 0:75fc82583a41 683 * \return ERR_PROTO : Protocol error occurred
DiegoOstuni 0:75fc82583a41 684 * \return ERR_TIMEOUT : Timeout error occurred
DiegoOstuni 0:75fc82583a41 685 * \return ERR_SLEEP_REQ : Deselect has been received and responded
DiegoOstuni 0:75fc82583a41 686 * \return ERR_NOMEM : The received I-PDU does not fit into the
DiegoOstuni 0:75fc82583a41 687 * receive buffer
DiegoOstuni 0:75fc82583a41 688 * \return ERR_LINK_LOSS : Communication is lost because Reader/Writer
DiegoOstuni 0:75fc82583a41 689 * has turned off its field
DiegoOstuni 0:75fc82583a41 690 * \return ERR_AGAIN : received one chaining block, continue to call
DiegoOstuni 0:75fc82583a41 691 * this method to retrieve the remaining blocks
DiegoOstuni 0:75fc82583a41 692 *****************************************************************************
DiegoOstuni 0:75fc82583a41 693 */
DiegoOstuni 0:75fc82583a41 694 ReturnCode rfalNfcDepGetTransceiveStatus( SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
DiegoOstuni 0:75fc82583a41 695
DiegoOstuni 0:75fc82583a41 696
DiegoOstuni 0:75fc82583a41 697 #endif /* RFAL_NFCDEP_H_ */
DiegoOstuni 0:75fc82583a41 698
DiegoOstuni 0:75fc82583a41 699 /**
DiegoOstuni 0:75fc82583a41 700 * @}
DiegoOstuni 0:75fc82583a41 701 *
DiegoOstuni 0:75fc82583a41 702 * @}
DiegoOstuni 0:75fc82583a41 703 *
DiegoOstuni 0:75fc82583a41 704 * @}
DiegoOstuni 0:75fc82583a41 705 */