rfal_isoDep.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R391x firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file rfal_isoDep.h
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief Implementation of ISO-DEP protocol
  31. *
  32. * This implementation was based on the following specs:
  33. * - ISO/IEC 14443-4 2nd Edition 2008-07-15
  34. * - NFC Forum Digital Protocol 1.1 2014-01-14
  35. *
  36. *
  37. * \addtogroup RFAL
  38. * @{
  39. *
  40. * \addtogroup RFAL-AL
  41. * \brief RFAL Abstraction Layer
  42. * @{
  43. *
  44. * \addtogroup ISO-DEP
  45. * \brief RFAL ISO-DEP Module
  46. * @{
  47. *
  48. */
  49. #ifndef RFAL_ISODEP_H_
  50. #define RFAL_ISODEP_H_
  51. /*
  52. ******************************************************************************
  53. * INCLUDES
  54. ******************************************************************************
  55. */
  56. #include "platform.h"
  57. #include "rfal_nfcb.h"
  58. /*
  59. ******************************************************************************
  60. * ENABLE SWITCH
  61. ******************************************************************************
  62. */
  63. #ifndef RFAL_FEATURE_ISO_DEP
  64. #define RFAL_FEATURE_ISO_DEP false /*!< ISO-DEP module configuration missing. Disabled by default */
  65. #endif
  66. /* If module is disabled remove the need for the user to set lengths */
  67. #if !RFAL_FEATURE_ISO_DEP
  68. #undef RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN
  69. #undef RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN
  70. #define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN (1U) /*!< ISO-DEP I-Block max length, set to "none" */
  71. #define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN (1U) /*!< ISO-DEP APDU max length, set to "none" */
  72. #endif /* !RFAL_FEATURE_NFC_DEP */
  73. /*
  74. ******************************************************************************
  75. * DEFINES
  76. ******************************************************************************
  77. */
  78. #define RFAL_ISODEP_PROLOGUE_SIZE (3U) /*!< Length of Prologue Field for I-Block Format */
  79. #define RFAL_ISODEP_PCB_LEN (1U) /*!< PCB length */
  80. #define RFAL_ISODEP_DID_LEN (1U) /*!< DID length */
  81. #define RFAL_ISODEP_NAD_LEN (1U) /*!< NAD length */
  82. #define RFAL_ISODEP_NO_DID (0x00U) /*!< DID value indicating the ISO-DEP layer not to use DID */
  83. #define RFAL_ISODEP_NO_NAD (0xFFU) /*!< NAD value indicating the ISO-DEP layer not to use NAD */
  84. #define RFAL_ISODEP_FWI_MASK (0xF0U) /*!< Mask bits of FWI */
  85. #define RFAL_ISODEP_FWI_SHIFT (4U) /*!< Shift val of FWI */
  86. #define RFAL_ISODEP_FWI_DEFAULT (4U) /*!< Default value for FWI Digital 1.0 11.6.2.17 */
  87. #define RFAL_ISODEP_ADV_FEATURE (0x0FU) /*!< Indicate 256 Bytes FSD and Advanc Proto Feature support:NAD & DID */
  88. #define RFAL_ISODEP_DID_MAX (14U) /*!< Maximum DID value */
  89. #define RFAL_ISODEP_BRI_MASK (0x07U) /*!< Mask bits for Poll to Listen Send bitrate */
  90. #define RFAL_ISODEP_BSI_MASK (0x70U) /*!< Mask bits for Listen to Poll Send bitrate */
  91. #define RFAL_ISODEP_SAME_BITRATE_MASK (0x80U) /*!< Mask bit indicate only same bit rate D for both direction support */
  92. #define RFAL_ISODEP_BITRATE_RFU_MASK (0x08U) /*!< Mask bit for RFU */
  93. /*! Maximum Frame Waiting Time = ((256 * 16/fc) * 2^FWImax) = ((256*16/fc)*2^14) = (67108864)/fc = 2^26 (1/fc) */
  94. #define RFAL_ISODEP_MAX_FWT ((uint32_t)1U<<26)
  95. #define RFAL_ISODEP_FSDI_DEFAULT RFAL_ISODEP_FSXI_256 /*!< Default Frame Size Integer in Poll mode */
  96. #define RFAL_ISODEP_FSX_KEEP (0xFFU) /*!< Flag to keep FSX from activation */
  97. #define RFAL_ISODEP_DEFAULT_FSCI RFAL_ISODEP_FSXI_256 /*!< FSCI default value to be used in Listen Mode */
  98. #define RFAL_ISODEP_DEFAULT_FSC RFAL_ISODEP_FSX_256 /*!< FSC default value (aligned RFAL_ISODEP_DEFAULT_FSCI) */
  99. #define RFAL_ISODEP_DEFAULT_SFGI (0U) /*!< SFGI Default value to be used in Listen Mode */
  100. #define RFAL_ISODEP_DEFAULT_FWI (8U) /*!< Default Listener FWI (Max) Digital 2.0 B7 & B3 */
  101. #define RFAL_ISODEP_APDU_MAX_LEN RFAL_ISODEP_FSX_1024 /*!< Max APDU length */
  102. #define RFAL_ISODEP_ATTRIB_RES_MBLI_NO_INFO (0x00U) /*!< MBLI indicating no information on its internal input buffer size */
  103. #define RFAL_ISODEP_ATTRIB_REQ_PARAM1_DEFAULT (0x00U) /*!< Default values of Param 1 of ATTRIB_REQ Digital 1.0 12.6.1.3-5 */
  104. #define RFAL_ISODEP_ATTRIB_HLINFO_LEN (32U) /*!< Maximum Size of Higher Layer Information */
  105. #define RFAL_ISODEP_ATS_HB_MAX_LEN (15U) /*!< Maximum length of Historical Bytes Digital 1.1 13.6.2.23 */
  106. #define RFAL_ISODEP_ATTRIB_REQ_MIN_LEN (9U) /*!< Minimum Length of ATTRIB_REQ command */
  107. #define RFAL_ISODEP_ATTRIB_RES_MIN_LEN (1U) /*!< Minimum Length of ATTRIB_RES response */
  108. #define RFAL_ISODEP_SPARAM_VALUES_MAX_LEN (16U) /*!< Maximum Length of the value field on S(PARAMETERS) */
  109. #define RFAL_ISODEP_SPARAM_TAG_BLOCKINFO (0xA0U) /*!< S(PARAMETERS) tag Block information */
  110. #define RFAL_ISODEP_SPARAM_TAG_BRREQ (0xA1U) /*!< S(PARAMETERS) tag Bit rates Request */
  111. #define RFAL_ISODEP_SPARAM_TAG_BRIND (0xA2U) /*!< S(PARAMETERS) tag Bit rates Indication */
  112. #define RFAL_ISODEP_SPARAM_TAG_BRACT (0xA3U) /*!< S(PARAMETERS) tag Bit rates Activation */
  113. #define RFAL_ISODEP_SPARAM_TAG_BRACK (0xA4U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement */
  114. #define RFAL_ISODEP_SPARAM_TAG_SUP_PCD2PICC (0x80U) /*!< S(PARAMETERS) tag Supported bit rates from PCD to PICC */
  115. #define RFAL_ISODEP_SPARAM_TAG_SUP_PICC2PCD (0x81U) /*!< S(PARAMETERS) tag Supported bit rates from PICC to PCD */
  116. #define RFAL_ISODEP_SPARAM_TAG_SUP_FRAME (0x82U) /*!< S(PARAMETERS) tag Supported framing options PICC to PCD */
  117. #define RFAL_ISODEP_SPARAM_TAG_SEL_PCD2PICC (0x83U) /*!< S(PARAMETERS) tag Selected bit rate from PCD to PICC */
  118. #define RFAL_ISODEP_SPARAM_TAG_SEL_PICC2PCD (0x84U) /*!< S(PARAMETERS) tag Selected bit rate from PICC to PCD */
  119. #define RFAL_ISODEP_SPARAM_TAG_SEL_FRAME (0x85U) /*!< S(PARAMETERS) tag Selected framing options PICC to PCD */
  120. #define RFAL_ISODEP_SPARAM_TAG_LEN (1) /*!< S(PARAMETERS) Tag Length */
  121. #define RFAL_ISODEP_SPARAM_TAG_BRREQ_LEN (0U) /*!< S(PARAMETERS) tag Bit rates Request Length */
  122. #define RFAL_ISODEP_SPARAM_TAG_PICC2PCD_LEN (2U) /*!< S(PARAMETERS) bit rates from PCD to PICC Length */
  123. #define RFAL_ISODEP_SPARAM_TAG_PCD2PICC_LEN (2U) /*!< S(PARAMETERS) bit rates from PICC to PCD Length */
  124. #define RFAL_ISODEP_SPARAM_TAG_BRACK_LEN (0U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement Length */
  125. #define RFAL_ISODEP_ATS_TA_DPL_212 (0x01U) /*!< ATS TA DSI 212 kbps support bit mask */
  126. #define RFAL_ISODEP_ATS_TA_DPL_424 (0x02U) /*!< ATS TA DSI 424 kbps support bit mask */
  127. #define RFAL_ISODEP_ATS_TA_DPL_848 (0x04U) /*!< ATS TA DSI 848 kbps support bit mask */
  128. #define RFAL_ISODEP_ATS_TA_DLP_212 (0x10U) /*!< ATS TA DSI 212 kbps support bit mask */
  129. #define RFAL_ISODEP_ATS_TA_DLP_424 (0x20U) /*!< ATS TA DRI 424 kbps support bit mask */
  130. #define RFAL_ISODEP_ATS_TA_DLP_848 (0x40U) /*!< ATS TA DRI 848 kbps support bit mask */
  131. #define RFAL_ISODEP_ATS_TA_SAME_D (0x80U) /*!< ATS TA same bit both directions bit mask */
  132. #define RFAL_ISODEP_ATS_TB_FWI_MASK (0xF0U) /*!< Mask bits for FWI (Frame Waiting Integer) in TB byte */
  133. #define RFAL_ISODEP_ATS_TB_SFGI_MASK (0x0FU) /*!< Mask bits for SFGI (Start-Up Frame Guard Integer) in TB byte */
  134. #define RFAL_ISODEP_ATS_T0_TA_PRESENCE_MASK (0x10U) /*!< Mask bit for TA presence */
  135. #define RFAL_ISODEP_ATS_T0_TB_PRESENCE_MASK (0x20U) /*!< Mask bit for TB presence */
  136. #define RFAL_ISODEP_ATS_T0_TC_PRESENCE_MASK (0x40U) /*!< Mask bit for TC presence */
  137. #define RFAL_ISODEP_ATS_T0_FSCI_MASK (0x0FU) /*!< Mask bit for FSCI presence */
  138. #define RFAL_ISODEP_ATS_T0_OFFSET (0x01U) /*!< Offset of T0 in ATS Response */
  139. #define RFAL_ISODEP_MAX_I_RETRYS (2U) /*!< Number of retries for a I-Block Digital 2.0 16.2.5.4 */
  140. #define RFAL_ISODEP_MAX_R_RETRYS (3U) /*!< Number of retries for a R-Block Digital 2.0 B9 - nRETRY ACK/NAK: [2,5] */
  141. #define RFAL_ISODEP_MAX_WTX_NACK_RETRYS (3U) /*!< Number of S(WTX) replied with NACK Digital 2.0 B9 - nRETRY WTX[2,5] */
  142. #define RFAL_ISODEP_MAX_WTX_RETRYS (20U) /*!< Number of overall S(WTX) retries Digital 2.0 16.2.5.2 */
  143. #define RFAL_ISODEP_MAX_WTX_RETRYS_ULTD (255U) /*!< Use unlimited number of overall S(WTX) */
  144. #define RFAL_ISODEP_MAX_DSL_RETRYS (0U) /*!< Number of retries for a S(DESELECT) Digital 2.0 B9 - nRETRY DESELECT: [0,5] */
  145. #define RFAL_ISODEP_RATS_RETRIES (1U) /*!< RATS retries upon fail Digital 2.0 B7 - nRETRY RATS [0,1] */
  146. /*! Frame Size for Proximity Card Integer definitions */
  147. typedef enum
  148. {
  149. RFAL_ISODEP_FSXI_16 = 0, /*!< Frame Size for Proximity Card Integer with 16 bytes */
  150. RFAL_ISODEP_FSXI_24 = 1, /*!< Frame Size for Proximity Card Integer with 24 bytes */
  151. RFAL_ISODEP_FSXI_32 = 2, /*!< Frame Size for Proximity Card Integer with 32 bytes */
  152. RFAL_ISODEP_FSXI_40 = 3, /*!< Frame Size for Proximity Card Integer with 40 bytes */
  153. RFAL_ISODEP_FSXI_48 = 4, /*!< Frame Size for Proximity Card Integer with 48 bytes */
  154. RFAL_ISODEP_FSXI_64 = 5, /*!< Frame Size for Proximity Card Integer with 64 bytes */
  155. RFAL_ISODEP_FSXI_96 = 6, /*!< Frame Size for Proximity Card Integer with 96 bytes */
  156. RFAL_ISODEP_FSXI_128 = 7, /*!< Frame Size for Proximity Card Integer with 128 bytes */
  157. RFAL_ISODEP_FSXI_256 = 8, /*!< Frame Size for Proximity Card Integer with 256 bytes */
  158. RFAL_ISODEP_FSXI_512 = 9, /*!< Frame Size for Proximity Card Integer with 512 bytes ISO14443-3 Amd2 2012 */
  159. RFAL_ISODEP_FSXI_1024 = 10, /*!< Frame Size for Proximity Card Integer with 1024 bytes ISO14443-3 Amd2 2012 */
  160. RFAL_ISODEP_FSXI_2048 = 11, /*!< Frame Size for Proximity Card Integer with 2048 bytes ISO14443-3 Amd2 2012 */
  161. RFAL_ISODEP_FSXI_4096 = 12 /*!< Frame Size for Proximity Card Integer with 4096 bytes ISO14443-3 Amd2 2012 */
  162. } rfalIsoDepFSxI;
  163. /*! Frame Size for Proximity Card definitions */
  164. typedef enum
  165. {
  166. RFAL_ISODEP_FSX_16 = 16, /*!< Frame Size for Proximity Card with 16 bytes */
  167. RFAL_ISODEP_FSX_24 = 24, /*!< Frame Size for Proximity Card with 24 bytes */
  168. RFAL_ISODEP_FSX_32 = 32, /*!< Frame Size for Proximity Card with 32 bytes */
  169. RFAL_ISODEP_FSX_40 = 40, /*!< Frame Size for Proximity Card with 40 bytes */
  170. RFAL_ISODEP_FSX_48 = 48, /*!< Frame Size for Proximity Card with 48 bytes */
  171. RFAL_ISODEP_FSX_64 = 64, /*!< Frame Size for Proximity Card with 64 bytes */
  172. RFAL_ISODEP_FSX_96 = 96, /*!< Frame Size for Proximity Card with 96 bytes */
  173. RFAL_ISODEP_FSX_128 = 128, /*!< Frame Size for Proximity Card with 128 bytes */
  174. RFAL_ISODEP_FSX_256 = 256, /*!< Frame Size for Proximity Card with 256 bytes */
  175. RFAL_ISODEP_FSX_512 = 512, /*!< Frame Size for Proximity Card with 512 bytes ISO14443-3 Amd2 2012 */
  176. RFAL_ISODEP_FSX_1024 = 1024, /*!< Frame Size for Proximity Card with 1024 bytes ISO14443-3 Amd2 2012 */
  177. RFAL_ISODEP_FSX_2048 = 2048, /*!< Frame Size for Proximity Card with 2048 bytes ISO14443-3 Amd2 2012 */
  178. RFAL_ISODEP_FSX_4096 = 4096, /*!< Frame Size for Proximity Card with 4096 bytes ISO14443-3 Amd2 2012 */
  179. } rfalIsoDepFSx;
  180. /*
  181. ******************************************************************************
  182. * GLOBAL MACROS
  183. ******************************************************************************
  184. */
  185. /*
  186. ******************************************************************************
  187. * GLOBAL DATA TYPES
  188. ******************************************************************************
  189. */
  190. /*! RATS format Digital 1.1 13.6.1 */
  191. typedef struct
  192. {
  193. uint8_t CMD; /*!< RATS command byte: 0xE0 */
  194. uint8_t PARAM; /*!< Param indicating FSDI and DID */
  195. } rfalIsoDepRats;
  196. /*! ATS response format Digital 1.1 13.6.2 */
  197. typedef struct
  198. {
  199. uint8_t TL; /*!< Length Byte, including TL byte itself */
  200. uint8_t T0; /*!< Format Byte T0 indicating if TA, TB, TC */
  201. uint8_t TA; /*!< Interface Byte TA(1) */
  202. uint8_t TB; /*!< Interface Byte TB(1) */
  203. uint8_t TC; /*!< Interface Byte TC(1) */
  204. uint8_t HB[RFAL_ISODEP_ATS_HB_MAX_LEN]; /*!< Historical Bytes */
  205. } rfalIsoDepAts;
  206. /*! PPS Request format (Protocol and Parameter Selection) ISO14443-4 5.3 */
  207. typedef struct
  208. {
  209. uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
  210. uint8_t PPS0; /*!< Parameter 0:[ 000b | PPS1[1n] | 0001b ] */
  211. uint8_t PPS1; /*!< Parameter 1:[ 0000b | DSI[2b] | DRI[2b] ]*/
  212. } rfalIsoDepPpsReq;
  213. /*! PPS Response format (Protocol and Parameter Selection) ISO14443-4 5.4 */
  214. typedef struct
  215. {
  216. uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
  217. } rfalIsoDepPpsRes;
  218. /*! ATTRIB Command Format Digital 1.1 15.6.1 */
  219. typedef struct
  220. {
  221. uint8_t cmd; /*!< ATTRIB_REQ command byte */
  222. uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFCID0 of the card to be selected */
  223. struct{
  224. uint8_t PARAM1; /*!< PARAM1 of ATTRIB command */
  225. uint8_t PARAM2; /*!< PARAM2 of ATTRIB command */
  226. uint8_t PARAM3; /*!< PARAM3 of ATTRIB command */
  227. uint8_t PARAM4; /*!< PARAM4 of ATTRIB command */
  228. }Param; /*!< Parameter of ATTRIB command */
  229. uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
  230. } rfalIsoDepAttribCmd;
  231. /*! ATTRIB Response Format Digital 1.1 15.6.2 */
  232. typedef struct
  233. {
  234. uint8_t mbliDid; /*!< Contains MBLI and DID */
  235. uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
  236. } rfalIsoDepAttribRes;
  237. /*! S(Parameters) Command Format ISO14443-4 (2016) Table 4 */
  238. typedef struct
  239. {
  240. uint8_t tag; /*!< S(PARAMETERS) Tag field */
  241. uint8_t length; /*!< S(PARAMETERS) Length field */
  242. uint8_t value[RFAL_ISODEP_SPARAM_VALUES_MAX_LEN]; /*!< S(PARAMETERS) Value field */
  243. } rfalIsoDepSParameter;
  244. /*! Activation info as Poller and Listener for NFC-A and NFC-B */
  245. typedef union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only of type A or B at a time. Thus no problem can occur. */
  246. /*! NFC-A information */
  247. union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
  248. struct {
  249. rfalIsoDepAts ATS; /*!< ATS response (Poller mode) */
  250. uint8_t ATSLen; /*!< ATS response length (Poller mode) */
  251. }Listener;
  252. struct {
  253. rfalIsoDepRats RATS; /*!< RATS request (Listener mode) */
  254. }Poller;
  255. }A;
  256. /*! NFC-B information */
  257. union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
  258. struct{
  259. rfalIsoDepAttribRes ATTRIB_RES; /*!< ATTRIB_RES (Poller mode) */
  260. uint8_t ATTRIB_RESLen; /*!< ATTRIB_RES length (Poller mode) */
  261. }Listener;
  262. struct{
  263. rfalIsoDepAttribCmd ATTRIB; /*!< ATTRIB request (Listener mode) */
  264. uint8_t ATTRIBLen; /*!< ATTRIB request length (Listener mode) */
  265. }Poller;
  266. }B;
  267. }rfalIsoDepActivation;
  268. /*! ISO-DEP device Info */
  269. typedef struct {
  270. uint8_t FWI; /*!< Frame Waiting Integer */
  271. uint32_t FWT; /*!< Frame Waiting Time (1/fc) */
  272. uint32_t dFWT; /*!< Delta Frame Waiting Time (1/fc) */
  273. uint32_t SFGI; /*!< Start-up Frame Guard time Integer */
  274. uint32_t SFGT; /*!< Start-up Frame Guard Time (ms) */
  275. uint8_t FSxI; /*!< Frame Size Device/Card Integer (FSDI or FSCI) */
  276. uint16_t FSx; /*!< Frame Size Device/Card (FSD or FSC) */
  277. uint32_t MBL; /*!< Maximum Buffer Length (optional for NFC-B) */
  278. rfalBitRate DSI; /*!< Bit Rate coding from Listener (PICC) to Poller (PCD) */
  279. rfalBitRate DRI; /*!< Bit Rate coding from Poller (PCD) to Listener (PICC) */
  280. uint8_t DID; /*!< Device ID */
  281. uint8_t NAD; /*!< Node ADdress */
  282. bool supDID; /*!< DID supported flag */
  283. bool supNAD; /*!< NAD supported flag */
  284. bool supAdFt; /*!< Advanced Features supported flag */
  285. } rfalIsoDepInfo;
  286. /*! ISO-DEP Device structure */
  287. typedef struct {
  288. rfalIsoDepActivation activation; /*!< Activation Info */
  289. rfalIsoDepInfo info; /*!< ISO-DEP (ISO14443-4) device Info */
  290. } rfalIsoDepDevice;
  291. /*! ATTRIB Response parameters */
  292. typedef struct
  293. {
  294. uint8_t mbli; /*!< MBLI */
  295. uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Hi Layer Information */
  296. uint8_t HLInfoLen; /*!< Hi Layer Information Length */
  297. } rfalIsoDepAttribResParam;
  298. /*! ATS Response parameter */
  299. typedef struct
  300. {
  301. uint8_t fsci; /*!< Frame Size of Proximity Card Integer */
  302. uint8_t fwi; /*!< Frame Waiting Time Integer */
  303. uint8_t sfgi; /*!< Start-Up Frame Guard Time Integer */
  304. bool didSupport; /*!< DID Supported */
  305. uint8_t ta; /*!< Max supported bitrate both direction */
  306. uint8_t *hb; /*!< Historical Bytes data */
  307. uint8_t hbLen; /*!< Historical Bytes Length */
  308. } rfalIsoDepAtsParam;
  309. /*! Structure of I-Block Buffer format from caller */
  310. typedef struct
  311. {
  312. uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
  313. uint8_t inf[RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN]; /*!< INF/Payload buffer */
  314. } rfalIsoDepBufFormat;
  315. /*! Structure of APDU Buffer format from caller */
  316. typedef struct
  317. {
  318. uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
  319. uint8_t apdu[RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN]; /*!< APDU/Payload buffer */
  320. } rfalIsoDepApduBufFormat;
  321. /*! Listen Activation Parameters Structure */
  322. typedef struct
  323. {
  324. rfalIsoDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
  325. uint16_t *rxLen; /*!< Received INF data length in Bytes */
  326. bool *isRxChaining; /*!< Received data is not complete */
  327. rfalIsoDepDevice *isoDepDev; /*!< ISO-DEP device info */
  328. } rfalIsoDepListenActvParam;
  329. /*! Structure of parameters used on ISO DEP Transceive */
  330. typedef struct
  331. {
  332. rfalIsoDepBufFormat *txBuf; /*!< Transmit Buffer struct reference */
  333. uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
  334. bool isTxChaining; /*!< Transmit data is not complete */
  335. rfalIsoDepBufFormat *rxBuf; /*!< Receive Buffer struct reference in Bytes */
  336. uint16_t *rxLen; /*!< Received INF data length in Bytes */
  337. bool *isRxChaining; /*!< Received data is not complete */
  338. uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
  339. uint32_t dFWT; /*!< Delta FWT to be used */
  340. uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
  341. uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
  342. uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
  343. } rfalIsoDepTxRxParam;
  344. /*! Structure of parameters used on ISO DEP APDU Transceive */
  345. typedef struct
  346. {
  347. rfalIsoDepApduBufFormat *txBuf; /*!< Transmit Buffer struct reference */
  348. uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
  349. rfalIsoDepApduBufFormat *rxBuf; /*!< Receive Buffer struct reference in Bytes */
  350. uint16_t *rxLen; /*!< Received INF data length in Bytes */
  351. rfalIsoDepBufFormat *tmpBuf; /*!< Temp buffer for Rx I-Blocks (internal) */
  352. uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
  353. uint32_t dFWT; /*!< Delta FWT to be used */
  354. uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
  355. uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
  356. uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
  357. } rfalIsoDepApduTxRxParam;
  358. /*
  359. ******************************************************************************
  360. * GLOBAL FUNCTION PROTOTYPES
  361. ******************************************************************************
  362. */
  363. /*!
  364. ******************************************************************************
  365. * \brief Initialize the ISO-DEP protocol
  366. *
  367. * Initialize the ISO-DEP protocol layer with default config
  368. ******************************************************************************
  369. */
  370. void rfalIsoDepInitialize( void );
  371. /*!
  372. ******************************************************************************
  373. * \brief Initialize the ISO-DEP protocol
  374. *
  375. * Initialize the ISO-DEP protocol layer with additional parameters allowing
  376. * to customise the protocol layer for specific behaviours
  377. *
  378. * \param[in] compMode : Compliance mode to be performed
  379. * \param[in] maxRetriesR : Number of retries for a R-Block
  380. * Digital 2.0 B9 - nRETRY ACK/NAK: [2,5]
  381. * \param[in] maxRetriesSnWTX : Number of retries for a S(WTX) (only in case
  382. * of NAKs) Digital 2.0 B9 - nRETRY WTX[2,5]
  383. * \param[in] maxRetriesSWTX : Number of overall S(WTX) retries.
  384. * Use RFAL_ISODEP_MAX_WTX_RETRYS_ULTD for disabling
  385. * this limit check Digital 2.0 16.2.5.2
  386. * \param[in] maxRetriesSDSL : Number of retries for a S(DESELECT)
  387. * Digital 2.0 B9 - nRETRY DESELECT: [0,5]
  388. * \param[in] maxRetriesI : Number of retries for a I-Block
  389. * Digital 2.0 16.2.5.4
  390. * \param[in] maxRetriesRATS : Number of retries for RATS
  391. * Digital 2.0 B7 - nRETRY RATS [0,1]
  392. *
  393. ******************************************************************************
  394. */
  395. void rfalIsoDepInitializeWithParams( rfalComplianceMode compMode,
  396. uint8_t maxRetriesR,
  397. uint8_t maxRetriesSnWTX,
  398. uint8_t maxRetriesSWTX,
  399. uint8_t maxRetriesSDSL,
  400. uint8_t maxRetriesI,
  401. uint8_t maxRetriesRATS );
  402. /*!
  403. *****************************************************************************
  404. * \brief FSxI to FSx
  405. *
  406. * Convert Frame Size for proximity coupling Device Integer (FSxI) to
  407. * Frame Size for proximity coupling Device (FSx)
  408. *
  409. * FSD - maximum frame size for NFC Forum Device in Poll Mode
  410. * FSC - maximum frame size for NFC Forum Device in Listen Mode
  411. *
  412. * FSxI = FSDI or FSCI
  413. * FSx = FSD or FSC
  414. *
  415. * The FSD/FSC value includes the header and CRC
  416. *
  417. * \param[in] FSxI : Frame Size for proximity coupling Device Integer
  418. *
  419. * \return fsx : Frame Size for proximity coupling Device (FSD or FSC)
  420. *
  421. *****************************************************************************
  422. */
  423. uint16_t rfalIsoDepFSxI2FSx( uint8_t FSxI );
  424. /*!
  425. *****************************************************************************
  426. * \brief FWI to FWT
  427. *
  428. * Convert Frame Waiting time Integer (FWI) to Frame Waiting Time (FWT) in
  429. * 1/fc units
  430. *
  431. * \param[in] fwi : Frame Waiting time Integer
  432. *
  433. * \return fwt : Frame Waiting Time in 1/fc units
  434. *
  435. *****************************************************************************
  436. */
  437. uint32_t rfalIsoDepFWI2FWT( uint8_t fwi );
  438. /*!
  439. *****************************************************************************
  440. * \brief Check if the buffer data contains a valid RATS command
  441. *
  442. * Check if it is a well formed RATS command with 2 bytes
  443. * This function does not check the validity of FSDI and DID
  444. *
  445. * \param[in] buf : reference to buffer containing the data to be checked
  446. * \param[in] bufLen : length of data in the buffer in bytes
  447. *
  448. * \return true if the data indicates a RATS command; false otherwise
  449. *****************************************************************************
  450. */
  451. bool rfalIsoDepIsRats( const uint8_t *buf, uint8_t bufLen );
  452. /*!
  453. *****************************************************************************
  454. * \brief Check if the buffer data contains a valid ATTRIB command
  455. *
  456. * Check if it is a well formed ATTRIB command, but does not check the
  457. * validity of the information inside
  458. *
  459. * \param[in] buf : reference to buffer containing the data to be checked
  460. * \param[in] bufLen : length of data in the buffer in bytes
  461. *
  462. * \return true if the data indicates a ATTRIB command; false otherwise
  463. *****************************************************************************
  464. */
  465. bool rfalIsoDepIsAttrib( const uint8_t *buf, uint8_t bufLen );
  466. /*!
  467. *****************************************************************************
  468. * \brief Start Listen Activation Handling
  469. *
  470. * Start Listen Activation Handling and setup to receive first I-block which may
  471. * contain complete or partial APDU after activation is completed
  472. *
  473. * Pass in RATS for T4AT, or ATTRIB for T4BT, to handle ATS or ATTRIB Response respectively
  474. * The Activation Handling handles ATS and ATTRIB Response; and additionally PPS Response
  475. * if a PPS is received for T4AT.
  476. * The method uses the current RFAL state machine to determine if it is expecting RATS or ATTRIB
  477. *
  478. * Activation is completed if PPS Response is sent or if first PDU is received in T4T-A
  479. * Activation is completed if ATTRIB Response is sent in T4T-B
  480. *
  481. * \ref rfalIsoDepListenGetActivationStatus provide status if activation is completed.
  482. * \ref rfalIsoDepStartTransceive shall be called right after activation is completed
  483. *
  484. * \param[in] atsParam : reference to ATS parameters
  485. * \param[in] attribResParam : reference to ATTRIB_RES parameters
  486. * \param[in] buf : reference to buffer containing RATS or ATTRIB
  487. * \param[in] bufLen : length in bytes of the given bufffer
  488. * \param[in] actParam : reference to incoming reception information will be placed
  489. *
  490. *
  491. * \warning Once the Activation has been completed the method
  492. * rfalIsoDepGetTransceiveStatus() must be called.
  493. * If activation has completed due to reception of a data block (not PPS) the
  494. * buffer owned by the caller and passed on actParam must still contain this data.
  495. * The first data will be processed (I-Block or S-DSL) by rfalIsoDepGetTransceiveStatus()
  496. * inform the caller and then for the next transaction use rfalIsoDepStartTransceive()
  497. *
  498. * \return ERR_NONE : RATS/ATTRIB is valid and activation has started
  499. * \return ERR_PARAM : Invalid parameters
  500. * \return ERR_PROTO : Invalid request
  501. * \return ERR_NOTSUPP : Feature not supported
  502. *****************************************************************************
  503. */
  504. ReturnCode rfalIsoDepListenStartActivation( rfalIsoDepAtsParam *atsParam, const rfalIsoDepAttribResParam *attribResParam, const uint8_t *buf, uint16_t bufLen, rfalIsoDepListenActvParam actParam );
  505. /*!
  506. *****************************************************************************
  507. * \brief Get the current Activation Status
  508. *
  509. * \return ERR_NONE if Activation is already completed
  510. * \return ERR_BUSY if Activation is ongoing
  511. * \return ERR_LINK_LOSS if Remote Field is turned off
  512. *****************************************************************************
  513. */
  514. ReturnCode rfalIsoDepListenGetActivationStatus( void );
  515. /*!
  516. *****************************************************************************
  517. * \brief Get the ISO-DEP Communication Information
  518. *
  519. * Gets the maximum INF length in bytes based on current Frame Size
  520. * for proximity coupling Device (FSD or FSC) excluding the header and CRC
  521. *
  522. * \return maximum INF length in bytes
  523. *****************************************************************************
  524. */
  525. uint16_t rfalIsoDepGetMaxInfLen( void );
  526. /*!
  527. *****************************************************************************
  528. * \brief ISO-DEP Start Transceive
  529. *
  530. * This method triggers a ISO-DEP Transceive containing a complete or
  531. * partial APDU
  532. * It transmits the given message and handles all protocol retransmitions,
  533. * error handling and control messages
  534. *
  535. * The txBuf contains a complete or partial APDU (INF) to be transmitted
  536. * The Prologue field will be manipulated by the Transceive
  537. *
  538. * If the buffer contains a partial APDU and is not the last block,
  539. * then isTxChaining must be set to true
  540. *
  541. * \param[in] param: reference parameters to be used for the Transceive
  542. *
  543. * \return ERR_PARAM : Bad request
  544. * \return ERR_WRONG_STATE : The module is not in a proper state
  545. * \return ERR_NONE : The Transceive request has been started
  546. *****************************************************************************
  547. */
  548. ReturnCode rfalIsoDepStartTransceive( rfalIsoDepTxRxParam param );
  549. /*!
  550. *****************************************************************************
  551. * \brief Get the Transceive status
  552. *
  553. * Returns the status of the ISO-DEP Transceive
  554. *
  555. * \warning When the other device is performing chaining once a chained
  556. * block is received the error ERR_AGAIN is sent. At this point
  557. * caller must handle the received data immediately.
  558. * When ERR_AGAIN is returned an ACK has already been sent to
  559. * the other device and the next block might be incoming.
  560. * If rfalWorker() is called frequently it will place the next
  561. * block on the given buffer
  562. *
  563. *
  564. * \return ERR_NONE : Transceive has been completed successfully
  565. * \return ERR_BUSY : Transceive is ongoing
  566. * \return ERR_PROTO : Protocol error occurred
  567. * \return ERR_TIMEOUT : Timeout error occurred
  568. * \return ERR_SLEEP_REQ : Deselect has been received and responded
  569. * \return ERR_NOMEM : The received INF does not fit into the
  570. * receive buffer
  571. * \return ERR_LINK_LOSS : Communication is lost because Reader/Writer
  572. * has turned off its field
  573. * \return ERR_AGAIN : received one chaining block, continue to call
  574. * this method to retrieve the remaining blocks
  575. *****************************************************************************
  576. */
  577. ReturnCode rfalIsoDepGetTransceiveStatus( void );
  578. /*!
  579. *****************************************************************************
  580. * \brief ISO-DEP Start APDU Transceive
  581. *
  582. * This method triggers a ISO-DEP Transceive containing a complete APDU
  583. * It transmits the given message and handles all protocol retransmitions,
  584. * error handling and control messages
  585. *
  586. * The txBuf contains a complete APDU to be transmitted
  587. * The Prologue field will be manipulated by the Transceive
  588. *
  589. * \warning the txBuf will be modified during the transmission
  590. * \warning the maximum RF frame which can be received is limited by param.tmpBuf
  591. *
  592. * \param[in] param: reference parameters to be used for the Transceive
  593. *
  594. * \return ERR_PARAM : Bad request
  595. * \return ERR_WRONG_STATE : The module is not in a proper state
  596. * \return ERR_NONE : The Transceive request has been started
  597. *****************************************************************************
  598. */
  599. ReturnCode rfalIsoDepStartApduTransceive( rfalIsoDepApduTxRxParam param );
  600. /*!
  601. *****************************************************************************
  602. * \brief Get the APDU Transceive status
  603. *
  604. * \return ERR_NONE : if Transceive has been completed successfully
  605. * \return ERR_BUSY : if Transceive is ongoing
  606. * \return ERR_PROTO : if a protocol error occurred
  607. * \return ERR_TIMEOUT : if a timeout error occurred
  608. * \return ERR_SLEEP_REQ : if Deselect is received and responded
  609. * \return ERR_NOMEM : if the received INF does not fit into the
  610. * receive buffer
  611. * \return ERR_LINK_LOSS : if communication is lost because Reader/Writer
  612. * has turned off its field
  613. *****************************************************************************
  614. */
  615. ReturnCode rfalIsoDepGetApduTransceiveStatus( void );
  616. /*!
  617. *****************************************************************************
  618. * \brief ISO-DEP Send RATS
  619. *
  620. * This sends a RATS to make a NFC-A Listen Device to enter
  621. * ISO-DEP layer (ISO14443-4) and checks if the received ATS is valid
  622. *
  623. * \param[in] FSDI : Frame Size Device Integer to be used
  624. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  625. * \param[out] ats : pointer to place the ATS Response
  626. * \param[out] atsLen : pointer to place the ATS length
  627. *
  628. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  629. * \return ERR_PARAM : Invalid parameters
  630. * \return ERR_IO : Generic internal error
  631. * \return ERR_TIMEOUT : Timeout error
  632. * \return ERR_PAR : Parity error detected
  633. * \return ERR_CRC : CRC error detected
  634. * \return ERR_FRAMING : Framing error detected
  635. * \return ERR_PROTO : Protocol error detected
  636. * \return ERR_NONE : No error, ATS received
  637. *****************************************************************************
  638. */
  639. ReturnCode rfalIsoDepRATS( rfalIsoDepFSxI FSDI, uint8_t DID, rfalIsoDepAts *ats , uint8_t *atsLen );
  640. /*!
  641. *****************************************************************************
  642. * \brief ISO-DEP Send PPS
  643. *
  644. * This sends a PPS to make a NFC-A Listen Device change the communications
  645. * bit rate from 106kbps to one of the supported bit rates
  646. * Additionally checks if the received PPS response is valid
  647. *
  648. * \param[in] DID : Device ID
  649. * \param[in] DSI : DSI code the divisor from Listener (PICC) to Poller (PCD)
  650. * \param[in] DRI : DRI code the divisor from Poller (PCD) to Listener (PICC)
  651. * \param[out] ppsRes : pointer to place the PPS Response
  652. *
  653. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  654. * \return ERR_PARAM : Invalid parameters
  655. * \return ERR_IO : Generic internal error
  656. * \return ERR_TIMEOUT : Timeout error
  657. * \return ERR_PAR : Parity error detected
  658. * \return ERR_CRC : CRC error detected
  659. * \return ERR_FRAMING : Framing error detected
  660. * \return ERR_PROTO : Protocol error detected
  661. * \return ERR_NONE : No error, PPS Response received
  662. *****************************************************************************
  663. */
  664. ReturnCode rfalIsoDepPPS( uint8_t DID, rfalBitRate DSI, rfalBitRate DRI, rfalIsoDepPpsRes *ppsRes );
  665. /*!
  666. *****************************************************************************
  667. * \brief ISO-DEP Send ATTRIB
  668. *
  669. * This sends a ATTRIB to make a NFC-B Listen Device to enter
  670. * ISO-DEP layer (ISO14443-4) and checks if the received ATTRIB Response is valid
  671. *
  672. * \param[in] nfcid0 : NFCID0 to be used for the ATTRIB
  673. * \param[in] PARAM1 : ATTRIB PARAM1 byte (communication parameters)
  674. * \param[in] DSI : DSI code the divisor from Listener (PICC) to Poller (PCD)
  675. * \param[in] DRI : DRI code the divisor from Poller (PCD) to Listener (PICC)
  676. * \param[in] FSDI : PCD's Frame Size to be announced on the ATTRIB
  677. * \param[in] PARAM3 : ATTRIB PARAM1 byte (protocol type)
  678. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  679. * \param[in] HLInfo : pointer to Higher layer INF (NULL if none)
  680. * \param[in] HLInfoLen : Length HLInfo
  681. * \param[in] fwt : Frame Waiting Time to be used (from SENSB_RES)
  682. * \param[out] attribRes : pointer to place the ATTRIB Response
  683. * \param[out] attribResLen : pointer to place the ATTRIB Response length
  684. *
  685. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  686. * \return ERR_PARAM : Invalid parameters
  687. * \return ERR_IO : Generic internal error
  688. * \return ERR_TIMEOUT : Timeout error
  689. * \return ERR_CRC : CRC error detected
  690. * \return ERR_FRAMING : Framing error detected
  691. * \return ERR_PROTO : Protocol error detected
  692. * \return ERR_NONE : No error, ATTRIB Response received
  693. *****************************************************************************
  694. */
  695. ReturnCode rfalIsoDepATTRIB( const uint8_t* nfcid0, uint8_t PARAM1, rfalBitRate DSI, rfalBitRate DRI, rfalIsoDepFSxI FSDI, uint8_t PARAM3, uint8_t DID, const uint8_t* HLInfo, uint8_t HLInfoLen, uint32_t fwt, rfalIsoDepAttribRes *attribRes, uint8_t *attribResLen );
  696. /*!
  697. *****************************************************************************
  698. * \brief Deselects PICC
  699. *
  700. * This function sends a deselect command to PICC and waits for it`s
  701. * responce in a blocking way
  702. *
  703. * \return ERR_NONE : Deselect successfully sent and acknowledged by PICC
  704. * \return ERR_TIMEOUT: No response rcvd from PICC
  705. *
  706. *****************************************************************************
  707. */
  708. ReturnCode rfalIsoDepDeselect( void );
  709. /*!
  710. *****************************************************************************
  711. * \brief ISO-DEP Poller Handle NFC-A Activation
  712. *
  713. * This performs a NFC-A Activation into ISO-DEP layer (ISO14443-4) with the given
  714. * parameters. It sends RATS and if the higher bit rates are supported by
  715. * both devices it additionally sends PPS
  716. * Once Activated all details of the device are provided on isoDepDev
  717. *
  718. * \param[in] FSDI : Frame Size Device Integer to be used
  719. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  720. * \param[in] maxBR : Max bit rate supported by the Poller
  721. * \param[out] isoDepDev : ISO-DEP information of the activated Listen device
  722. *
  723. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  724. * \return ERR_PARAM : Invalid parameters
  725. * \return ERR_IO : Generic internal error
  726. * \return ERR_TIMEOUT : Timeout error
  727. * \return ERR_PAR : Parity error detected
  728. * \return ERR_CRC : CRC error detected
  729. * \return ERR_FRAMING : Framing error detected
  730. * \return ERR_PROTO : Protocol error detected
  731. * \return ERR_NONE : No error, activation successful
  732. *****************************************************************************
  733. */
  734. ReturnCode rfalIsoDepPollAHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, rfalIsoDepDevice *isoDepDev );
  735. /*!
  736. *****************************************************************************
  737. * \brief ISO-DEP Poller Handle NFC-B Activation
  738. *
  739. * This performs a NFC-B Activation into ISO-DEP layer (ISO14443-4) with the given
  740. * parameters. It sends ATTRIB and calculates supported higher bit rates of both
  741. * devices and performs activation.
  742. * Once Activated all details of the device are provided on isoDepDev
  743. *
  744. * \param[in] FSDI : Frame Size Device Integer to be used
  745. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  746. * \param[in] maxBR : Max bit rate supported by the Poller
  747. * \param[in] PARAM1 : ATTRIB PARAM1 byte (communication parameters)
  748. * \param[in] nfcbDev : pointer to the NFC-B Device containing the SENSB_RES
  749. * \param[in] HLInfo : pointer to Higher layer INF (NULL if none)
  750. * \param[in] HLInfoLen : Length HLInfo
  751. * \param[out] isoDepDev : ISO-DEP information of the activated Listen device
  752. *
  753. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  754. * \return ERR_PARAM : Invalid parameters
  755. * \return ERR_IO : Generic internal error
  756. * \return ERR_TIMEOUT : Timeout error
  757. * \return ERR_PAR : Parity error detected
  758. * \return ERR_CRC : CRC error detected
  759. * \return ERR_FRAMING : Framing error detected
  760. * \return ERR_PROTO : Protocol error detected
  761. * \return ERR_NONE : No error, activation successful
  762. *****************************************************************************
  763. */
  764. ReturnCode rfalIsoDepPollBHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, uint8_t PARAM1, const rfalNfcbListenDevice *nfcbDev, const uint8_t* HLInfo, uint8_t HLInfoLen, rfalIsoDepDevice *isoDepDev );
  765. /*!
  766. *****************************************************************************
  767. * \brief ISO-DEP Poller Handle S(Parameters)
  768. *
  769. * This checks if PICC supports S(PARAMETERS), retieves PICC's
  770. * capabilities and sets the Bit Rate at the highest supported by both
  771. * devices
  772. *
  773. * \param[out] isoDepDev : ISO-DEP information of the activated Listen device
  774. * \param[in] maxTxBR : Maximum Tx bit rate supported by PCD
  775. * \param[in] maxRxBR : Maximum Rx bit rate supported by PCD
  776. *
  777. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  778. * \return ERR_PARAM : Invalid parameters
  779. * \return ERR_IO : Generic internal error
  780. * \return ERR_TIMEOUT : Timeout error
  781. * \return ERR_FRAMING : Framing error detected
  782. * \return ERR_PROTO : Protocol error detected
  783. * \return ERR_NONE : No error, S(PARAMETERS) selection successful
  784. *****************************************************************************
  785. */
  786. ReturnCode rfalIsoDepPollHandleSParameters( rfalIsoDepDevice *isoDepDev, rfalBitRate maxTxBR, rfalBitRate maxRxBR );
  787. /*!
  788. *****************************************************************************
  789. * \brief ISO-DEP Poller Start NFC-A Activation
  790. *
  791. * This starts a NFC-A Activation into ISO-DEP layer (ISO14443-4) with the given
  792. * parameters. It sends RATS and if the higher bit rates are supported by
  793. * both devices it additionally sends PPS
  794. * Once Activated all details of the device are provided on isoDepDev
  795. *
  796. *
  797. * \see rfalIsoDepPollAGetActivationStatus
  798. *
  799. * \param[in] FSDI : Frame Size Device Integer to be used
  800. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  801. * \param[in] maxBR : Max bit rate supported by the Poller
  802. * \param[out] isoDepDev : ISO-DEP information of the activated Listen device
  803. *
  804. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  805. * \return ERR_PARAM : Invalid parameters
  806. * \return ERR_IO : Generic internal error
  807. * \return ERR_TIMEOUT : Timeout error
  808. * \return ERR_PAR : Parity error detected
  809. * \return ERR_CRC : CRC error detected
  810. * \return ERR_FRAMING : Framing error detected
  811. * \return ERR_PROTO : Protocol error detected
  812. * \return ERR_NONE : No error, start of asynchronous operation successful
  813. *****************************************************************************
  814. */
  815. ReturnCode rfalIsoDepPollAStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, rfalIsoDepDevice *isoDepDev );
  816. /*!
  817. *****************************************************************************
  818. * \brief ISO-DEP Poller Get NFC-A Activation Status
  819. *
  820. * Returns the activation status started by rfalIsoDepPollAStartActivation
  821. *
  822. * \see rfalIsoDepPollAStartActivation
  823. *
  824. * \return ERR_BUSY : Operation is ongoing
  825. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  826. * \return ERR_PARAM : Invalid parameters
  827. * \return ERR_IO : Generic internal error
  828. * \return ERR_TIMEOUT : Timeout error
  829. * \return ERR_PAR : Parity error detected
  830. * \return ERR_CRC : CRC error detected
  831. * \return ERR_FRAMING : Framing error detected
  832. * \return ERR_PROTO : Protocol error detected
  833. * \return ERR_NONE : No error, activation successful
  834. *****************************************************************************
  835. */
  836. ReturnCode rfalIsoDepPollAGetActivationStatus( void );
  837. /*!
  838. *****************************************************************************
  839. * \brief ISO-DEP Poller Start NFC-B Activation
  840. *
  841. * This starts a NFC-B Activation into ISO-DEP layer (ISO14443-4) with the given
  842. * parameters. It will send ATTRIB and calculate supported higher bit rates of both
  843. * devices and perform activation.
  844. * Once Activated all details of the device are provided on isoDepDev
  845. *
  846. * \see rfalIsoDepPollBGetActivationStatus
  847. *
  848. * \param[in] FSDI : Frame Size Device Integer to be used
  849. * \param[in] DID : Device ID to be used or RFAL_ISODEP_NO_DID for not use DID
  850. * \param[in] maxBR : Max bit rate supported by the Poller
  851. * \param[in] PARAM1 : ATTRIB PARAM1 byte (communication parameters)
  852. * \param[in] nfcbDev : pointer to the NFC-B Device containing the SENSB_RES
  853. * \param[in] HLInfo : pointer to Higher layer INF (NULL if none)
  854. * \param[in] HLInfoLen : Length HLInfo
  855. * \param[out] isoDepDev : ISO-DEP information of the activated Listen device
  856. *
  857. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  858. * \return ERR_PARAM : Invalid parameters
  859. * \return ERR_IO : Generic internal error
  860. * \return ERR_TIMEOUT : Timeout error
  861. * \return ERR_PAR : Parity error detected
  862. * \return ERR_CRC : CRC error detected
  863. * \return ERR_FRAMING : Framing error detected
  864. * \return ERR_PROTO : Protocol error detected
  865. * \return ERR_NONE : No error, start of asynchronous operation successful
  866. *****************************************************************************
  867. */
  868. ReturnCode rfalIsoDepPollBStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, uint8_t PARAM1, const rfalNfcbListenDevice *nfcbDev, const uint8_t* HLInfo, uint8_t HLInfoLen, rfalIsoDepDevice *isoDepDev );
  869. /*!
  870. *****************************************************************************
  871. * \brief ISO-DEP Poller Get NFC-B Activation Status
  872. *
  873. * Returns the activation status started by rfalIsoDepPollBStartActivation
  874. *
  875. * \see rfalIsoDepPollBStartActivation
  876. *
  877. * \return ERR_BUSY : Operation is ongoing
  878. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  879. * \return ERR_PARAM : Invalid parameters
  880. * \return ERR_IO : Generic internal error
  881. * \return ERR_TIMEOUT : Timeout error
  882. * \return ERR_PAR : Parity error detected
  883. * \return ERR_CRC : CRC error detected
  884. * \return ERR_FRAMING : Framing error detected
  885. * \return ERR_PROTO : Protocol error detected
  886. * \return ERR_NONE : No error, activation successful
  887. *****************************************************************************
  888. */
  889. ReturnCode rfalIsoDepPollBGetActivationStatus( void );
  890. #endif /* RFAL_ISODEP_H_ */
  891. /**
  892. * @}
  893. *
  894. * @}
  895. *
  896. * @}
  897. */