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 * PROJECT: ST25R391x firmware
DiegoOstuni 0:75fc82583a41 25 * $Revision: $
DiegoOstuni 0:75fc82583a41 26 * LANGUAGE: ISO C99
DiegoOstuni 0:75fc82583a41 27 */
DiegoOstuni 0:75fc82583a41 28
DiegoOstuni 0:75fc82583a41 29 /*! \file rfal_nfca.h
DiegoOstuni 0:75fc82583a41 30 *
DiegoOstuni 0:75fc82583a41 31 * \author Gustavo Patricio
DiegoOstuni 0:75fc82583a41 32 *
DiegoOstuni 0:75fc82583a41 33 * \brief Provides several NFC-A convenience methods and definitions
DiegoOstuni 0:75fc82583a41 34 *
DiegoOstuni 0:75fc82583a41 35 * It provides a Poller (ISO14443A PCD) interface and as well as
DiegoOstuni 0:75fc82583a41 36 * some NFC-A Listener (ISO14443A PICC) helpers.
DiegoOstuni 0:75fc82583a41 37 *
DiegoOstuni 0:75fc82583a41 38 * The definitions and helpers methods provided by this module are only
DiegoOstuni 0:75fc82583a41 39 * up to ISO14443-3 layer
DiegoOstuni 0:75fc82583a41 40 *
DiegoOstuni 0:75fc82583a41 41 * @addtogroup RFAL
DiegoOstuni 0:75fc82583a41 42 * @{
DiegoOstuni 0:75fc82583a41 43 *
DiegoOstuni 0:75fc82583a41 44 * @addtogroup RFAL-AL
DiegoOstuni 0:75fc82583a41 45 * @brief RFAL Abstraction Layer
DiegoOstuni 0:75fc82583a41 46 * @{
DiegoOstuni 0:75fc82583a41 47 *
DiegoOstuni 0:75fc82583a41 48 * @addtogroup NFC-A
DiegoOstuni 0:75fc82583a41 49 * @brief RFAL NFC-A Module
DiegoOstuni 0:75fc82583a41 50 * @{
DiegoOstuni 0:75fc82583a41 51 *
DiegoOstuni 0:75fc82583a41 52 */
DiegoOstuni 0:75fc82583a41 53
DiegoOstuni 0:75fc82583a41 54
DiegoOstuni 0:75fc82583a41 55 #ifndef RFAL_NFCA_H
DiegoOstuni 0:75fc82583a41 56 #define RFAL_NFCA_H
DiegoOstuni 0:75fc82583a41 57
DiegoOstuni 0:75fc82583a41 58 /*
DiegoOstuni 0:75fc82583a41 59 ******************************************************************************
DiegoOstuni 0:75fc82583a41 60 * INCLUDES
DiegoOstuni 0:75fc82583a41 61 ******************************************************************************
DiegoOstuni 0:75fc82583a41 62 */
DiegoOstuni 0:75fc82583a41 63 #include "platform1.h"
DiegoOstuni 0:75fc82583a41 64 #include "st_errno.h"
DiegoOstuni 0:75fc82583a41 65 #include "rfal_rf.h"
DiegoOstuni 0:75fc82583a41 66 #include "rfal_t1t.h"
DiegoOstuni 0:75fc82583a41 67
DiegoOstuni 0:75fc82583a41 68 /*
DiegoOstuni 0:75fc82583a41 69 ******************************************************************************
DiegoOstuni 0:75fc82583a41 70 * GLOBAL DEFINES
DiegoOstuni 0:75fc82583a41 71 ******************************************************************************
DiegoOstuni 0:75fc82583a41 72 */
DiegoOstuni 0:75fc82583a41 73
DiegoOstuni 0:75fc82583a41 74 #define RFAL_NFCA_CASCADE_1_UID_LEN 4 /*!< UID length of cascade level 1 only tag */
DiegoOstuni 0:75fc82583a41 75 #define RFAL_NFCA_CASCADE_2_UID_LEN 7 /*!< UID length of cascade level 2 only tag */
DiegoOstuni 0:75fc82583a41 76 #define RFAL_NFCA_CASCADE_3_UID_LEN 10 /*!< UID length of cascade level 3 only tag */
DiegoOstuni 0:75fc82583a41 77
DiegoOstuni 0:75fc82583a41 78 #define RFAL_NFCA_SENS_RES_PLATFORM_MASK 0x0F /*!< SENS_RES (ATQA) platform configuration mask Digital 1.1 Table 10 */
DiegoOstuni 0:75fc82583a41 79 #define RFAL_NFCA_SENS_RES_PLATFORM_T1T 0x0C /*!< SENS_RES (ATQA) T1T platform configuration Digital 1.1 Table 10 */
DiegoOstuni 0:75fc82583a41 80
DiegoOstuni 0:75fc82583a41 81 #define RFAL_NFCA_SEL_RES_CONF_MASK 0x60 /*!< SEL_RES (SAK) platform configuration mask Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 82 #define RFAL_NFCA_SEL_RES_CONF_T2T 0x00 /*!< SEL_RES (SAK) T2T configuration Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 83 #define RFAL_NFCA_SEL_RES_CONF_T4T 0x20 /*!< SEL_RES (SAK) T4T configuration Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 84 #define RFAL_NFCA_SEL_RES_CONF_NFCDEP 0x40 /*!< SEL_RES (SAK) NFC-DEP configuration Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 85 #define RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP 0x60 /*!< SEL_RES (SAK) T4T and NFC-DEP configuration Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 86
DiegoOstuni 0:75fc82583a41 87
DiegoOstuni 0:75fc82583a41 88 /*! NFC-A minimum FDT(listen) = ((n * 128 + (84)) / fc) with n_min = 9 Digital 1.1 6.10.1
DiegoOstuni 0:75fc82583a41 89 * = (1236)/fc
DiegoOstuni 0:75fc82583a41 90 * Relax with 3etu: (3*128)/fc as with multiple NFC-A cards, response may take longer (JCOP cards)
DiegoOstuni 0:75fc82583a41 91 * = (1236 + 384)/fc = 1620 / fc */
DiegoOstuni 0:75fc82583a41 92 #define RFAL_NFCA_FDTMIN 1620
DiegoOstuni 0:75fc82583a41 93 /*
DiegoOstuni 0:75fc82583a41 94 ******************************************************************************
DiegoOstuni 0:75fc82583a41 95 * GLOBAL MACROS
DiegoOstuni 0:75fc82583a41 96 ******************************************************************************
DiegoOstuni 0:75fc82583a41 97 */
DiegoOstuni 0:75fc82583a41 98
DiegoOstuni 0:75fc82583a41 99 /*! Checks if device is a T1T given its SENS_RES */
DiegoOstuni 0:75fc82583a41 100 #define rfalNfcaIsSensResT1T( sensRes ) ((((rfalNfcaSensRes*)sensRes)->platformInfo & RFAL_NFCA_SENS_RES_PLATFORM_MASK) == RFAL_NFCA_SENS_RES_PLATFORM_T1T )
DiegoOstuni 0:75fc82583a41 101
DiegoOstuni 0:75fc82583a41 102 /*! Checks if device is a T2T given its SENS_RES */
DiegoOstuni 0:75fc82583a41 103 #define rfalNfcaIsSelResT2T( selRes ) ((((rfalNfcaSelRes*)selRes)->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T2T )
DiegoOstuni 0:75fc82583a41 104
DiegoOstuni 0:75fc82583a41 105 /*! Checks if device is a T4T given its SENS_RES */
DiegoOstuni 0:75fc82583a41 106 #define rfalNfcaIsSelResT4T( selRes ) ((((rfalNfcaSelRes*)selRes)->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T4T )
DiegoOstuni 0:75fc82583a41 107
DiegoOstuni 0:75fc82583a41 108 /*! Checks if device supports NFC-DEP protocol given its SENS_RES */
DiegoOstuni 0:75fc82583a41 109 #define rfalNfcaIsSelResNFCDEP( selRes ) ((((rfalNfcaSelRes*)selRes)->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_NFCDEP )
DiegoOstuni 0:75fc82583a41 110
DiegoOstuni 0:75fc82583a41 111 /*! Checks if device supports ISO-DEP and NFC-DEP protocol given its SENS_RES */
DiegoOstuni 0:75fc82583a41 112 #define rfalNfcaIsSelResT4TNFCDEP( selRes ) ((((rfalNfcaSelRes*)selRes)->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP )
DiegoOstuni 0:75fc82583a41 113
DiegoOstuni 0:75fc82583a41 114 /*! Checks if a NFC-A listener device supports multiple protocols (ISO-DEP and NFC-DEP) */
DiegoOstuni 0:75fc82583a41 115 #define rfalNfcaLisDevIsMultiProto( lisDev ) (((rfalNfcaListenDevice*)lisDev)->type == RFAL_NFCA_T4T_NFCDEP )
DiegoOstuni 0:75fc82583a41 116
DiegoOstuni 0:75fc82583a41 117 /*
DiegoOstuni 0:75fc82583a41 118 ******************************************************************************
DiegoOstuni 0:75fc82583a41 119 * GLOBAL TYPES
DiegoOstuni 0:75fc82583a41 120 ******************************************************************************
DiegoOstuni 0:75fc82583a41 121 */
DiegoOstuni 0:75fc82583a41 122
DiegoOstuni 0:75fc82583a41 123 /*! NFC-A Listen device types */
DiegoOstuni 0:75fc82583a41 124 typedef enum {
DiegoOstuni 0:75fc82583a41 125 RFAL_NFCA_T1T = 0x01, /* Device configured for T1T Digital 1.1 Table 9 */
DiegoOstuni 0:75fc82583a41 126 RFAL_NFCA_T2T = 0x00, /* Device configured for T2T Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 127 RFAL_NFCA_T4T = 0x20, /* Device configured for T4T Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 128 RFAL_NFCA_NFCDEP = 0x40, /* Device configured for NFC-DEP Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 129 RFAL_NFCA_T4T_NFCDEP = 0x60 /* Device configured for NFC-DEP and T4T Digital 1.1 Table 19 */
DiegoOstuni 0:75fc82583a41 130 } rfalNfcaListenDeviceType;
DiegoOstuni 0:75fc82583a41 131
DiegoOstuni 0:75fc82583a41 132
DiegoOstuni 0:75fc82583a41 133 /*! SENS_RES (ATQA) format Digital 1.1 6.6.3 & Table 7 */
DiegoOstuni 0:75fc82583a41 134 typedef struct
DiegoOstuni 0:75fc82583a41 135 {
DiegoOstuni 0:75fc82583a41 136 uint8_t anticollisionInfo; /*!< SENS_RES Anticollision Information */
DiegoOstuni 0:75fc82583a41 137 uint8_t platformInfo; /*!< SENS_RES Platform Information */
DiegoOstuni 0:75fc82583a41 138 } rfalNfcaSensRes;
DiegoOstuni 0:75fc82583a41 139
DiegoOstuni 0:75fc82583a41 140
DiegoOstuni 0:75fc82583a41 141 /*! SDD_REQ (Anticollision) format Digital 1.1 6.7.1 & Table 11 */
DiegoOstuni 0:75fc82583a41 142 typedef struct
DiegoOstuni 0:75fc82583a41 143 {
DiegoOstuni 0:75fc82583a41 144 uint8_t selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
DiegoOstuni 0:75fc82583a41 145 uint8_t selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
DiegoOstuni 0:75fc82583a41 146 } rfalNfcaSddReq;
DiegoOstuni 0:75fc82583a41 147
DiegoOstuni 0:75fc82583a41 148
DiegoOstuni 0:75fc82583a41 149 /*! SDD_RES (UID CLn) format Digital 1.1 6.7.2 & Table 15 */
DiegoOstuni 0:75fc82583a41 150 typedef struct
DiegoOstuni 0:75fc82583a41 151 {
DiegoOstuni 0:75fc82583a41 152 uint8_t nfcid1[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 cascade level NFCID */
DiegoOstuni 0:75fc82583a41 153 uint8_t bcc; /*!< BCC Exclusive-OR over first 4 bytes of SDD_RES */
DiegoOstuni 0:75fc82583a41 154 } rfalNfcaSddRes;
DiegoOstuni 0:75fc82583a41 155
DiegoOstuni 0:75fc82583a41 156
DiegoOstuni 0:75fc82583a41 157 /*! SEL_REQ (Select) format Digital 1.1 6.8.1 & Table 17 */
DiegoOstuni 0:75fc82583a41 158 typedef struct
DiegoOstuni 0:75fc82583a41 159 {
DiegoOstuni 0:75fc82583a41 160 uint8_t selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
DiegoOstuni 0:75fc82583a41 161 uint8_t selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
DiegoOstuni 0:75fc82583a41 162 uint8_t nfcid1[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 data */
DiegoOstuni 0:75fc82583a41 163 uint8_t bcc; /*!< Checksum calculated as exclusive-OR over the 4 bytes of NFCID1 CLn */
DiegoOstuni 0:75fc82583a41 164 } rfalNfcaSelReq;
DiegoOstuni 0:75fc82583a41 165
DiegoOstuni 0:75fc82583a41 166
DiegoOstuni 0:75fc82583a41 167 /*! SEL_RES (SAK) format Digital 1.1 6.8.2 & Table 19 */
DiegoOstuni 0:75fc82583a41 168 typedef struct
DiegoOstuni 0:75fc82583a41 169 {
DiegoOstuni 0:75fc82583a41 170 uint8_t sak; /*!< Select Acknowledge */
DiegoOstuni 0:75fc82583a41 171 } rfalNfcaSelRes;
DiegoOstuni 0:75fc82583a41 172
DiegoOstuni 0:75fc82583a41 173
DiegoOstuni 0:75fc82583a41 174 /*! NFC-A listener device (PICC) struct */
DiegoOstuni 0:75fc82583a41 175 typedef struct
DiegoOstuni 0:75fc82583a41 176 {
DiegoOstuni 0:75fc82583a41 177 rfalNfcaListenDeviceType type; /*!< NFC-A Listen device type */
DiegoOstuni 0:75fc82583a41 178 rfalNfcaSensRes sensRes; /*!< SENS_RES (ATQA) */
DiegoOstuni 0:75fc82583a41 179 rfalNfcaSelRes selRes; /*!< SEL_RES (SAK) */
DiegoOstuni 0:75fc82583a41 180 uint8_t nfcId1Len; /*!< NFCID1 Length */
DiegoOstuni 0:75fc82583a41 181 uint8_t nfcId1[RFAL_NFCA_CASCADE_3_UID_LEN]; /*!< NFCID1 (UID) */
DiegoOstuni 0:75fc82583a41 182 #ifdef RFAL_FEATURE_T1T
DiegoOstuni 0:75fc82583a41 183 rfalT1TRidRes ridRes; /*!< RID_RES */
DiegoOstuni 0:75fc82583a41 184 #endif /* RFAL_FEATURE_T1T */
DiegoOstuni 0:75fc82583a41 185 bool isSleep; /*!< Device sleeping flag */
DiegoOstuni 0:75fc82583a41 186 } rfalNfcaListenDevice;
DiegoOstuni 0:75fc82583a41 187
DiegoOstuni 0:75fc82583a41 188 /*
DiegoOstuni 0:75fc82583a41 189 ******************************************************************************
DiegoOstuni 0:75fc82583a41 190 * GLOBAL FUNCTION PROTOTYPES
DiegoOstuni 0:75fc82583a41 191 ******************************************************************************
DiegoOstuni 0:75fc82583a41 192 */
DiegoOstuni 0:75fc82583a41 193
DiegoOstuni 0:75fc82583a41 194 /*!
DiegoOstuni 0:75fc82583a41 195 *****************************************************************************
DiegoOstuni 0:75fc82583a41 196 * \brief Initialize NFC-A Poller mode
DiegoOstuni 0:75fc82583a41 197 *
DiegoOstuni 0:75fc82583a41 198 * This methods configures RFAL RF layer to perform as a
DiegoOstuni 0:75fc82583a41 199 * NFC-A Poller/RW (ISO14443A PCD) including all default timings and bit rate
DiegoOstuni 0:75fc82583a41 200 * to 106 kbps
DiegoOstuni 0:75fc82583a41 201
DiegoOstuni 0:75fc82583a41 202 *
DiegoOstuni 0:75fc82583a41 203 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 204 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 205 *****************************************************************************
DiegoOstuni 0:75fc82583a41 206 */
DiegoOstuni 0:75fc82583a41 207 ReturnCode rfalNfcaPollerInitialize( 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 208
DiegoOstuni 0:75fc82583a41 209
DiegoOstuni 0:75fc82583a41 210 /*!
DiegoOstuni 0:75fc82583a41 211 *****************************************************************************
DiegoOstuni 0:75fc82583a41 212 * \brief NFC-A Poller Check Presence
DiegoOstuni 0:75fc82583a41 213 *
DiegoOstuni 0:75fc82583a41 214 * This method checks if a NFC-A Listen device (PICC) is present on the field
DiegoOstuni 0:75fc82583a41 215 * by sending an ALL_REQ (WUPA) or SENS_REQ (REQA)
DiegoOstuni 0:75fc82583a41 216 *
DiegoOstuni 0:75fc82583a41 217 * \param[in] cmd : Indicate if to send an ALL_REQ or a SENS_REQ
DiegoOstuni 0:75fc82583a41 218 * \param[out] sensRes : If received, the SENS_RES
DiegoOstuni 0:75fc82583a41 219 *
DiegoOstuni 0:75fc82583a41 220 * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
DiegoOstuni 0:75fc82583a41 221 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 222 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 223 * \return ERR_RF_COLLISION : Collision detected one or more device in the field
DiegoOstuni 0:75fc82583a41 224 * \return ERR_PAR : Parity error detected, one or more device in the field
DiegoOstuni 0:75fc82583a41 225 * \return ERR_CRC : CRC error detected, one or more device in the field
DiegoOstuni 0:75fc82583a41 226 * \return ERR_FRAMING : Framing error detected, one or more device in the field
DiegoOstuni 0:75fc82583a41 227 * \return ERR_PROTO : Protocol error detected, one or more device in the field
DiegoOstuni 0:75fc82583a41 228 * \return ERR_TIMEOUT : Timeout error, no listener device detected
DiegoOstuni 0:75fc82583a41 229 * \return ERR_NONE : No error, one or more device in the field
DiegoOstuni 0:75fc82583a41 230 *****************************************************************************
DiegoOstuni 0:75fc82583a41 231 */
DiegoOstuni 0:75fc82583a41 232 ReturnCode rfalNfcaPollerCheckPresence( rfal14443AShortFrameCmd cmd, rfalNfcaSensRes *sensRes, 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 233
DiegoOstuni 0:75fc82583a41 234
DiegoOstuni 0:75fc82583a41 235 /*!
DiegoOstuni 0:75fc82583a41 236 *****************************************************************************
DiegoOstuni 0:75fc82583a41 237 * \brief NFC-A Poller Select
DiegoOstuni 0:75fc82583a41 238 *
DiegoOstuni 0:75fc82583a41 239 * This method selects a NFC-A Listener device (PICC)
DiegoOstuni 0:75fc82583a41 240 *
DiegoOstuni 0:75fc82583a41 241 * \param[in] nfcid1 : Listener device NFCID1 to be selected
DiegoOstuni 0:75fc82583a41 242 * \param[in] nfcidLen : Length of the NFCID1 to be selected
DiegoOstuni 0:75fc82583a41 243 * \param[out] selRes : pointer to place the SEL_RES
DiegoOstuni 0:75fc82583a41 244 *
DiegoOstuni 0:75fc82583a41 245 * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
DiegoOstuni 0:75fc82583a41 246 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 247 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 248 * \return ERR_TIMEOUT : Timeout error
DiegoOstuni 0:75fc82583a41 249 * \return ERR_PAR : Parity error detected
DiegoOstuni 0:75fc82583a41 250 * \return ERR_CRC : CRC error detected
DiegoOstuni 0:75fc82583a41 251 * \return ERR_FRAMING : Framing error detected
DiegoOstuni 0:75fc82583a41 252 * \return ERR_PROTO : Protocol error detected
DiegoOstuni 0:75fc82583a41 253 * \return ERR_NONE : No error, SEL_RES received
DiegoOstuni 0:75fc82583a41 254 *****************************************************************************
DiegoOstuni 0:75fc82583a41 255 */
DiegoOstuni 0:75fc82583a41 256 ReturnCode rfalNfcaPollerSelect( uint8_t *nfcid1, uint8_t nfcidLen, rfalNfcaSelRes *selRes, 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 257
DiegoOstuni 0:75fc82583a41 258
DiegoOstuni 0:75fc82583a41 259 /*!
DiegoOstuni 0:75fc82583a41 260 *****************************************************************************
DiegoOstuni 0:75fc82583a41 261 * \brief NFC-A Poller Sleep
DiegoOstuni 0:75fc82583a41 262 *
DiegoOstuni 0:75fc82583a41 263 * This method sends a SLP_REQ (HLTA)
DiegoOstuni 0:75fc82583a41 264 * No response is expected afterwards Digital 1.1 6.9.2.1
DiegoOstuni 0:75fc82583a41 265 *
DiegoOstuni 0:75fc82583a41 266 * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
DiegoOstuni 0:75fc82583a41 267 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 268 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 269 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 270 *****************************************************************************
DiegoOstuni 0:75fc82583a41 271 */
DiegoOstuni 0:75fc82583a41 272 ReturnCode rfalNfcaPollerSleep( 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 273
DiegoOstuni 0:75fc82583a41 274
DiegoOstuni 0:75fc82583a41 275 /*!
DiegoOstuni 0:75fc82583a41 276 *****************************************************************************
DiegoOstuni 0:75fc82583a41 277 * \brief NFC-A Technology Detection
DiegoOstuni 0:75fc82583a41 278 *
DiegoOstuni 0:75fc82583a41 279 * This method performs NFC-A Technology Detection as defined in the spec
DiegoOstuni 0:75fc82583a41 280 * given in the compliance mode
DiegoOstuni 0:75fc82583a41 281 *
DiegoOstuni 0:75fc82583a41 282 * \param[in] compMode : compliance mode to be performed
DiegoOstuni 0:75fc82583a41 283 * \param[out] sensRes : location to store the SENS_RES, if received
DiegoOstuni 0:75fc82583a41 284 *
DiegoOstuni 0:75fc82583a41 285 * When compMode is set to ISO compliance a SLP_REQ (HLTA) is not sent
DiegoOstuni 0:75fc82583a41 286 * after detection. When set to EMV a ALL_REQ (WUPA) is sent instead of
DiegoOstuni 0:75fc82583a41 287 * a SENS_REQ (REQA)
DiegoOstuni 0:75fc82583a41 288 *
DiegoOstuni 0:75fc82583a41 289 * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
DiegoOstuni 0:75fc82583a41 290 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 291 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 292 * \return ERR_NONE : No error, one or more device in the field
DiegoOstuni 0:75fc82583a41 293 *****************************************************************************
DiegoOstuni 0:75fc82583a41 294 */
DiegoOstuni 0:75fc82583a41 295 ReturnCode rfalNfcaPollerTechnologyDetection( rfalComplianceMode compMode, rfalNfcaSensRes *sensRes, 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 296
DiegoOstuni 0:75fc82583a41 297
DiegoOstuni 0:75fc82583a41 298 /*!
DiegoOstuni 0:75fc82583a41 299 *****************************************************************************
DiegoOstuni 0:75fc82583a41 300 * \brief NFC-A Poller Collision Resolution
DiegoOstuni 0:75fc82583a41 301 *
DiegoOstuni 0:75fc82583a41 302 * Collision resolution for one NFC-A Listener device/card (PICC) as
DiegoOstuni 0:75fc82583a41 303 * defined in Activity 1.1 9.3.4
DiegoOstuni 0:75fc82583a41 304 *
DiegoOstuni 0:75fc82583a41 305 * This method executes anti collision loop and select the device with higher NFCID1
DiegoOstuni 0:75fc82583a41 306 *
DiegoOstuni 0:75fc82583a41 307 * When devLimit = 0 it is configured to perform collision detection only. Once a collision
DiegoOstuni 0:75fc82583a41 308 * is detected the collision resolution is aborted immidiatly. If only one device is found
DiegoOstuni 0:75fc82583a41 309 * with no collisions, it will properly resolved.
DiegoOstuni 0:75fc82583a41 310 *
DiegoOstuni 0:75fc82583a41 311 * \param[in] devLimit : device limit value (CON_DEVICES_LIMIT)
DiegoOstuni 0:75fc82583a41 312 * \param[out] collPending : pointer to collision pending flag (INT_COLL_PEND)
DiegoOstuni 0:75fc82583a41 313 * \param[out] selRes : location to store the last Select Response from listener device (PICC)
DiegoOstuni 0:75fc82583a41 314 * \param[out] nfcId1 : location to store the NFCID1 (UID), ensure RFAL_NFCA_CASCADE_3_UID_LEN
DiegoOstuni 0:75fc82583a41 315 * \param[out] nfcId1Len : pointer to length of NFCID1 (UID)
DiegoOstuni 0:75fc82583a41 316 *
DiegoOstuni 0:75fc82583a41 317 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 318 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 319 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 320 * \return ERR_PROTO : Card length invalid
DiegoOstuni 0:75fc82583a41 321 * \return ERR_IGNORE : conDevLimit is 0 and there is a collision
DiegoOstuni 0:75fc82583a41 322 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 323 *****************************************************************************
DiegoOstuni 0:75fc82583a41 324 */
DiegoOstuni 0:75fc82583a41 325 ReturnCode rfalNfcaPollerSingleCollisionResolution( uint8_t devLimit, bool *collPending, rfalNfcaSelRes *selRes, uint8_t *nfcId1, uint8_t *nfcId1Len, 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 326
DiegoOstuni 0:75fc82583a41 327
DiegoOstuni 0:75fc82583a41 328 /*!
DiegoOstuni 0:75fc82583a41 329 *****************************************************************************
DiegoOstuni 0:75fc82583a41 330 * \brief NFC-A Poller Full Collision Resolution
DiegoOstuni 0:75fc82583a41 331 *
DiegoOstuni 0:75fc82583a41 332 * Performs a full Collision resolution as defined in Activity 1.0 or 1.1 9.3.4
DiegoOstuni 0:75fc82583a41 333 *
DiegoOstuni 0:75fc82583a41 334 * \param[in] compMode : compliance mode to be performed
DiegoOstuni 0:75fc82583a41 335 * \param[in] devLimit : device limit value, and size nfcaDevList
DiegoOstuni 0:75fc82583a41 336 * \param[out] nfcaDevList : NFC-A listener device info
DiegoOstuni 0:75fc82583a41 337 * \param[out] devCnt : Devices found counter
DiegoOstuni 0:75fc82583a41 338 *
DiegoOstuni 0:75fc82583a41 339 * When compMode is set to ISO compliance it assumes that the device is
DiegoOstuni 0:75fc82583a41 340 * not sleeping and therefore no ALL_REQ (WUPA) is sent at the beginning.
DiegoOstuni 0:75fc82583a41 341 *
DiegoOstuni 0:75fc82583a41 342 * When compMode is set to NFC compliance an additional ALL_REQ (WUPA) is sent at
DiegoOstuni 0:75fc82583a41 343 * the beginning and a proprietary behaviour also takes place. Once a device has been
DiegoOstuni 0:75fc82583a41 344 * resolved an additional SLP_REQ (HLTA) is sent regardless if there was a collision
DiegoOstuni 0:75fc82583a41 345 * (except if the number of devices found already equals the limit).
DiegoOstuni 0:75fc82583a41 346 * This proprietary behaviour ensures proper activation of certain devices that suffer
DiegoOstuni 0:75fc82583a41 347 * from influence of Type B commands as foreseen in ISO14443-3 5.2.3
DiegoOstuni 0:75fc82583a41 348 *
DiegoOstuni 0:75fc82583a41 349 *
DiegoOstuni 0:75fc82583a41 350 * When devLimit = 0 it is configured to perform collision detection only. Once a collision
DiegoOstuni 0:75fc82583a41 351 * is detected the collision resolution is aborted immidiatly. If only one device is found
DiegoOstuni 0:75fc82583a41 352 * with no collisions, it will properly resolved.
DiegoOstuni 0:75fc82583a41 353 *
DiegoOstuni 0:75fc82583a41 354 *
DiegoOstuni 0:75fc82583a41 355 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 356 * \return ERR_PARAM : Invalid parameters
DiegoOstuni 0:75fc82583a41 357 * \return ERR_IO : Generic internal error
DiegoOstuni 0:75fc82583a41 358 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 359 *****************************************************************************
DiegoOstuni 0:75fc82583a41 360 */
DiegoOstuni 0:75fc82583a41 361 ReturnCode rfalNfcaPollerFullCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt, 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 362
DiegoOstuni 0:75fc82583a41 363
DiegoOstuni 0:75fc82583a41 364 /*!
DiegoOstuni 0:75fc82583a41 365 *****************************************************************************
DiegoOstuni 0:75fc82583a41 366 * \brief NFC-A Listener is SLP_REQ
DiegoOstuni 0:75fc82583a41 367 *
DiegoOstuni 0:75fc82583a41 368 * Checks if the given buffer contains valid NFC-A SLP_REQ (HALT)
DiegoOstuni 0:75fc82583a41 369 *
DiegoOstuni 0:75fc82583a41 370 * \param[in] buf: buffer containing data
DiegoOstuni 0:75fc82583a41 371 * \param[in] bufLen: length of the data in buffer to be checked
DiegoOstuni 0:75fc82583a41 372 *
DiegoOstuni 0:75fc82583a41 373 * \return true if data in buf contains a SLP_REQ ; false otherwise
DiegoOstuni 0:75fc82583a41 374 *****************************************************************************
DiegoOstuni 0:75fc82583a41 375 */
DiegoOstuni 0:75fc82583a41 376 bool rfalNfcaListenerIsSleepReq( uint8_t *buf, uint16_t bufLen );
DiegoOstuni 0:75fc82583a41 377
DiegoOstuni 0:75fc82583a41 378 #endif /* RFAL_NFCA_H */
DiegoOstuni 0:75fc82583a41 379
DiegoOstuni 0:75fc82583a41 380 /**
DiegoOstuni 0:75fc82583a41 381 * @}
DiegoOstuni 0:75fc82583a41 382 *
DiegoOstuni 0:75fc82583a41 383 * @}
DiegoOstuni 0:75fc82583a41 384 *
DiegoOstuni 0:75fc82583a41 385 * @}
DiegoOstuni 0:75fc82583a41 386 */