Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
rfal_rf.h
00001 00002 /****************************************************************************** 00003 * @attention 00004 * 00005 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> 00006 * 00007 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); 00008 * You may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at: 00010 * 00011 * http://www.st.com/myliberty 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 00016 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 * 00021 ******************************************************************************/ 00022 00023 00024 /* 00025 * PROJECT: ST25R391x firmware 00026 * $Revision: $ 00027 * LANGUAGE: ISO C99 00028 */ 00029 00030 /*! \file rfal_rf.h 00031 * 00032 * \author Gustavo Patricio 00033 * 00034 * \brief RF Abstraction Layer (RFAL) 00035 * 00036 * RFAL (RF Abstraction Layer) provides several functionalities required to 00037 * perform RF/NFC communications. <br>The RFAL encapsulates the different 00038 * RF ICs (ST25R3911, ST25R391x, etc) into a common and easy to use interface. 00039 * 00040 * It provides interfaces to configure the RF IC, set/get timings, modes, bit rates, 00041 * specific handlings, execute listen mode, etc. 00042 * 00043 * Furthermore it provides a common interface to perform a Transceive operations. 00044 * The Transceive can be executed in a blocking or non blocking way.<br> 00045 * Additionally few specific Transceive methods are available to cope with the 00046 * specifics of these particular operations. 00047 * 00048 * The most common interfaces are: 00049 * <br> rfalInitialize() 00050 * <br> rfalSetFDTPoll() 00051 * <br> rfalSetFDTListen() 00052 * <br> rfalSetGT() 00053 * <br> rfalSetBitRate() 00054 * <br> rfalSetMode() 00055 * <br> rfalFieldOnAndStartGT() 00056 * <br> rfalFieldOff() 00057 * <br> rfalStartTransceive() 00058 * <br> rfalGetTransceiveStatus() 00059 * <br> rfalTransceiveBlockingTxRx() 00060 * 00061 * 00062 * @addtogroup RFAL 00063 * @{ 00064 * 00065 * @addtogroup RFAL-HAL 00066 * @brief RFAL Hardware Abstraction Layer 00067 * @{ 00068 * 00069 * @addtogroup RF 00070 * @brief RFAL RF Abstraction Layer 00071 * @{ 00072 * 00073 */ 00074 00075 #ifndef RFAL_RF_H 00076 #define RFAL_RF_H 00077 00078 /* 00079 ****************************************************************************** 00080 * INCLUDES 00081 ****************************************************************************** 00082 */ 00083 #include "platform1.h" 00084 #include "st_errno.h" 00085 #include "rfal_features.h" 00086 #include "st25r3911_com.h" 00087 #include <stdint.h> 00088 00089 /* 00090 ****************************************************************************** 00091 * GLOBAL DEFINES 00092 ****************************************************************************** 00093 */ 00094 #define RFAL_VERSION (uint32_t)0x010302 /*!< RFAL Current Version: v1.3.2 */ 00095 00096 #define RFAL_FWT_NONE 0xFFFFFFFF /*!< Disabled FWT: Wait forever for a response */ 00097 #define RFAL_GT_NONE RFAL_TIMING_NONE /*!< Disabled GT: No GT will be applied after Field On */ 00098 00099 #define RFAL_TIMING_NONE 0x00 /*!< Timing disabled | Don't apply */ 00100 00101 #define RFAL_1FC_IN_4096FC (uint32_t)4096 /*!< Number of 1/fc cycles in one 4096/fc */ 00102 #define RFAL_1FC_IN_512FC (uint32_t)512 /*!< Number of 1/fc cycles in one 512/fc */ 00103 #define RFAL_1FC_IN_64FC (uint32_t)64 /*!< Number of 1/fc cycles in one 64/fc */ 00104 #define RFAL_1FC_IN_8FC (uint32_t)8 /*!< Number of 1/fc cycles in one 8/fc */ 00105 #define RFAL_US_IN_MS (uint32_t)1000 /*!< Number of us in one ms */ 00106 #define RFAL_1MS_IN_1FC (uint32_t)13560 /*!< Number of 1/fc cycles in 1ms */ 00107 #define RFAL_BITS_IN_BYTE (uint16_t)8 /*!< Number of bits in one byte */ 00108 00109 #define RFAL_CRC_LEN 2 /*!< RF CRC LEN */ 00110 00111 /*! Default TxRx flags: Tx CRC automatic, Rx CRC removed, NFCIP1 mode off, AGC On, Tx Parity automatic, Rx Parity removed */ 00112 #define RFAL_TXRX_FLAGS_DEFAULT ( RFAL_TXRX_FLAGS_CRC_TX_AUTO | RFAL_TXRX_FLAGS_CRC_RX_REMV | RFAL_TXRX_FLAGS_NFCIP1_OFF | RFAL_TXRX_FLAGS_AGC_ON | RFAL_TXRX_FLAGS_PAR_RX_REMV | RFAL_TXRX_FLAGS_PAR_TX_AUTO | RFAL_TXRX_FLAGS_NFCV_FLAG_AUTO) 00113 00114 00115 #define RFAL_LM_MASK_NFCA (1<<RFAL_MODE_LISTEN_NFCA) /*!< Bitmask for Listen Mode enabling Listen NFCA */ 00116 #define RFAL_LM_MASK_NFCB (1<<RFAL_MODE_LISTEN_NFCB) /*!< Bitmask for Listen Mode enabling Listen NFCB */ 00117 #define RFAL_LM_MASK_NFCF (1<<RFAL_MODE_LISTEN_NFCF) /*!< Bitmask for Listen Mode enabling Listen NFCF */ 00118 #define RFAL_LM_MASK_ACTIVE_P2P (1<<RFAL_MODE_LISTEN_ACTIVE_P2P) /*!< Bitmask for Listen Mode enabling Listen AP2P */ 00119 00120 #define RFAL_LM_SENS_RES_LEN 2 /*!< NFC-A SENS_RES (ATQA) length */ 00121 #define RFAL_LM_SENSB_RES_LEN 13 /*!< NFC-B SENSB_RES (ATQB) length */ 00122 #define RFAL_LM_SENSF_RES_LEN 19 /*!< NFC-F SENSF_RES length */ 00123 #define RFAL_LM_SENSF_SC_LEN 2 /*!< NFC-F System Code length */ 00124 00125 #define RFAL_NFCID3_LEN 10 /*!< NFCID3 length */ 00126 #define RFAL_NFCID2_LEN 7 /*!< NFCID2 length */ 00127 #define RFAL_NFCID1_LEN 4 /*!< NFCID1 length */ 00128 00129 00130 /* 00131 ****************************************************************************** 00132 * GLOBAL MACROS 00133 ****************************************************************************** 00134 */ 00135 00136 /*! Returns the maximum supported bit rate for RW mode. Caller must check if mode is supported before, as even if mode is not supported will return the min */ 00137 #define rfalGetMaxBrRW() ( ((RFAL_SUPPORT_BR_RW_6780) ? RFAL_BR_6780 : ((RFAL_SUPPORT_BR_RW_3390) ? RFAL_BR_3390 : ((RFAL_SUPPORT_BR_RW_1695) ? RFAL_BR_1695 : ((RFAL_SUPPORT_BR_RW_848) ? RFAL_BR_848 : ((RFAL_SUPPORT_BR_RW_424) ? RFAL_BR_424 : ((RFAL_SUPPORT_BR_RW_212) ? RFAL_BR_212 : RFAL_BR_106 ) ) ) ) ) ) ) 00138 00139 /*! Returns the maximum supported bit rate for AP2P mode. Caller must check if mode is supported before, as even if mode is not supported will return the min */ 00140 #define rfalGetMaxBrAP2P() ( ((RFAL_SUPPORT_BR_AP2P_848) ? RFAL_BR_848 : ((RFAL_SUPPORT_BR_AP2P_424) ? RFAL_BR_424 : ((RFAL_SUPPORT_BR_AP2P_212) ? RFAL_BR_212 : RFAL_BR_106 ) ) ) ) 00141 00142 /*! Returns the maximum supported bit rate for CE-A mode. Caller must check if mode is supported before, as even if mode is not supported will return the min */ 00143 #define rfalGetMaxBrCEA() ( ((RFAL_SUPPORT_BR_CE_A_848) ? RFAL_BR_848 : ((RFAL_SUPPORT_BR_CE_A_424) ? RFAL_BR_424 : ((RFAL_SUPPORT_BR_CE_A_212) ? RFAL_BR_212 : RFAL_BR_106 ) ) ) ) 00144 00145 /*! Returns the maximum supported bit rate for CE-B mode. Caller must check if mode is supported before, as even if mode is not supported will return the min */ 00146 #define rfalGetMaxBrCEB() ( ((RFAL_SUPPORT_BR_CE_B_848) ? RFAL_BR_848 : ((RFAL_SUPPORT_BR_CE_B_424) ? RFAL_BR_424 : ((RFAL_SUPPORT_BR_CE_B_212) ? RFAL_BR_212 : RFAL_BR_106 ) ) ) ) 00147 00148 /*! Returns the maximum supported bit rate for CE-F mode. Caller must check if mode is supported before, as even if mode is not supported will return the min */ 00149 #define rfalGetMaxBrCEF() ( ((RFAL_SUPPORT_BR_CE_F_424) ? RFAL_BR_424 : RFAL_BR_212 ) ) 00150 00151 #define rfalConv1fcTo8fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_8FC ) /*!< Converts the given t from 1/fc to 8/fc */ 00152 #define rfalConv8fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_8FC ) /*!< Converts the given t from 8/fc to 1/fc */ 00153 00154 #define rfalConv1fcTo64fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_64FC ) /*!< Converts the given t from 1/fc to 64/fc */ 00155 #define rfalConv64fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_64FC ) /*!< Converts the given t from 64/fc to 1/fc */ 00156 00157 #define rfalConv1fcTo512fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_512FC ) /*!< Converts the given t from 1/fc to 512/fc */ 00158 #define rfalConv512fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_512FC ) /*!< Converts the given t from 512/fc to 1/fc */ 00159 00160 #define rfalConv1fcTo4096fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_4096FC ) /*!< Converts the given t from 1/fc to 4096/fc */ 00161 #define rfalConv4096fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_4096FC ) /*!< Converts the given t from 4096/fc to 1/fc */ 00162 00163 #define rfalConv1fcToMs( t ) (uint32_t)( (t) / RFAL_1MS_IN_1FC ) /*!< Converts the given t from 1/fc to ms */ 00164 #define rfalConvMsTo1fc( t ) (uint32_t)( (t) * RFAL_1MS_IN_1FC ) /*!< Converts the given t from ms to 1/fc */ 00165 00166 #define rfalConv1fcToUs( t ) (uint32_t)( (t * RFAL_US_IN_MS) / RFAL_1MS_IN_1FC) /*!< Converts the given t from 1/fc to us */ 00167 #define rfalConvUsTo1fc( t ) (uint32_t)( (t * RFAL_1MS_IN_1FC) / RFAL_US_IN_MS) /*!< Converts the given t from us to 1/fc */ 00168 00169 #define rfalConv64fcToMs( t ) (uint32_t)( (t) / (RFAL_1MS_IN_1FC / RFAL_1FC_IN_64FC) ) /*!< Converts the given t from 64/fc to ms */ 00170 #define rfalConvMsTo64fc( t ) (uint32_t)( (t) * (RFAL_1MS_IN_1FC / RFAL_1FC_IN_64FC) ) /*!< Converts the given t from ms to 64/fc */ 00171 00172 #define rfalConvBitsToBytes( n ) (uint32_t)( (n+(RFAL_BITS_IN_BYTE-1)) / (RFAL_BITS_IN_BYTE) ) /*!< Converts the given n from bits to bytes */ 00173 #define rfalConvBytesToBits( n ) (uint32_t)( (n) * (RFAL_BITS_IN_BYTE) ) /*!< Converts the given n from bytes to bits */ 00174 00175 00176 00177 #define rfalIsTransceiveInTx( ) ( !rfalIsTransceiveInRx() && (rfalGetTransceiveState() >= RFAL_TXRX_STATE_TX_IDLE) ) /*!< Checks if Transceive is in a Transmission state ( Transmit ongoing ) */ 00178 #define rfalIsTransceiveInRx( ) ( rfalGetTransceiveState() >= RFAL_TXRX_STATE_RX_IDLE ) /*!< Checks if Transceive is in a Reception state ( Transmit done ) */ 00179 00180 00181 00182 00183 /*! Computes a Transceive context \a ctx with default flags and the lengths 00184 * in bytes with the given arguments 00185 * \a ctx : Transceive context to be assigned 00186 * \a tB : txBuf the pointer to the buffer to be sent 00187 * \a tBL : txBuf length in bytes 00188 * \a rB : rxBuf the pointer to the buffer to place the received frame 00189 * \a rBL : rxBuf length in bytes 00190 * \a rBL : rxBuf length in bytes 00191 * \a t : FWT to be used on this transceive in 1/fc 00192 */ 00193 #define rfalCreateByteTxRxContext( ctx, tB, tBL, rB, rBL, rdL, t ) \ 00194 ctx.txBuf = (tB); \ 00195 ctx.txBufLen = rfalConvBytesToBits(tBL); \ 00196 ctx.rxBuf = (rB); \ 00197 ctx.rxBufLen = rfalConvBytesToBits(rBL); \ 00198 ctx.rxRcvdLen = rdL; \ 00199 ctx.flags = RFAL_TXRX_FLAGS_DEFAULT; \ 00200 ctx.fwt = (t); 00201 00202 00203 /*! Computes a Transceive context \a ctx using lengths in bytes 00204 * with the given flags and arguments 00205 * \a ctx : Transceive context to be assigned 00206 * \a tB : txBuf the pointer to the buffer to be sent 00207 * \a tBL : txBuf length in bytes 00208 * \a rB : rxBuf the pointer to the buffer to place the received frame 00209 * \a rBL : rxBuf length in bytes 00210 * \a rBL : rxBuf length in bytes 00211 * \a t : FWT to be used on this transceive in 1/fc 00212 */ 00213 #define rfalCreateByteFlagsTxRxContext( ctx, tB, tBL, rB, rBL, rdL, fl, t ) \ 00214 ctx.txBuf = (tB); \ 00215 ctx.txBufLen = rfalConvBytesToBits(tBL); \ 00216 ctx.rxBuf = (rB); \ 00217 ctx.rxBufLen = rfalConvBytesToBits(rBL); \ 00218 ctx.rxRcvdLen = rdL; \ 00219 ctx.flags = (fl); \ 00220 ctx.fwt = (t); 00221 00222 00223 #define rfalLogE(...) //(__VA_ARGS__) /*!< Macro for the error log method */ 00224 #define rfalLogW(...) //(__VA_ARGS__) /*!< Macro for the warning log method */ 00225 #define rfalLogI(...) //(__VA_ARGS__) /*!< Macro for the info log method */ 00226 #define rfalLogD(...) //(__VA_ARGS__) /*!< Macro for the debug log method */ 00227 00228 00229 /* 00230 ****************************************************************************** 00231 * GLOBAL ENUMS 00232 ****************************************************************************** 00233 */ 00234 00235 /*! RFAL Guard Time (GT) default values */ 00236 enum { 00237 RFAL_GT_NFCA = rfalConvMsTo1fc(5), /*!< GTA Digital 1.1 6.10.4.1 & A.2 */ 00238 RFAL_GT_NFCB = rfalConvMsTo1fc(5), /*!< GTB Digital 1.1 7.9.4.1 & A.3 */ 00239 RFAL_GT_NFCF = rfalConvMsTo1fc(20), /*!< GTF Digital 1.1 8.7.4.1 & A.4 */ 00240 RFAL_GT_NFCV = rfalConvMsTo1fc(1), /*!< GTV NFC Forum NFCV Change Request 9.7.1.1 & A.2 */ 00241 RFAL_GT_NFCV_ADJUSTED = rfalConvMsTo1fc(1+4), /*!< Adjusted GT for greater interoperability (ISO15693 Dynamic Tags) */ 00242 RFAL_GT_PICOPASS = rfalConvMsTo1fc(1), /*!< GT Picopass */ 00243 RFAL_GT_AP2P = rfalConvMsTo1fc(5), /*!< TIRFG Ecma 340 11.1.1 */ 00244 RFAL_GT_AP2P_ADJUSTED = rfalConvMsTo1fc(5+25) /*!< Adjusted GT for greater interoperability (Sony XPERIA P, Nokia N9, Huawei P2) */ 00245 }; 00246 00247 00248 /*! RFAL Frame Delay Time (FDT) Listen default values */ 00249 enum { 00250 RFAL_FDT_LISTEN_NFCA_POLLER = 1172, /*!< FDTA,LISTEN,MIN (n=9) Last bit: Logic "1" - tnn,min/2 Digital 1.1 6.10 ; EMV CCP Spec Book D v2.01 4.8.1.3 */ 00251 RFAL_FDT_LISTEN_NFCB_POLLER = 1008, /*!< TR0B,MIN Digital 1.1 7.1.3 & A.3 ; EMV CCP Spec Book D v2.01 4.8.1.3 & Table A.5 */ 00252 RFAL_FDT_LISTEN_NFCF_POLLER = 2672, /*!< TR0F,LISTEN,MIN Digital 1.1 8.7.1.1 & A.4 */ 00253 RFAL_FDT_LISTEN_NFCV_POLLER = 4192, /*!< t1 min 4192/fc (309,2us) ISO15693 3 Table 8 */ 00254 RFAL_FDT_LISTEN_PICOPASS_POLLER = 3400, /*!< ISO15693 t1 min - observed adjustment */ 00255 RFAL_FDT_LISTEN_AP2P_POLLER = 64, /*!< FDT AP2P No actual FDTListen is required as fields switch and collision avoidance */ 00256 RFAL_FDT_LISTEN_NFCA_LISTENER = 1172, /*!< FDTA,LISTEN,MIN Digital 1.1 6.10 */ 00257 RFAL_FDT_LISTEN_NFCB_LISTENER = 1024, /*!< TR0B,MIN Digital 1.1 7.1.3 & A.3 ; EMV CCP Spec Book D v2.01 4.8.1.3 & Table A.5 */ 00258 RFAL_FDT_LISTEN_NFCF_LISTENER = 2688, /*!< TR0F,LISTEN,MIN Digital 1.1 8.7.1.1 & A.4 */ 00259 RFAL_FDT_LISTEN_AP2P_LISTENER = 64 /*!< FDT AP2P No actual FDTListen exists as fields switch and collision avoidance */ 00260 }; 00261 00262 00263 /*! RFAL Frame Delay Time (FDT) Poll default values */ 00264 enum { 00265 RFAL_FDT_POLL_NFCA_POLLER = 6780, /*!< FDTA,POLL,MIN Digital 1.1 6.10.3.1 & A.2 */ 00266 RFAL_FDT_POLL_NFCA_T1T_POLLER = 384, /*!< RRDDT1T,MIN,B1 Digital 1.1 10.7.1 & A.5 */ 00267 RFAL_FDT_POLL_NFCB_POLLER = 6780, /*!< FDTB,POLL,MIN = TR2B,MIN,DEFAULT Digital 1.1 7.9.3 & A.3 */ 00268 RFAL_FDT_POLL_NFCF_POLLER = 2672, /*!< FDTF,POLL,MIN Digital 1.1 8.7.3 & A.4 */ 00269 RFAL_FDT_POLL_NFCV_POLLER = 4192, /*!< FDTV,POLL NFC Forum NFCV Change Request A.2*/ 00270 RFAL_FDT_POLL_PICOPASS_POLLER = 1790, /*!< FDT Max */ 00271 RFAL_FDT_POLL_AP2P_POLLER = 0 /*!< FDT AP2P No actual FDTPoll exists as fields switch and collision avoidance */ 00272 }; 00273 00274 00275 /* 00276 ****************************************************************************** 00277 * GLOBAL TYPES 00278 ****************************************************************************** 00279 */ 00280 00281 /*! RFAL modes */ 00282 typedef enum { 00283 RFAL_MODE_NONE = 0, /*!< No mode selected/defined */ 00284 RFAL_MODE_POLL_NFCA = 1, /*!< Mode to perform as NFCA (ISO14443A) Poller (PCD) */ 00285 RFAL_MODE_POLL_NFCA_T1T = 2, /*!< Mode to perform as NFCA T1T (Topaz) Poller (PCD) */ 00286 RFAL_MODE_POLL_NFCB = 3, /*!< Mode to perform as NFCB (ISO14443B) Poller (PCD) */ 00287 RFAL_MODE_POLL_B_PRIME = 4, /*!< Mode to perform as B' Calypso (Innovatron) (PCD) */ 00288 RFAL_MODE_POLL_B_CTS = 5, /*!< Mode to perform as CTS Poller (PCD) */ 00289 RFAL_MODE_POLL_NFCF = 6, /*!< Mode to perform as NFCF (FeliCa) Poller (PCD) */ 00290 RFAL_MODE_POLL_NFCV = 7, /*!< Mode to perform as NFCV (ISO15963) Poller (PCD) */ 00291 RFAL_MODE_POLL_PICOPASS = 8, /*!< Mode to perform as PicoPass / iClass Poller (PCD) */ 00292 RFAL_MODE_POLL_ACTIVE_P2P = 9, /*!< Mode to perform as Active P2P (ISO18092) Initiator */ 00293 RFAL_MODE_LISTEN_NFCA = 10, /*!< Mode to perform as NFCA (ISO14443A) Listener (PICC) */ 00294 RFAL_MODE_LISTEN_NFCB = 11, /*!< Mode to perform as NFCA (ISO14443B) Listener (PICC) */ 00295 RFAL_MODE_LISTEN_NFCF = 12, /*!< Mode to perform as NFCA (ISO15963) Listener (PICC) */ 00296 RFAL_MODE_LISTEN_ACTIVE_P2P = 13 /*!< Mode to perform as Active P2P (ISO18092) Target */ 00297 } rfalMode ; 00298 00299 00300 /*! RFAL Bit rates */ 00301 typedef enum { 00302 RFAL_BR_106 = 0, /*!< Bit Rate 106 kbit/s (fc/128) */ 00303 RFAL_BR_212 = 1, /*!< Bit Rate 212 kbit/s (fc/64) */ 00304 RFAL_BR_424 = 2, /*!< Bit Rate 424 kbit/s (fc/32) */ 00305 RFAL_BR_848 = 3, /*!< Bit Rate 848 kbit/s (fc/16) */ 00306 RFAL_BR_1695 = 4, /*!< Bit Rate 1695 kbit/s (fc/8) */ 00307 RFAL_BR_3390 = 5, /*!< Bit Rate 3390 kbit/s (fc/4) */ 00308 RFAL_BR_6780 = 6, /*!< Bit Rate 6780 kbit/s (fc/2) */ 00309 RFAL_BR_52p97 = 0xEB, /*!< Bit Rate 52.97 kbit/s (fc/256) Fast Mode VICC->VCD */ 00310 RFAL_BR_26p48 = 0xEC, /*!< Bit Rate 26,48 kbit/s (fc/512) NFCV VICC->VCD & VCD->VICC 1of4 */ 00311 RFAL_BR_1p66 = 0xED, /*!< Bit Rate 1,66 kbit/s (fc/8192) NFCV VCD->VICC 1of256 */ 00312 RFAL_BR_KEEP = 0xFF /*!< Value indicating to keep the same previous bit rate */ 00313 } rfalBitRate ; 00314 00315 00316 /*! RFAL Compliance modes for upper modules */ 00317 typedef enum { 00318 RFAL_COMPLIANCE_MODE_NFC , /*!< Perform with NFC Forum 1.1 compliance */ 00319 RFAL_COMPLIANCE_MODE_EMV , /*!< Perform with EMVCo compliance */ 00320 RFAL_COMPLIANCE_MODE_ISO /*!< Perform with ISO10373 compliance */ 00321 }rfalComplianceMode ; 00322 00323 00324 /*! RFAL main states flags */ 00325 typedef enum { 00326 RFAL_STATE_IDLE = 0, 00327 RFAL_STATE_INIT = 1, 00328 RFAL_STATE_MODE_SET = 2, 00329 00330 RFAL_STATE_TXRX = 3, 00331 RFAL_STATE_LM = 4, 00332 RFAL_STATE_WUM = 5 00333 00334 } rfalState ; 00335 00336 /*! RFAL transceive states */ 00337 typedef enum { 00338 RFAL_TXRX_STATE_IDLE = 0, 00339 RFAL_TXRX_STATE_INIT = 1, 00340 RFAL_TXRX_STATE_START = 2, 00341 00342 RFAL_TXRX_STATE_TX_IDLE = 11, 00343 RFAL_TXRX_STATE_TX_WAIT_GT = 12, 00344 RFAL_TXRX_STATE_TX_WAIT_FDT = 13, 00345 RFAL_TXRX_STATE_TX_TRANSMIT = 14, 00346 RFAL_TXRX_STATE_TX_WAIT_WL = 15, 00347 RFAL_TXRX_STATE_TX_RELOAD_FIFO = 16, 00348 RFAL_TXRX_STATE_TX_WAIT_TXE = 17, 00349 RFAL_TXRX_STATE_TX_DONE = 18, 00350 RFAL_TXRX_STATE_TX_FAIL = 19, 00351 00352 RFAL_TXRX_STATE_RX_IDLE = 81, 00353 RFAL_TXRX_STATE_RX_WAIT_EON = 82, 00354 RFAL_TXRX_STATE_RX_WAIT_RXS = 83, 00355 RFAL_TXRX_STATE_RX_WAIT_RXE = 84, 00356 RFAL_TXRX_STATE_RX_READ_FIFO = 85, 00357 RFAL_TXRX_STATE_RX_ERR_CHECK = 86, 00358 RFAL_TXRX_STATE_RX_READ_DATA = 87, 00359 RFAL_TXRX_STATE_RX_WAIT_EOF = 88, 00360 RFAL_TXRX_STATE_RX_DONE = 89, 00361 RFAL_TXRX_STATE_RX_FAIL = 90, 00362 00363 } rfalTransceiveState ; 00364 00365 00366 /*! RFAL transceive flags */ 00367 enum { 00368 RFAL_TXRX_FLAGS_CRC_TX_AUTO = (0<<0), /*!< CRC will be generated automatic upon transmission */ 00369 RFAL_TXRX_FLAGS_CRC_TX_MANUAL = (1<<0), /*!< CRC was calculated manually, included in txBuffer */ 00370 RFAL_TXRX_FLAGS_CRC_RX_KEEP = (1<<1), /*!< Upon Reception keep the CRC in rxBuffer (reflected on rcvd length) */ 00371 RFAL_TXRX_FLAGS_CRC_RX_REMV = (0<<1), /*!< Upon Reception remove the CRC from rxBuffer */ 00372 RFAL_TXRX_FLAGS_NFCIP1_ON = (1<<2), /*!< Enable NFCIP1 mode: Add SB(F0) and LEN bytes during Tx and skip SB(F0) byte during Rx */ 00373 RFAL_TXRX_FLAGS_NFCIP1_OFF = (0<<2), /*!< Disable NFCIP1 mode: do not append protocol bytes while Tx nor skip while Rx */ 00374 RFAL_TXRX_FLAGS_AGC_OFF = (1<<3), /*!< Disable Automatic Gain Control, improving multiple devices collision detection */ 00375 RFAL_TXRX_FLAGS_AGC_ON = (0<<3), /*!< Enable Automatic Gain Control, improving single device reception */ 00376 RFAL_TXRX_FLAGS_PAR_RX_KEEP = (1<<4), /*!< Disable Parity and CRC check and keep the Parity and CRC bits in the received buffer */ 00377 RFAL_TXRX_FLAGS_PAR_RX_REMV = (0<<0), /*!< Enable Parity check and remove the parity bits from the received buffer */ 00378 RFAL_TXRX_FLAGS_PAR_TX_NONE = (1<<5), /*!< Disable automatic Parity generation (ISO14443A) and use the one provided in the buffer*/ 00379 RFAL_TXRX_FLAGS_PAR_TX_AUTO = (0<<5), /*!< Enable automatic Parity generation (ISO14443A) */ 00380 RFAL_TXRX_FLAGS_NFCV_FLAG_MANUAL = (1<<6), /*!< Disable automatic adaption of flag byte (ISO15693) according to current comm params */ 00381 RFAL_TXRX_FLAGS_NFCV_FLAG_AUTO = (0<<6), /*!< Enable automatic adaption of flag byte (ISO115693) according to current comm params */ 00382 }; 00383 00384 00385 /*! RFAL error handling */ 00386 typedef enum { 00387 RFAL_ERRORHANDLING_NONE = 0, /*!< No special error handling will be performed */ 00388 RFAL_ERRORHANDLING_NFC = 1, /*!< Error handling set to perform as NFC complaint device */ 00389 RFAL_ERRORHANDLING_EMVCO = 2 /*!< Error handling set to perform as EMVCo complaint device */ 00390 } rfalEHandling ; 00391 00392 00393 /*! Struct that holds all context to be used on a Transceive */ 00394 typedef struct { 00395 uint8_t* txBuf ; /*!< (In) Buffer where outgoing message is located */ 00396 uint16_t txBufLen ; /*!< (In) Length of the outgoing message in bits */ 00397 00398 uint8_t* rxBuf ; /*!< (Out) Buffer where incoming message will be placed */ 00399 uint16_t rxBufLen ; /*!< (In) Maximum length of the incoming message in bits */ 00400 uint16_t* rxRcvdLen ; /*!< (Out) Actual received length in bits */ 00401 00402 uint32_t flags ; /*!< (In) TransceiveFlags indication special handling */ 00403 uint32_t fwt ; /*!< (In) Frame Waiting Time in 1/fc */ 00404 } rfalTransceiveContext ; 00405 00406 00407 /*! System callback to indicate an event that requires a system reRun */ 00408 typedef void (* rfalUpperLayerCallback )(void); 00409 00410 /*! Callback to be executed before a Transceive */ 00411 typedef void (* rfalPreTxRxCallback )(void); 00412 00413 /*! Callback to be executed after a Transceive */ 00414 typedef void (* rfalPostTxRxCallback )(void); 00415 00416 00417 /*******************************************************************************/ 00418 /* ISO14443A */ 00419 /*******************************************************************************/ 00420 00421 /*! RFAL ISO 14443A Short Frame Command */ 00422 typedef enum 00423 { 00424 RFAL_14443A_SHORTFRAME_CMD_WUPA = 0x52, /*!< ISO14443A WUPA / NFC-A ALL_REQ */ 00425 RFAL_14443A_SHORTFRAME_CMD_REQA = 0x26 /*!< ISO14443A REQA / NFC-A SENS_REQ */ 00426 } rfal14443AShortFrameCmd ; 00427 00428 /*******************************************************************************/ 00429 00430 00431 /*******************************************************************************/ 00432 /* FeliCa */ 00433 /*******************************************************************************/ 00434 00435 #define RFAL_FELICA_LEN_LEN 1 /*!< FeliCa LEN byte length */ 00436 #define RFAL_FELICA_POLL_REQ_LEN (RFAL_FELICA_LEN_LEN + 1 + 2 + 1 + 1) /*!< FeliCa Poll Request length (LEN + CMD + SC + RC + TSN) */ 00437 #define RFAL_FELICA_POLL_RES_LEN (RFAL_FELICA_LEN_LEN + 1 + 8 + 8 + 2) /*!< Maximum FeliCa Poll Response length (LEN + CMD + NFCID2 + PAD + RD) */ 00438 #define RFAL_FELICA_POLL_MAX_SLOTS 16 /*!< Maximum number of slots (TSN) on FeliCa Poll */ 00439 00440 00441 /*! NFC-F RC (Request Code) codes NFC Forum Digital 1.1 Table 42 */ 00442 enum 00443 { 00444 RFAL_FELICA_POLL_RC_NO_REQUEST = 0x00, /*!< RC: No System Code information requested */ 00445 RFAL_FELICA_POLL_RC_SYSTEM_CODE = 0x01, /*!< RC: System Code information requested */ 00446 RFAL_FELICA_POLL_RC_COM_PERFORMANCE = 0x02 /*!< RC: Advanced protocol features supported */ 00447 }; 00448 00449 00450 /*! NFC-F TSN (Time Slot Number) codes NFC Forum Digital 1.1 Table 43 */ 00451 typedef enum 00452 { 00453 RFAL_FELICA_1_SLOT = 0, /*!< TSN with number of Time Slots: 1 */ 00454 RFAL_FELICA_2_SLOTS = 1, /*!< TSN with number of Time Slots: 2 */ 00455 RFAL_FELICA_4_SLOTS = 3, /*!< TSN with number of Time Slots: 4 */ 00456 RFAL_FELICA_8_SLOTS = 7, /*!< TSN with number of Time Slots: 8 */ 00457 RFAL_FELICA_16_SLOTS = 15 /*!< TSN with number of Time Slots: 16 */ 00458 } rfalFeliCaPollSlots ; 00459 00460 00461 /*! NFCF Poll Response NFC Forum Digital 1.1 Table 44 */ 00462 typedef uint8_t rfalFeliCaPollRes [RFAL_FELICA_POLL_RES_LEN]; 00463 00464 00465 /*******************************************************************************/ 00466 00467 00468 /*******************************************************************************/ 00469 /* Listen Mode */ 00470 /*******************************************************************************/ 00471 00472 /*! RFAL Listen Mode NFCID Length */ 00473 typedef enum 00474 { 00475 RFAL_LM_NFCID_LEN_04 = 4, /*!< Listen mode indicates 4 byte NFCID */ 00476 RFAL_LM_NFCID_LEN_07 = 7, /*!< Listen mode indicates 7 byte NFCID */ 00477 RFAL_LM_NFCID_LEN_10 = 10, /*!< Listen mode indicates 10 byte NFCID */ 00478 } rfalLmNfcidLen ; 00479 00480 00481 /*! RFAL Listen Mode States */ 00482 typedef enum 00483 { 00484 RFAL_LM_STATE_NOT_INIT = 0x00, /*!< Not Initialized state */ 00485 RFAL_LM_STATE_POWER_OFF = 0x01, /*!< Power Off state */ 00486 RFAL_LM_STATE_IDLE = 0x02, /*!< Idle state Activity 1.1 5.2 */ 00487 RFAL_LM_STATE_READY_A = 0x03, /*!< Ready A state Activity 1.1 5.3 5.4 & 5.5 */ 00488 RFAL_LM_STATE_READY_B = 0x04, /*!< Ready B state Activity 1.1 5.11 5.12 */ 00489 RFAL_LM_STATE_READY_F = 0x05, /*!< Ready F state Activity 1.1 5.15 */ 00490 RFAL_LM_STATE_ACTIVE_A = 0x06, /*!< Active A state Activity 1.1 5.6 */ 00491 RFAL_LM_STATE_CARDEMU_4A = 0x07, /*!< Card Emulation 4A state Activity 1.1 5.10 */ 00492 RFAL_LM_STATE_CARDEMU_4B = 0x08, /*!< Card Emulation 4B state Activity 1.1 5.14 */ 00493 RFAL_LM_STATE_CARDEMU_3 = 0x09, /*!< Card Emulation 3 state Activity 1.1 5.18 */ 00494 RFAL_LM_STATE_TARGET_A = 0x0A, /*!< Target A state Activity 1.1 5.9 */ 00495 RFAL_LM_STATE_TARGET_F = 0x0B, /*!< Target F state Activity 1.1 5.17 */ 00496 RFAL_LM_STATE_SLEEP_A = 0x0C, /*!< Sleep A state Activity 1.1 5.7 */ 00497 RFAL_LM_STATE_SLEEP_B = 0x0D, /*!< Sleep B state Activity 1.1 5.13 */ 00498 RFAL_LM_STATE_READY_Ax = 0x0E, /*!< Ready A* state Activity 1.1 5.3 5.4 & 5.5 */ 00499 RFAL_LM_STATE_ACTIVE_Ax = 0x0F, /*!< Active A* state Activity 1.1 5.6 */ 00500 RFAL_LM_STATE_SLEEP_AF = 0x10, /*!< Sleep AF state Activity 1.1 5.19 */ 00501 } rfalLmState ; 00502 00503 00504 /*! RFAL Listen Mode Passive A configs */ 00505 typedef struct 00506 { 00507 rfalLmNfcidLen nfcidLen ; /*!< NFCID Len (00: 4bytes ; 01: 7bytes) */ 00508 uint8_t nfcid[RFAL_NFCID3_LEN]; /*!< NFCID */ 00509 uint8_t SENS_RES[RFAL_LM_SENS_RES_LEN]; /*!< NFC-106k; SENS_REQ Response */ 00510 uint8_t SEL_RES ; /*!< SEL_RES (SAK) with complete NFCID1 (UID) */ 00511 } rfalLmConfPA ; 00512 00513 00514 /*! RFAL Listen Mode Passive B configs */ 00515 typedef struct 00516 { 00517 uint8_t SENSB_RES[RFAL_LM_SENSB_RES_LEN]; /*!< SENSF_RES */ 00518 } rfalLmConfPB ; 00519 00520 00521 /*! RFAL Listen Mode Passive F configs */ 00522 typedef struct 00523 { 00524 uint8_t SC[RFAL_LM_SENSF_SC_LEN]; /*!< System Code to listen for */ 00525 uint8_t SENSF_RES[RFAL_LM_SENSF_RES_LEN]; /*!< SENSF_RES */ 00526 } rfalLmConfPF ; 00527 00528 /*******************************************************************************/ 00529 00530 00531 /*******************************************************************************/ 00532 /* Wake-Up Mode */ 00533 /*******************************************************************************/ 00534 00535 /*! RFAL Wake-Up Mode States */ 00536 typedef enum 00537 { 00538 RFAL_WUM_STATE_NOT_INIT = 0x00, /*!< Not Initialized state */ 00539 RFAL_WUM_STATE_ENABLED = 0x01, /*!< Wake-Up mode is enabled */ 00540 RFAL_WUM_STATE_ENABLED_WOKE = 0x02, /*!< Wake-Up mode enabled and has received IRQ(s)*/ 00541 } rfalWumState ; 00542 /*******************************************************************************/ 00543 00544 /* 00545 ****************************************************************************** 00546 * GLOBAL FUNCTION PROTOTYPES 00547 ****************************************************************************** 00548 */ 00549 00550 00551 /*! 00552 ***************************************************************************** 00553 * \brief RFAL Initialize 00554 * 00555 * Initializes RFAL layer and the ST25R391x 00556 * Ensures that ST25R391x is properly connected and returns error if any problem 00557 * is detected 00558 * 00559 * \warning rfalAnalogConfigInitialize() should be called before so that 00560 * the Analog config table has been previously initialized. 00561 * 00562 * \return ERR_HW_MISMATCH : Expected HW do not match or communication error 00563 * \return ERR_NONE : No error 00564 ***************************************************************************** 00565 */ 00566 ReturnCode rfalInitialize( 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 ); 00567 00568 00569 /*! 00570 ***************************************************************************** 00571 * \brief RFAL Calibrate 00572 * 00573 * Performs necessary calibration of RF chip in case it is indicated by current 00574 * register settings. E.g. antenna calibration and regulator calibration 00575 * 00576 * \return ERR_WRONG_STATE : RFAL not initialized 00577 * \return ERR_NONE : No error 00578 * 00579 ***************************************************************************** 00580 */ 00581 ReturnCode rfalCalibrate( 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 ); 00582 00583 00584 /*! 00585 ***************************************************************************** 00586 * \brief RFAL Adjust Regulators 00587 * 00588 * Adjusts ST25R391x regulators 00589 * 00590 * \param[out] result : the result of the calibrate antenna in mV 00591 * NULL if result not requested 00592 * 00593 * \return ERR_WRONG_STATE : RFAL not initialized 00594 * \return ERR_NONE : No error 00595 * 00596 ***************************************************************************** 00597 */ 00598 ReturnCode rfalAdjustRegulators( uint16_t* result, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 ); 00599 00600 00601 /*! 00602 ***************************************************************************** 00603 * \brief RFAL Set System Callback 00604 * 00605 * Sets a callback for the driver to call when an event has occurred that 00606 * may require the system to be notified 00607 * 00608 * \param[in] pFunc : method pointer for the upper layer callback 00609 * 00610 ***************************************************************************** 00611 */ 00612 void rfalSetUpperLayerCallback( rfalUpperLayerCallback pFunc ); 00613 00614 00615 /*! 00616 ***************************************************************************** 00617 * \brief RFAL Set Pre Tx Callback 00618 * 00619 * Sets a callback for the driver to call before a Transceive 00620 * 00621 * \param[in] pFunc : method pointer for the Pre Tx callback 00622 * 00623 ***************************************************************************** 00624 */ 00625 void rfalSetPreTxRxCallback( rfalPreTxRxCallback pFunc ); 00626 00627 /*! 00628 ***************************************************************************** 00629 * \brief RFAL Set Post Tx Callback 00630 * 00631 * Sets a callback for the driver to call after a Transceive 00632 * 00633 * \param[in] pFunc : method pointer for the Post Tx callback 00634 * 00635 ***************************************************************************** 00636 */ 00637 void rfalSetPostTxRxCallback( rfalPostTxRxCallback pFunc ); 00638 00639 /*! 00640 ***************************************************************************** 00641 * \brief RFAL Deinitialize 00642 * 00643 * Deinitializes RFAL layer and the ST25R391x 00644 * 00645 * \return ERR_NONE : No error 00646 * 00647 ***************************************************************************** 00648 */ 00649 ReturnCode rfalDeinitialize( 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 ); 00650 00651 00652 /*! 00653 ***************************************************************************** 00654 * \brief RFAL Set Mode 00655 * 00656 * Sets the mode that RFAL will operate on the following communications. 00657 * Proper initializations will be performed on the ST25R391x 00658 * 00659 * \warning bit rate value RFAL_BR_KEEP is not allowed, only in rfalSetBitRate() 00660 * 00661 * \warning the mode will be applied immediately on the RFchip regardless of 00662 * any ongoing operations like Transceive, ListenMode 00663 * 00664 * \param[in] mode : mode for the RFAL/RFchip to perform 00665 * \param[in] txBR : transmit bit rate 00666 * \param[in] rxBR : receive bit rate 00667 * 00668 * \see rfalIsGTDone 00669 * \see rfalMode 00670 * 00671 * \return ERR_WRONG_STATE : RFAL not initialized 00672 * \return ERR_PARAM : Invalid parameter 00673 * \return ERR_NONE : No error 00674 * 00675 ***************************************************************************** 00676 */ 00677 ReturnCode rfalSetMode( rfalMode mode, rfalBitRate txBR, rfalBitRate rxBR,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 ); 00678 00679 00680 /*! 00681 ***************************************************************************** 00682 * \brief RFAL Get Mode 00683 * 00684 * Gets the mode that RFAL is set to operate 00685 * 00686 * \see rfalMode 00687 * 00688 * \return rfalMode : The current RFAL mode 00689 ***************************************************************************** 00690 */ 00691 rfalMode rfalGetMode( void ); 00692 00693 00694 /*! 00695 ***************************************************************************** 00696 * \brief RFAL Set Bit Rate 00697 * 00698 * Sets the Tx and Rx bit rates with the given values 00699 * The bit rate change is applied on the RF chip remaining in the same 00700 * mode previous defined with rfalSetMode() 00701 * 00702 * If no mode is defined bit rates will not be applied and an error 00703 * is returned 00704 * 00705 * \param[in] txBR : transmit bit rate 00706 * \param[in] rxBR : receive bit rate 00707 * 00708 * \see rfalSetMode 00709 * \see rfalMode 00710 * \see rfalBitRate 00711 * 00712 * \return ERR_WRONG_STATE : RFAL not initialized 00713 * \return ERR_PARAM : Invalid parameter 00714 * \return ERR_NOT_IMPLEMENTED : Mode not implemented 00715 * \return ERR_NONE : No error 00716 * 00717 ***************************************************************************** 00718 */ 00719 ReturnCode rfalSetBitRate( rfalBitRate txBR, rfalBitRate rxBR, 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 ); 00720 00721 00722 /*! 00723 ***************************************************************************** 00724 * \brief RFAL Get Bit Rate 00725 * 00726 * Gets the Tx and Rx current bit rates 00727 * 00728 * If RFAL is not initialized or mode not set the bit rates return will 00729 * be invalid RFAL_BR_KEEP 00730 * 00731 * \param[out] txBR : RFAL's current Tx Bit Rate 00732 * \param[out] rxBR : RFAL's current Rx Bit Rate 00733 * 00734 * \see rfalSetBitRate 00735 * \see rfalBitRate 00736 * 00737 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set 00738 * \return ERR_NONE : No error 00739 ***************************************************************************** 00740 */ 00741 ReturnCode rfalGetBitRate( rfalBitRate *txBR, rfalBitRate *rxBR ); 00742 00743 00744 /*! 00745 ***************************************************************************** 00746 * \brief RFAL Set Modulated RFO 00747 * 00748 * Sets the RFO value to be used in the modulated state 00749 * 00750 * \param[in] rfo : the RFO value to be used 00751 * 00752 * \return ERR_IO : Internal error 00753 * \return ERR_NONE : No error 00754 ***************************************************************************** 00755 */ 00756 ReturnCode rfalSetModulatedRFO( uint8_t rfo, 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 ); 00757 00758 00759 /*! 00760 ***************************************************************************** 00761 * \brief RFAL Get Modulated RFO 00762 * 00763 * Gets the RFO value used in the modulated state 00764 * 00765 * \return ERR_IO : Internal error 00766 * \return ERR_NONE : No error 00767 ***************************************************************************** 00768 */ 00769 uint8_t rfalGetModulatedRFO( 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 ); 00770 00771 00772 /*! 00773 ***************************************************************************** 00774 * \brief RFAL Measure RF Amplitude 00775 * 00776 * Measures the RF Amplitude 00777 * 00778 * \param[out] result : result of RF measurement 00779 * 00780 * \return ERR_IO : Internal error 00781 * \return ERR_NONE : No error 00782 ***************************************************************************** 00783 */ 00784 ReturnCode rfalMeasureRF( uint8_t* result, 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 ); 00785 00786 00787 /*! 00788 ***************************************************************************** 00789 * \brief Set Error Handling Mode 00790 * 00791 * Sets the error handling mode to be used by the RFAL 00792 * 00793 * \param[in] eHandling : the error handling mode 00794 * 00795 ***************************************************************************** 00796 */ 00797 void rfalSetErrorHandling( rfalEHandling eHandling ); 00798 00799 00800 /*! 00801 ***************************************************************************** 00802 * \brief Get Error Handling Mode 00803 * 00804 * Gets the error handling mode currently used by the RFAL 00805 * 00806 * \return rfalEHandling : Current error handling mode 00807 ***************************************************************************** 00808 */ 00809 rfalEHandling rfalGetErrorHandling( void ); 00810 00811 00812 /*! 00813 ***************************************************************************** 00814 * \brief Set Observation Mode 00815 * 00816 * Sets ST25R391x observation modes for RF debug purposes 00817 * 00818 * \param[in] txMode : the observation mode to be used during transmission 00819 * \param[in] rxMode : the observation mode to be used during reception 00820 * 00821 * \warning The Observation Mode is an advanced feature and should be set 00822 * according to the documentation of the part number in use. 00823 * Please refer to the corresponding Datasheet or Application Note(s) 00824 ***************************************************************************** 00825 */ 00826 void rfalSetObsvMode( uint8_t txMode, uint8_t rxMode ); 00827 00828 00829 /*! 00830 ***************************************************************************** 00831 * \brief Get Observation Mode 00832 * 00833 * Gets ST25R391x the current configured observation modes 00834 * 00835 * \param[in] txMode : the current observation mode configured for transmission 00836 * \param[in] rxMode : the current observation mode configured for reception 00837 * 00838 ***************************************************************************** 00839 */ 00840 void rfalGetObsvMode( uint8_t* txMode, uint8_t* rxMode ); 00841 00842 00843 /*! 00844 ***************************************************************************** 00845 * \brief Disable Observation Mode 00846 * 00847 * Disables the ST25R391x observation mode 00848 ***************************************************************************** 00849 */ 00850 void rfalDisableObsvMode( void ); 00851 00852 00853 /*! 00854 ***************************************************************************** 00855 * \brief RFAL Set FDT Poll 00856 * 00857 * Sets the Frame Delay Time (FDT) to be used on the following 00858 * communications. 00859 * 00860 * FDT Poll is the minimum time following a Poll Frame during 00861 * which no subsequent Poll Frame can be sent (without a response from 00862 * the Listener in between) 00863 * FDTx,PP,MIN - Digital 1.1 6.10.2 & 7.9.2 & 8.7.2 00864 * 00865 * \param[in] fdt : Frame Delay Time in 1/fc cycles 00866 * 00867 ***************************************************************************** 00868 */ 00869 void rfalSetFDTPoll( uint32_t fdt ); 00870 00871 00872 /*! 00873 ***************************************************************************** 00874 * \brief RFAL Set FDT Poll 00875 * 00876 * Gets the current Frame Delay Time (FDT) 00877 * 00878 * FDT Poll is the minimum time following a Poll Frame during 00879 * which no subsequent Poll Frame can be sent (without a response from 00880 * the Listener in between) 00881 * FDTx,PP,MIN - Digital 1.1 6.10.2 & 7.9.2 & 8.7.2 00882 * 00883 * \return FDT : current FDT value in 1/fc cycles 00884 * 00885 ***************************************************************************** 00886 */ 00887 uint32_t rfalGetFDTPoll( void ); 00888 00889 00890 /*! 00891 ***************************************************************************** 00892 * \brief RFAL Set FDT Listen 00893 * 00894 * Sets the Frame Delay Time (FDT) Listen minimum to be used on the 00895 * following communications. 00896 * 00897 * FDT Listen is the minimum time between a Poll Frame and a Listen Frame 00898 * FDTx,LISTEN,MIN - Digital 1.1 6.10.1 & 7.9.1 & 8.7.1 00899 * 00900 * \param[in] fdt : Frame Delay Time in 1/fc cycles 00901 * 00902 ***************************************************************************** 00903 */ 00904 void rfalSetFDTListen( uint32_t fdt ); 00905 00906 00907 /*! 00908 ***************************************************************************** 00909 * \brief RFAL Set FDT Listen 00910 * 00911 * Gets the Frame Delay Time (FDT) Listen minimum 00912 * 00913 * FDT Listen is the minimum time between a Poll Frame and a Listen Frame 00914 * FDTx,LISTEN,MIN - Digital 1.1 6.10.1 & 7.9.1 & 8.7.1 00915 * 00916 * \return FDT : current FDT value in 1/fc cycles 00917 * 00918 ***************************************************************************** 00919 */ 00920 uint32_t rfalGetFDTListen( void ); 00921 00922 00923 /*! 00924 ***************************************************************************** 00925 * \brief RFAL Get GT 00926 * 00927 * Gets the current Guard Time (GT) 00928 * 00929 * GT is the minimum time when a device in Listen Mode is exposed to an 00930 * unmodulated carrier 00931 * 00932 * \return GT : Guard Time in 1/fc cycles 00933 * 00934 ***************************************************************************** 00935 */ 00936 uint32_t rfalGetGT( void ); 00937 00938 00939 /*! 00940 ***************************************************************************** 00941 * \brief RFAL Set GT 00942 * 00943 * Sets the Guard Time (GT) to be used on the following communications. 00944 * 00945 * GT is the minimum time when a device in Listen Mode is exposed to an 00946 * unmodulated carrier 00947 * 00948 * \param[in] gt : Guard Time in 1/fc cycles 00949 * RFAL_GT_NONE if no GT should be applied 00950 * 00951 ***************************************************************************** 00952 */ 00953 void rfalSetGT( uint32_t gt ); 00954 00955 00956 /*! 00957 ***************************************************************************** 00958 * \brief RFAL Is GT expired 00959 * 00960 * Checks whether the GT timer has expired 00961 * 00962 * \return true : GT has expired or not running 00963 * \return false : GT is still running 00964 * 00965 ***************************************************************************** 00966 */ 00967 bool rfalIsGTExpired( void ); 00968 00969 00970 /*! 00971 ***************************************************************************** 00972 * \brief RFAL Turn Field On and Start GT 00973 * 00974 * Turns the Field On, performing Initial Collision Avoidance 00975 * 00976 * After Field On, if GT was set before, it starts the GT timer to be 00977 * used on the following communications. 00978 * 00979 * \return ERR_RF_COLLISION : External field detected 00980 * \return ERR_NONE : Field turned On 00981 * 00982 ***************************************************************************** 00983 */ 00984 ReturnCode rfalFieldOnAndStartGT( 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 ); 00985 00986 00987 /*! 00988 ***************************************************************************** 00989 * \brief RFAL Turn Field Off 00990 * 00991 * Turns the Field Off 00992 * 00993 * \return ERR_NONE : Field turned Off 00994 ***************************************************************************** 00995 */ 00996 ReturnCode rfalFieldOff( 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 ); 00997 00998 00999 01000 /***************************************************************************** 01001 * Transceive * 01002 *****************************************************************************/ 01003 01004 /*! 01005 ***************************************************************************** 01006 * \brief RFAL Set transceive context 01007 * 01008 * Set the context that will be used for the following Transceive 01009 * Output and input buffers have to be passed and all other details prior to 01010 * the Transceive itself has been started 01011 * 01012 * This method only sets the context, once set rfalWorker has 01013 * to be executed until is done 01014 * 01015 * \param[in] ctx : the context for the following Transceive 01016 * 01017 * \see rfalWorker 01018 * \see rfalGetTransceiveStatus 01019 * 01020 * \return ERR_NONE : Done with no error 01021 * \return ERR_WRONG_STATE : Not initialized properly 01022 ***************************************************************************** 01023 */ 01024 ReturnCode rfalStartTransceive( rfalTransceiveContext *ctx,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 ); 01025 01026 01027 /*! 01028 ***************************************************************************** 01029 * \brief Get Transceive State 01030 * 01031 * Gets current Transceive internal State 01032 * 01033 * \return rfalTransceiveState : the current Transceive internal State 01034 ***************************************************************************** 01035 */ 01036 rfalTransceiveState rfalGetTransceiveState( void ); 01037 01038 /*! 01039 ***************************************************************************** 01040 * \brief Get Transceive Status 01041 * 01042 * Gets current Transceive status 01043 * 01044 * \return ERR_NONE : Transceive done with no error 01045 * \return ERR_BUSY : Transceive ongoing 01046 * \return ERR_XXXX : Error occurred 01047 * \return ERR_TIMEOUT : No response 01048 * \return ERR_FRAMING : Framing error detected 01049 * \return ERR_PAR : Parity error detected 01050 * \return ERR_CRC : CRC error detected 01051 * \return ERR_LINK_LOSS : Link Loss - External Field is Off 01052 * \return ERR_RF_COLLISION : Collision detected 01053 * \return ERR_IO : Internal error 01054 ***************************************************************************** 01055 */ 01056 ReturnCode rfalGetTransceiveStatus( void ); 01057 01058 01059 /*! 01060 ***************************************************************************** 01061 * \brief RFAL Worker 01062 * 01063 * This runs RFAL layer, which drives the actual Transceive procedure 01064 * It MUST be executed frequently in order to execute the RFAL internal 01065 * states and perform the requested operations 01066 * 01067 ***************************************************************************** 01068 */ 01069 void rfalWorker( 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 ); 01070 01071 01072 /***************************************************************************** 01073 * ISO1443A * 01074 *****************************************************************************/ 01075 01076 /*! 01077 ***************************************************************************** 01078 * \brief Transceives an ISO14443A ShortFrame 01079 * 01080 * Sends REQA to detect if there is any PICC in the field 01081 * 01082 * \param[in] txCmd: Command to be sent: 01083 * 0x52 WUPA / ALL_REQ 01084 * 0x26 REQA / SENS_REQ 01085 * 01086 * \param[in] txCmd : type of short frame to be sent REQA or WUPA 01087 * \param[out] rxBuf : buffer to place the response 01088 * \param[in] rxBufLen : length of rxBuf 01089 * \param[out] rxRcvdLen: received length 01090 * \param[in] fwt : Frame Waiting Time in 1/fc 01091 * 01092 * \warning If fwt is set to RFAL_FWT_NONE it will make endlessly for 01093 * a response, which on a blocking method may not be the 01094 * desired usage 01095 * 01096 * \return ERR_NONE if there is response 01097 * \return ERR_TIMEOUT if there is no response 01098 * \return ERR_COLLISION collision has occurred 01099 * 01100 ***************************************************************************** 01101 */ 01102 ReturnCode rfalISO14443ATransceiveShortFrame( rfal14443AShortFrameCmd txCmd, uint8_t* rxBuf, uint8_t rxBufLen, uint16_t* rxRcvdLen, uint32_t fwt, 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 ); 01103 01104 01105 /*! 01106 ***************************************************************************** 01107 * \brief Sends an ISO14443A Anticollision Frame 01108 * 01109 * This is use to perform ISO14443A anti-collision. 01110 * \note Anticollision is sent without CRC 01111 * 01112 * 01113 * \param[in] buf : reference to ANTICOLLISION command (with known UID if any) to be sent (also out param) 01114 * reception will be place on this buf after bytesToSend 01115 * \param[in] bytesToSend: reference number of full bytes to be sent (including CMD byte and SEL_PAR) 01116 * if a collision occurs will contain the number of clear bytes 01117 * \param[in] bitsToSend : reference to number of bits (0-7) to be sent; and received (also out param) 01118 * if a collision occurs will indicate the number of clear bits (also out param) 01119 * \param[out] rxLength : reference to the return the received length 01120 * \param[in] fwt : Frame Waiting Time in 1/fc 01121 * 01122 * \return ERR_NONE if there is no error 01123 ***************************************************************************** 01124 */ 01125 ReturnCode rfalISO14443ATransceiveAnticollisionFrame( uint8_t *buf, uint8_t *bytesToSend, uint8_t *bitsToSend, uint16_t *rxLength, uint32_t fwt, 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 ); 01126 01127 01128 /***************************************************************************** 01129 * FeliCa * 01130 *****************************************************************************/ 01131 01132 /*! 01133 ***************************************************************************** 01134 * \brief FeliCa Poll 01135 * 01136 * Sends a Poll Request and collects all Poll Responses according to the 01137 * given slots 01138 * 01139 * 01140 * \param[in] slots : number of slots for the Poll Request 01141 * \param[in] sysCode : system code (SC) for the Poll Request 01142 * \param[in] reqCode : request code (RC) for the Poll Request 01143 * \param[out] pollResList : list of all responses 01144 * \param[in] pollResListSize : number of responses that can be placed in pollResList 01145 * \param[out] devicesDetected : number of cards found 01146 * \param[out] collisionsDetected: number of collisions detected 01147 * 01148 * \return ERR_NONE if there is no error 01149 * \return ERR_TIMEOUT if there is no response 01150 ***************************************************************************** 01151 */ 01152 ReturnCode rfalFeliCaPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint8_t reqCode, rfalFeliCaPollRes* pollResList, 01153 uint8_t pollResListSize, uint8_t *devicesDetected, 01154 uint8_t *collisionsDetected, 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 ); 01155 01156 01157 /***************************************************************************** 01158 * ISO15693 * 01159 *****************************************************************************/ 01160 01161 /*! 01162 ***************************************************************************** 01163 * \brief Sends an ISO15693 Anticollision Frame 01164 * 01165 * This send the Anticollision|Inventory frame (INVENTORY_REQ) 01166 * 01167 * \warning rxBuf must be able to contain the payload and CRC 01168 * 01169 * \param[in] txBuf : Buffer where outgoing message is located 01170 * \param[in] txBufLen : Length of the outgoing message in bytes 01171 * \param[out] rxBuf : Buffer where incoming message will be placed 01172 * \param[in] rxBufLen : Maximum length of the incoming message in bytes 01173 * \param[out] actLen : Actual received length in bits 01174 * 01175 * \return ERR_NONE : Transceive done with no error 01176 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set 01177 * \return ERR_IO : Internal error 01178 ***************************************************************************** 01179 */ 01180 ReturnCode rfalISO15693TransceiveAnticollisionFrame( uint8_t *txBuf, uint8_t txBufLen, uint8_t *rxBuf, uint8_t rxBufLen, uint16_t *actLen, 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 ); 01181 01182 01183 /*! 01184 ***************************************************************************** 01185 * \brief Sends an ISO15693 Anticollision EOF 01186 * 01187 * This sends the Anticollision|Inventory EOF used as a slot marker 01188 * 01189 * \warning rxBuf must be able to contain the payload and CRC 01190 * 01191 * \param[out] rxBuf : Buffer where incoming message will be placed 01192 * \param[in] rxBufLen : Maximum length of the incoming message in bytes 01193 * \param[out] actLen : Actual received length in bits 01194 * 01195 * \return ERR_NONE : Transceive done with no error 01196 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set 01197 * \return ERR_IO : Internal error 01198 ***************************************************************************** 01199 */ 01200 ReturnCode rfalISO15693TransceiveAnticollisionEOF( uint8_t *rxBuf, uint8_t rxBufLen, uint16_t *actLen, SPI* mspiChannel, 01201 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 ); 01202 01203 01204 /*! 01205 ***************************************************************************** 01206 * \brief Sends an ISO15693 Slot Marker 01207 * 01208 * This is method sends an ISO15693 (EoF) used for a Write operation 01209 * 01210 * \warning rxBuf must be able to contain the payload and CRC 01211 * 01212 * \param[out] rxBuf : Buffer where incoming message will be placed 01213 * \param[in] rxBufLen : Maximum length of the incoming message in bytes 01214 * \param[out] actLen : Actual received length in bytes 01215 * 01216 * \return ERR_NONE : Transceive done with no error 01217 * \return ERR_IO : Internal error 01218 ***************************************************************************** 01219 */ 01220 ReturnCode rfalISO15693TransceiveEOF( uint8_t *rxBuf, uint8_t rxBufLen, uint16_t *actLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ ); 01221 01222 01223 /*! 01224 ***************************************************************************** 01225 * \brief Transceive Blocking Tx 01226 * 01227 * This is method triggers a Transceive and executes it blocking until the 01228 * Tx has been completed 01229 * 01230 * \param[in] txBuf : Buffer where outgoing message is located 01231 * \param[in] txBufLen : Length of the outgoing message in bytes 01232 * \param[out] rxBuf : Buffer where incoming message will be placed 01233 * \param[in] rxBufLen : Maximum length of the incoming message in bytes 01234 * \param[out] actLen : Actual received length in bits 01235 * \param[in] flags : TransceiveFlags indication special handling 01236 * \param[in] fwt : Frame Waiting Time in 1/fc 01237 * 01238 * \return ERR_NONE : Transceive done with no error 01239 * \return ERR_BUSY : Transceive ongoing 01240 * \return ERR_XXXX : Error occurred 01241 * \return ERR_LINK_LOSS : Link Loss - External Field is Off 01242 * \return ERR_RF_COLLISION : Collision detected 01243 * \return ERR_IO : Internal error 01244 ***************************************************************************** 01245 */ 01246 ReturnCode rfalTransceiveBlockingTx( uint8_t* txBuf, uint16_t txBufLen, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* actLen, uint32_t flags, uint32_t fwt, 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 ); 01247 01248 /*! 01249 ***************************************************************************** 01250 * \brief Transceive Blocking Rx 01251 * 01252 * This is method executes the reception of an ongoing Transceive triggered 01253 * before by rfalTransceiveBlockingTx() 01254 * 01255 * \return ERR_NONE : Transceive done with no error 01256 * \return ERR_BUSY : Transceive ongoing 01257 * \return ERR_XXXX : Error occurred 01258 * \return ERR_TIMEOUT : No response 01259 * \return ERR_FRAMING : Framing error detected 01260 * \return ERR_PAR : Parity error detected 01261 * \return ERR_CRC : CRC error detected 01262 * \return ERR_LINK_LOSS : Link Loss - External Field is Off 01263 * \return ERR_RF_COLLISION : Collision detected 01264 * \return ERR_IO : Internal error 01265 ***************************************************************************** 01266 */ 01267 ReturnCode rfalTransceiveBlockingRx( 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 ); 01268 01269 /*! 01270 ***************************************************************************** 01271 * \brief Transceive Blocking 01272 * 01273 * This is method triggers a Transceive and executes it blocking until it 01274 * has been completed 01275 * 01276 * \param[in] txBuf : Buffer where outgoing message is located 01277 * \param[in] txBufLen : Length of the outgoing message in bytes 01278 * \param[out] rxBuf : Buffer where incoming message will be placed 01279 * \param[in] rxBufLen : Maximum length of the incoming message in bytes 01280 * \param[out] actLen : Actual received length in bytes 01281 * \param[in] flags : TransceiveFlags indication special handling 01282 * \param[in] fwt : Frame Waiting Time in 1/fc 01283 * 01284 * \return ERR_NONE : Transceive done with no error 01285 * \return ERR_BUSY : Transceive ongoing 01286 * \return ERR_XXXX : Error occurred 01287 * \return ERR_TIMEOUT : No response 01288 * \return ERR_FRAMING : Framing error detected 01289 * \return ERR_PAR : Parity error detected 01290 * \return ERR_CRC : CRC error detected 01291 * \return ERR_LINK_LOSS : Link Loss - External Field is Off 01292 * \return ERR_RF_COLLISION : Collision detected 01293 * \return ERR_IO : Internal error 01294 ***************************************************************************** 01295 */ 01296 ReturnCode rfalTransceiveBlockingTxRx( uint8_t* txBuf, uint16_t txBufLen, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* actLen, uint32_t flags, uint32_t fwt, 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 ); 01297 01298 01299 01300 /***************************************************************************** 01301 * Listen Mode * 01302 *****************************************************************************/ 01303 01304 /*! 01305 ***************************************************************************** 01306 * \brief Is external Field On 01307 * 01308 * Checks if external field (other peer/device) is on/detected 01309 * 01310 * 01311 * 01312 * \return true External field is On 01313 * \return false No external field is detected 01314 * 01315 ***************************************************************************** 01316 */ 01317 bool rfalIsExtFieldOn( 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 ); 01318 01319 01320 /*! 01321 ***************************************************************************** 01322 * \brief Listen Mode start 01323 * 01324 * Configures RF Chip to go into listen mode enabling the given technologies 01325 * 01326 * 01327 * \param[in] lmMask: mask with the enabled/disabled listen modes 01328 * use: RFAL_LM_MASK_NFCA ; RFAL_LM_MASK_NFCB ; 01329 * RFAL_LM_MASK_NFCF ; RFAL_LM_MASK_ACTIVE_P2P 01330 * \param[in] confA: pointer to Passive A configurations (NULL if disabled) 01331 * \param[in] confB: pointer to Passive B configurations (NULL if disabled) 01332 * \param[in] confF: pointer to Passive F configurations (NULL if disabled) 01333 * \param[in] rxBuf: buffer to place incoming data 01334 * \param[in] rxBufLen: length in bits of rxBuf 01335 * \param[in] rxLen: pointer to write the data length in bits placed into rxBuf 01336 * 01337 * 01338 * \return ERR_PARAM Invalid parameter 01339 * \return ERR_REQUEST Invalid listen mode mask 01340 * \return ERR_NONE Done with no error 01341 * 01342 ***************************************************************************** 01343 */ 01344 ReturnCode rfalListenStart( uint32_t lmMask, rfalLmConfPA *confA, rfalLmConfPB *confB, rfalLmConfPF *confF, uint8_t *rxBuf, 01345 uint16_t rxBufLen, uint16_t *rxLen, 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 ); 01346 01347 01348 /*! 01349 ***************************************************************************** 01350 * \brief Listen Mode start Sleeping 01351 * 01352 * 01353 ***************************************************************************** 01354 */ 01355 ReturnCode rfalListenSleepStart( rfalLmState sleepSt, uint8_t *rxBuf, uint16_t rxBufLen, uint16_t *rxLen ); 01356 01357 01358 /*! 01359 ***************************************************************************** 01360 * \brief Listen Mode Stop 01361 * 01362 * Disables the listen mode on the RF Chip 01363 * 01364 * \warning the listen mode will be disabled immediately on the RFchip regardless 01365 * of any ongoing operations like Transceive 01366 * 01367 * \return ERR_NONE Done with no error 01368 * 01369 ***************************************************************************** 01370 */ 01371 ReturnCode rfalListenStop( 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 ); 01372 01373 01374 /*! 01375 ***************************************************************************** 01376 * \brief Listen Mode get state 01377 * 01378 * Sets the new state of the Listen Mode and applies the necessary changes 01379 * on the RF Chip 01380 * 01381 * \param[out] dataFlag: indicates that Listen Mode has rcvd data and caller 01382 * must process it. The received message is located 01383 * at the rxBuf passed on rfalListenStart() 01384 * rfalListenSetState() will clear this flag 01385 * if NULL output parameter will no be written/returned 01386 * \param[out] lastBR: bit rate detected of the last initiator request 01387 * if NULL output parameter will no be written/returned 01388 * 01389 * \return rfalLmState RFAL_LM_STATE_NOT_INIT : LM not initialized properly 01390 * Any Other : LM State 01391 * 01392 ***************************************************************************** 01393 */ 01394 rfalLmState rfalListenGetState( bool *dataFlag, rfalBitRate *lastBR ); 01395 01396 01397 /*! 01398 ***************************************************************************** 01399 * \brief Listen Mode set state 01400 * 01401 * Sets the new state of the Listen Mode and applies the necessary changes 01402 * on the RF Chip 01403 * 01404 * \param[in] newSt : New state to go to 01405 * 01406 * \return ERR_WRONG_STATE : Not initialized properly 01407 * \return ERR_PARAM : Invalid parameter 01408 * \return ERR_NONE : Done with no error 01409 * 01410 ***************************************************************************** 01411 */ 01412 ReturnCode rfalListenSetState( rfalLmState newSt, 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 ); 01413 01414 01415 /***************************************************************************** 01416 * Wake-Up Mode * 01417 *****************************************************************************/ 01418 01419 /*! 01420 ***************************************************************************** 01421 * \brief Wake-Up Mode Start 01422 * 01423 * Sets the RF Chip in Low Power Wake-Up Mode according to the given 01424 * configuration. 01425 * 01426 * \param[in] config : Generic Wake-Up configuration provided by lower 01427 * layers. If NULL will automatically configure the 01428 * Wake-Up mode 01429 * 01430 * \return ERR_WRONG_STATE : Not initialized properly 01431 * \return ERR_PARAM : Invalid parameter 01432 * \return ERR_NONE : Done with no error 01433 * 01434 ***************************************************************************** 01435 */ 01436 ReturnCode rfalWakeUpModeStart( void *config, ST25R3911* mST25, SPI* mspiChannel, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 ); 01437 01438 01439 /*! 01440 ***************************************************************************** 01441 * \brief Wake-Up Has Woke 01442 * 01443 * Returns true if the Wake-Up mode is enabled and it has already received 01444 * the indication from the RF Chip that the surrounding environment has changed 01445 * and flagged at least one wake-Up interrupt 01446 * 01447 * \return true : Wake-Up mode enabled and has received a wake-up IRQ 01448 * \return false : no Wake-Up IRQ has been received 01449 * 01450 ***************************************************************************** 01451 */ 01452 bool rfalWakeUpModeHasWoke( ST25R3911* mST25, SPI* mspiChannel, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 ); 01453 01454 01455 /*! 01456 ***************************************************************************** 01457 * \brief Wake-Up Mode Stop 01458 * 01459 * Stops the Wake-Up Mode 01460 * 01461 * \return ERR_WRONG_STATE : Not initialized properly 01462 * \return ERR_PARAM : Invalid parameter 01463 * \return ERR_NONE : Done with no error 01464 * 01465 ***************************************************************************** 01466 */ 01467 ReturnCode rfalWakeUpModeStop( 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 ); 01468 01469 01470 void rfalSetWumState( void ); 01471 01472 01473 #endif /* RFAL_RF_H */ 01474 01475 01476 /** 01477 * @} 01478 * 01479 * @} 01480 * 01481 * @} 01482 */
Generated on Sat Jul 16 2022 13:00:53 by
1.7.2