RFAL library for the STMicroelectronics X-NUCLEO-NFC05A1

Dependents:   mbed-os-nfc05a1

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:75fc82583a41 1
DiegoOstuni 0:75fc82583a41 2 /******************************************************************************
DiegoOstuni 0:75fc82583a41 3 * @attention
DiegoOstuni 0:75fc82583a41 4 *
DiegoOstuni 0:75fc82583a41 5 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
DiegoOstuni 0:75fc82583a41 6 *
DiegoOstuni 0:75fc82583a41 7 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
DiegoOstuni 0:75fc82583a41 8 * You may not use this file except in compliance with the License.
DiegoOstuni 0:75fc82583a41 9 * You may obtain a copy of the License at:
DiegoOstuni 0:75fc82583a41 10 *
DiegoOstuni 0:75fc82583a41 11 * http://www.st.com/myliberty
DiegoOstuni 0:75fc82583a41 12 *
DiegoOstuni 0:75fc82583a41 13 * Unless required by applicable law or agreed to in writing, software
DiegoOstuni 0:75fc82583a41 14 * distributed under the License is distributed on an "AS IS" BASIS,
DiegoOstuni 0:75fc82583a41 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
DiegoOstuni 0:75fc82583a41 16 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
DiegoOstuni 0:75fc82583a41 17 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
DiegoOstuni 0:75fc82583a41 18 * See the License for the specific language governing permissions and
DiegoOstuni 0:75fc82583a41 19 * limitations under the License.
DiegoOstuni 0:75fc82583a41 20 *
DiegoOstuni 0:75fc82583a41 21 ******************************************************************************/
DiegoOstuni 0:75fc82583a41 22
DiegoOstuni 0:75fc82583a41 23
DiegoOstuni 0:75fc82583a41 24 /*
DiegoOstuni 0:75fc82583a41 25 * PROJECT: ST25R391x firmware
DiegoOstuni 0:75fc82583a41 26 * $Revision: $
DiegoOstuni 0:75fc82583a41 27 * LANGUAGE: ISO C99
DiegoOstuni 0:75fc82583a41 28 */
DiegoOstuni 0:75fc82583a41 29
DiegoOstuni 0:75fc82583a41 30 /*! \file rfal_rf.h
DiegoOstuni 0:75fc82583a41 31 *
DiegoOstuni 0:75fc82583a41 32 * \author Gustavo Patricio
DiegoOstuni 0:75fc82583a41 33 *
DiegoOstuni 0:75fc82583a41 34 * \brief RF Abstraction Layer (RFAL)
DiegoOstuni 0:75fc82583a41 35 *
DiegoOstuni 0:75fc82583a41 36 * RFAL (RF Abstraction Layer) provides several functionalities required to
DiegoOstuni 0:75fc82583a41 37 * perform RF/NFC communications. <br>The RFAL encapsulates the different
DiegoOstuni 0:75fc82583a41 38 * RF ICs (ST25R3911, ST25R391x, etc) into a common and easy to use interface.
DiegoOstuni 0:75fc82583a41 39 *
DiegoOstuni 0:75fc82583a41 40 * It provides interfaces to configure the RF IC, set/get timings, modes, bit rates,
DiegoOstuni 0:75fc82583a41 41 * specific handlings, execute listen mode, etc.
DiegoOstuni 0:75fc82583a41 42 *
DiegoOstuni 0:75fc82583a41 43 * Furthermore it provides a common interface to perform a Transceive operations.
DiegoOstuni 0:75fc82583a41 44 * The Transceive can be executed in a blocking or non blocking way.<br>
DiegoOstuni 0:75fc82583a41 45 * Additionally few specific Transceive methods are available to cope with the
DiegoOstuni 0:75fc82583a41 46 * specifics of these particular operations.
DiegoOstuni 0:75fc82583a41 47 *
DiegoOstuni 0:75fc82583a41 48 * The most common interfaces are:
DiegoOstuni 0:75fc82583a41 49 * <br>&nbsp; rfalInitialize()
DiegoOstuni 0:75fc82583a41 50 * <br>&nbsp; rfalSetFDTPoll()
DiegoOstuni 0:75fc82583a41 51 * <br>&nbsp; rfalSetFDTListen()
DiegoOstuni 0:75fc82583a41 52 * <br>&nbsp; rfalSetGT()
DiegoOstuni 0:75fc82583a41 53 * <br>&nbsp; rfalSetBitRate()
DiegoOstuni 0:75fc82583a41 54 * <br>&nbsp; rfalSetMode()
DiegoOstuni 0:75fc82583a41 55 * <br>&nbsp; rfalFieldOnAndStartGT()
DiegoOstuni 0:75fc82583a41 56 * <br>&nbsp; rfalFieldOff()
DiegoOstuni 0:75fc82583a41 57 * <br>&nbsp; rfalStartTransceive()
DiegoOstuni 0:75fc82583a41 58 * <br>&nbsp; rfalGetTransceiveStatus()
DiegoOstuni 0:75fc82583a41 59 * <br>&nbsp; rfalTransceiveBlockingTxRx()
DiegoOstuni 0:75fc82583a41 60 *
DiegoOstuni 0:75fc82583a41 61 *
DiegoOstuni 0:75fc82583a41 62 * @addtogroup RFAL
DiegoOstuni 0:75fc82583a41 63 * @{
DiegoOstuni 0:75fc82583a41 64 *
DiegoOstuni 0:75fc82583a41 65 * @addtogroup RFAL-HAL
DiegoOstuni 0:75fc82583a41 66 * @brief RFAL Hardware Abstraction Layer
DiegoOstuni 0:75fc82583a41 67 * @{
DiegoOstuni 0:75fc82583a41 68 *
DiegoOstuni 0:75fc82583a41 69 * @addtogroup RF
DiegoOstuni 0:75fc82583a41 70 * @brief RFAL RF Abstraction Layer
DiegoOstuni 0:75fc82583a41 71 * @{
DiegoOstuni 0:75fc82583a41 72 *
DiegoOstuni 0:75fc82583a41 73 */
DiegoOstuni 0:75fc82583a41 74
DiegoOstuni 0:75fc82583a41 75 #ifndef RFAL_RF_H
DiegoOstuni 0:75fc82583a41 76 #define RFAL_RF_H
DiegoOstuni 0:75fc82583a41 77
DiegoOstuni 0:75fc82583a41 78 /*
DiegoOstuni 0:75fc82583a41 79 ******************************************************************************
DiegoOstuni 0:75fc82583a41 80 * INCLUDES
DiegoOstuni 0:75fc82583a41 81 ******************************************************************************
DiegoOstuni 0:75fc82583a41 82 */
DiegoOstuni 0:75fc82583a41 83 #include "platform1.h"
DiegoOstuni 0:75fc82583a41 84 #include "st_errno.h"
DiegoOstuni 0:75fc82583a41 85 #include "rfal_features.h"
DiegoOstuni 0:75fc82583a41 86 #include "st25r3911_com.h"
DiegoOstuni 0:75fc82583a41 87 #include <stdint.h>
DiegoOstuni 0:75fc82583a41 88
DiegoOstuni 0:75fc82583a41 89 /*
DiegoOstuni 0:75fc82583a41 90 ******************************************************************************
DiegoOstuni 0:75fc82583a41 91 * GLOBAL DEFINES
DiegoOstuni 0:75fc82583a41 92 ******************************************************************************
DiegoOstuni 0:75fc82583a41 93 */
DiegoOstuni 0:75fc82583a41 94 #define RFAL_VERSION (uint32_t)0x010302 /*!< RFAL Current Version: v1.3.2 */
DiegoOstuni 0:75fc82583a41 95
DiegoOstuni 0:75fc82583a41 96 #define RFAL_FWT_NONE 0xFFFFFFFF /*!< Disabled FWT: Wait forever for a response */
DiegoOstuni 0:75fc82583a41 97 #define RFAL_GT_NONE RFAL_TIMING_NONE /*!< Disabled GT: No GT will be applied after Field On */
DiegoOstuni 0:75fc82583a41 98
DiegoOstuni 0:75fc82583a41 99 #define RFAL_TIMING_NONE 0x00 /*!< Timing disabled | Don't apply */
DiegoOstuni 0:75fc82583a41 100
DiegoOstuni 0:75fc82583a41 101 #define RFAL_1FC_IN_4096FC (uint32_t)4096 /*!< Number of 1/fc cycles in one 4096/fc */
DiegoOstuni 0:75fc82583a41 102 #define RFAL_1FC_IN_512FC (uint32_t)512 /*!< Number of 1/fc cycles in one 512/fc */
DiegoOstuni 0:75fc82583a41 103 #define RFAL_1FC_IN_64FC (uint32_t)64 /*!< Number of 1/fc cycles in one 64/fc */
DiegoOstuni 0:75fc82583a41 104 #define RFAL_1FC_IN_8FC (uint32_t)8 /*!< Number of 1/fc cycles in one 8/fc */
DiegoOstuni 0:75fc82583a41 105 #define RFAL_US_IN_MS (uint32_t)1000 /*!< Number of us in one ms */
DiegoOstuni 0:75fc82583a41 106 #define RFAL_1MS_IN_1FC (uint32_t)13560 /*!< Number of 1/fc cycles in 1ms */
DiegoOstuni 0:75fc82583a41 107 #define RFAL_BITS_IN_BYTE (uint16_t)8 /*!< Number of bits in one byte */
DiegoOstuni 0:75fc82583a41 108
DiegoOstuni 0:75fc82583a41 109 #define RFAL_CRC_LEN 2 /*!< RF CRC LEN */
DiegoOstuni 0:75fc82583a41 110
DiegoOstuni 0:75fc82583a41 111 /*! Default TxRx flags: Tx CRC automatic, Rx CRC removed, NFCIP1 mode off, AGC On, Tx Parity automatic, Rx Parity removed */
DiegoOstuni 0:75fc82583a41 112 #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)
DiegoOstuni 0:75fc82583a41 113
DiegoOstuni 0:75fc82583a41 114
DiegoOstuni 0:75fc82583a41 115 #define RFAL_LM_MASK_NFCA (1<<RFAL_MODE_LISTEN_NFCA) /*!< Bitmask for Listen Mode enabling Listen NFCA */
DiegoOstuni 0:75fc82583a41 116 #define RFAL_LM_MASK_NFCB (1<<RFAL_MODE_LISTEN_NFCB) /*!< Bitmask for Listen Mode enabling Listen NFCB */
DiegoOstuni 0:75fc82583a41 117 #define RFAL_LM_MASK_NFCF (1<<RFAL_MODE_LISTEN_NFCF) /*!< Bitmask for Listen Mode enabling Listen NFCF */
DiegoOstuni 0:75fc82583a41 118 #define RFAL_LM_MASK_ACTIVE_P2P (1<<RFAL_MODE_LISTEN_ACTIVE_P2P) /*!< Bitmask for Listen Mode enabling Listen AP2P */
DiegoOstuni 0:75fc82583a41 119
DiegoOstuni 0:75fc82583a41 120 #define RFAL_LM_SENS_RES_LEN 2 /*!< NFC-A SENS_RES (ATQA) length */
DiegoOstuni 0:75fc82583a41 121 #define RFAL_LM_SENSB_RES_LEN 13 /*!< NFC-B SENSB_RES (ATQB) length */
DiegoOstuni 0:75fc82583a41 122 #define RFAL_LM_SENSF_RES_LEN 19 /*!< NFC-F SENSF_RES length */
DiegoOstuni 0:75fc82583a41 123 #define RFAL_LM_SENSF_SC_LEN 2 /*!< NFC-F System Code length */
DiegoOstuni 0:75fc82583a41 124
DiegoOstuni 0:75fc82583a41 125 #define RFAL_NFCID3_LEN 10 /*!< NFCID3 length */
DiegoOstuni 0:75fc82583a41 126 #define RFAL_NFCID2_LEN 7 /*!< NFCID2 length */
DiegoOstuni 0:75fc82583a41 127 #define RFAL_NFCID1_LEN 4 /*!< NFCID1 length */
DiegoOstuni 0:75fc82583a41 128
DiegoOstuni 0:75fc82583a41 129
DiegoOstuni 0:75fc82583a41 130 /*
DiegoOstuni 0:75fc82583a41 131 ******************************************************************************
DiegoOstuni 0:75fc82583a41 132 * GLOBAL MACROS
DiegoOstuni 0:75fc82583a41 133 ******************************************************************************
DiegoOstuni 0:75fc82583a41 134 */
DiegoOstuni 0:75fc82583a41 135
DiegoOstuni 0:75fc82583a41 136 /*! 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 */
DiegoOstuni 0:75fc82583a41 137 #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 ) ) ) ) ) ) )
DiegoOstuni 0:75fc82583a41 138
DiegoOstuni 0:75fc82583a41 139 /*! 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 */
DiegoOstuni 0:75fc82583a41 140 #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 ) ) ) )
DiegoOstuni 0:75fc82583a41 141
DiegoOstuni 0:75fc82583a41 142 /*! 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 */
DiegoOstuni 0:75fc82583a41 143 #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 ) ) ) )
DiegoOstuni 0:75fc82583a41 144
DiegoOstuni 0:75fc82583a41 145 /*! 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 */
DiegoOstuni 0:75fc82583a41 146 #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 ) ) ) )
DiegoOstuni 0:75fc82583a41 147
DiegoOstuni 0:75fc82583a41 148 /*! 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 */
DiegoOstuni 0:75fc82583a41 149 #define rfalGetMaxBrCEF() ( ((RFAL_SUPPORT_BR_CE_F_424) ? RFAL_BR_424 : RFAL_BR_212 ) )
DiegoOstuni 0:75fc82583a41 150
DiegoOstuni 0:75fc82583a41 151 #define rfalConv1fcTo8fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_8FC ) /*!< Converts the given t from 1/fc to 8/fc */
DiegoOstuni 0:75fc82583a41 152 #define rfalConv8fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_8FC ) /*!< Converts the given t from 8/fc to 1/fc */
DiegoOstuni 0:75fc82583a41 153
DiegoOstuni 0:75fc82583a41 154 #define rfalConv1fcTo64fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_64FC ) /*!< Converts the given t from 1/fc to 64/fc */
DiegoOstuni 0:75fc82583a41 155 #define rfalConv64fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_64FC ) /*!< Converts the given t from 64/fc to 1/fc */
DiegoOstuni 0:75fc82583a41 156
DiegoOstuni 0:75fc82583a41 157 #define rfalConv1fcTo512fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_512FC ) /*!< Converts the given t from 1/fc to 512/fc */
DiegoOstuni 0:75fc82583a41 158 #define rfalConv512fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_512FC ) /*!< Converts the given t from 512/fc to 1/fc */
DiegoOstuni 0:75fc82583a41 159
DiegoOstuni 0:75fc82583a41 160 #define rfalConv1fcTo4096fc( t ) (uint32_t)( (t) / RFAL_1FC_IN_4096FC ) /*!< Converts the given t from 1/fc to 4096/fc */
DiegoOstuni 0:75fc82583a41 161 #define rfalConv4096fcTo1fc( t ) (uint32_t)( (t) * RFAL_1FC_IN_4096FC ) /*!< Converts the given t from 4096/fc to 1/fc */
DiegoOstuni 0:75fc82583a41 162
DiegoOstuni 0:75fc82583a41 163 #define rfalConv1fcToMs( t ) (uint32_t)( (t) / RFAL_1MS_IN_1FC ) /*!< Converts the given t from 1/fc to ms */
DiegoOstuni 0:75fc82583a41 164 #define rfalConvMsTo1fc( t ) (uint32_t)( (t) * RFAL_1MS_IN_1FC ) /*!< Converts the given t from ms to 1/fc */
DiegoOstuni 0:75fc82583a41 165
DiegoOstuni 0:75fc82583a41 166 #define rfalConv1fcToUs( t ) (uint32_t)( (t * RFAL_US_IN_MS) / RFAL_1MS_IN_1FC) /*!< Converts the given t from 1/fc to us */
DiegoOstuni 0:75fc82583a41 167 #define rfalConvUsTo1fc( t ) (uint32_t)( (t * RFAL_1MS_IN_1FC) / RFAL_US_IN_MS) /*!< Converts the given t from us to 1/fc */
DiegoOstuni 0:75fc82583a41 168
DiegoOstuni 0:75fc82583a41 169 #define rfalConv64fcToMs( t ) (uint32_t)( (t) / (RFAL_1MS_IN_1FC / RFAL_1FC_IN_64FC) ) /*!< Converts the given t from 64/fc to ms */
DiegoOstuni 0:75fc82583a41 170 #define rfalConvMsTo64fc( t ) (uint32_t)( (t) * (RFAL_1MS_IN_1FC / RFAL_1FC_IN_64FC) ) /*!< Converts the given t from ms to 64/fc */
DiegoOstuni 0:75fc82583a41 171
DiegoOstuni 0:75fc82583a41 172 #define rfalConvBitsToBytes( n ) (uint32_t)( (n+(RFAL_BITS_IN_BYTE-1)) / (RFAL_BITS_IN_BYTE) ) /*!< Converts the given n from bits to bytes */
DiegoOstuni 0:75fc82583a41 173 #define rfalConvBytesToBits( n ) (uint32_t)( (n) * (RFAL_BITS_IN_BYTE) ) /*!< Converts the given n from bytes to bits */
DiegoOstuni 0:75fc82583a41 174
DiegoOstuni 0:75fc82583a41 175
DiegoOstuni 0:75fc82583a41 176
DiegoOstuni 0:75fc82583a41 177 #define rfalIsTransceiveInTx( ) ( !rfalIsTransceiveInRx() && (rfalGetTransceiveState() >= RFAL_TXRX_STATE_TX_IDLE) ) /*!< Checks if Transceive is in a Transmission state ( Transmit ongoing ) */
DiegoOstuni 0:75fc82583a41 178 #define rfalIsTransceiveInRx( ) ( rfalGetTransceiveState() >= RFAL_TXRX_STATE_RX_IDLE ) /*!< Checks if Transceive is in a Reception state ( Transmit done ) */
DiegoOstuni 0:75fc82583a41 179
DiegoOstuni 0:75fc82583a41 180
DiegoOstuni 0:75fc82583a41 181
DiegoOstuni 0:75fc82583a41 182
DiegoOstuni 0:75fc82583a41 183 /*! Computes a Transceive context \a ctx with default flags and the lengths
DiegoOstuni 0:75fc82583a41 184 * in bytes with the given arguments
DiegoOstuni 0:75fc82583a41 185 * \a ctx : Transceive context to be assigned
DiegoOstuni 0:75fc82583a41 186 * \a tB : txBuf the pointer to the buffer to be sent
DiegoOstuni 0:75fc82583a41 187 * \a tBL : txBuf length in bytes
DiegoOstuni 0:75fc82583a41 188 * \a rB : rxBuf the pointer to the buffer to place the received frame
DiegoOstuni 0:75fc82583a41 189 * \a rBL : rxBuf length in bytes
DiegoOstuni 0:75fc82583a41 190 * \a rBL : rxBuf length in bytes
DiegoOstuni 0:75fc82583a41 191 * \a t : FWT to be used on this transceive in 1/fc
DiegoOstuni 0:75fc82583a41 192 */
DiegoOstuni 0:75fc82583a41 193 #define rfalCreateByteTxRxContext( ctx, tB, tBL, rB, rBL, rdL, t ) \
DiegoOstuni 0:75fc82583a41 194 ctx.txBuf = (tB); \
DiegoOstuni 0:75fc82583a41 195 ctx.txBufLen = rfalConvBytesToBits(tBL); \
DiegoOstuni 0:75fc82583a41 196 ctx.rxBuf = (rB); \
DiegoOstuni 0:75fc82583a41 197 ctx.rxBufLen = rfalConvBytesToBits(rBL); \
DiegoOstuni 0:75fc82583a41 198 ctx.rxRcvdLen = rdL; \
DiegoOstuni 0:75fc82583a41 199 ctx.flags = RFAL_TXRX_FLAGS_DEFAULT; \
DiegoOstuni 0:75fc82583a41 200 ctx.fwt = (t);
DiegoOstuni 0:75fc82583a41 201
DiegoOstuni 0:75fc82583a41 202
DiegoOstuni 0:75fc82583a41 203 /*! Computes a Transceive context \a ctx using lengths in bytes
DiegoOstuni 0:75fc82583a41 204 * with the given flags and arguments
DiegoOstuni 0:75fc82583a41 205 * \a ctx : Transceive context to be assigned
DiegoOstuni 0:75fc82583a41 206 * \a tB : txBuf the pointer to the buffer to be sent
DiegoOstuni 0:75fc82583a41 207 * \a tBL : txBuf length in bytes
DiegoOstuni 0:75fc82583a41 208 * \a rB : rxBuf the pointer to the buffer to place the received frame
DiegoOstuni 0:75fc82583a41 209 * \a rBL : rxBuf length in bytes
DiegoOstuni 0:75fc82583a41 210 * \a rBL : rxBuf length in bytes
DiegoOstuni 0:75fc82583a41 211 * \a t : FWT to be used on this transceive in 1/fc
DiegoOstuni 0:75fc82583a41 212 */
DiegoOstuni 0:75fc82583a41 213 #define rfalCreateByteFlagsTxRxContext( ctx, tB, tBL, rB, rBL, rdL, fl, t ) \
DiegoOstuni 0:75fc82583a41 214 ctx.txBuf = (tB); \
DiegoOstuni 0:75fc82583a41 215 ctx.txBufLen = rfalConvBytesToBits(tBL); \
DiegoOstuni 0:75fc82583a41 216 ctx.rxBuf = (rB); \
DiegoOstuni 0:75fc82583a41 217 ctx.rxBufLen = rfalConvBytesToBits(rBL); \
DiegoOstuni 0:75fc82583a41 218 ctx.rxRcvdLen = rdL; \
DiegoOstuni 0:75fc82583a41 219 ctx.flags = (fl); \
DiegoOstuni 0:75fc82583a41 220 ctx.fwt = (t);
DiegoOstuni 0:75fc82583a41 221
DiegoOstuni 0:75fc82583a41 222
DiegoOstuni 0:75fc82583a41 223 #define rfalLogE(...) //(__VA_ARGS__) /*!< Macro for the error log method */
DiegoOstuni 0:75fc82583a41 224 #define rfalLogW(...) //(__VA_ARGS__) /*!< Macro for the warning log method */
DiegoOstuni 0:75fc82583a41 225 #define rfalLogI(...) //(__VA_ARGS__) /*!< Macro for the info log method */
DiegoOstuni 0:75fc82583a41 226 #define rfalLogD(...) //(__VA_ARGS__) /*!< Macro for the debug log method */
DiegoOstuni 0:75fc82583a41 227
DiegoOstuni 0:75fc82583a41 228
DiegoOstuni 0:75fc82583a41 229 /*
DiegoOstuni 0:75fc82583a41 230 ******************************************************************************
DiegoOstuni 0:75fc82583a41 231 * GLOBAL ENUMS
DiegoOstuni 0:75fc82583a41 232 ******************************************************************************
DiegoOstuni 0:75fc82583a41 233 */
DiegoOstuni 0:75fc82583a41 234
DiegoOstuni 0:75fc82583a41 235 /*! RFAL Guard Time (GT) default values */
DiegoOstuni 0:75fc82583a41 236 enum {
DiegoOstuni 0:75fc82583a41 237 RFAL_GT_NFCA = rfalConvMsTo1fc(5), /*!< GTA Digital 1.1 6.10.4.1 & A.2 */
DiegoOstuni 0:75fc82583a41 238 RFAL_GT_NFCB = rfalConvMsTo1fc(5), /*!< GTB Digital 1.1 7.9.4.1 & A.3 */
DiegoOstuni 0:75fc82583a41 239 RFAL_GT_NFCF = rfalConvMsTo1fc(20), /*!< GTF Digital 1.1 8.7.4.1 & A.4 */
DiegoOstuni 0:75fc82583a41 240 RFAL_GT_NFCV = rfalConvMsTo1fc(1), /*!< GTV NFC Forum NFCV Change Request 9.7.1.1 & A.2 */
DiegoOstuni 0:75fc82583a41 241 RFAL_GT_NFCV_ADJUSTED = rfalConvMsTo1fc(1+4), /*!< Adjusted GT for greater interoperability (ISO15693 Dynamic Tags) */
DiegoOstuni 0:75fc82583a41 242 RFAL_GT_PICOPASS = rfalConvMsTo1fc(1), /*!< GT Picopass */
DiegoOstuni 0:75fc82583a41 243 RFAL_GT_AP2P = rfalConvMsTo1fc(5), /*!< TIRFG Ecma 340 11.1.1 */
DiegoOstuni 0:75fc82583a41 244 RFAL_GT_AP2P_ADJUSTED = rfalConvMsTo1fc(5+25) /*!< Adjusted GT for greater interoperability (Sony XPERIA P, Nokia N9, Huawei P2) */
DiegoOstuni 0:75fc82583a41 245 };
DiegoOstuni 0:75fc82583a41 246
DiegoOstuni 0:75fc82583a41 247
DiegoOstuni 0:75fc82583a41 248 /*! RFAL Frame Delay Time (FDT) Listen default values */
DiegoOstuni 0:75fc82583a41 249 enum {
DiegoOstuni 0:75fc82583a41 250 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 */
DiegoOstuni 0:75fc82583a41 251 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 */
DiegoOstuni 0:75fc82583a41 252 RFAL_FDT_LISTEN_NFCF_POLLER = 2672, /*!< TR0F,LISTEN,MIN Digital 1.1 8.7.1.1 & A.4 */
DiegoOstuni 0:75fc82583a41 253 RFAL_FDT_LISTEN_NFCV_POLLER = 4192, /*!< t1 min 4192/fc (309,2us) ISO15693 3 Table 8 */
DiegoOstuni 0:75fc82583a41 254 RFAL_FDT_LISTEN_PICOPASS_POLLER = 3400, /*!< ISO15693 t1 min - observed adjustment */
DiegoOstuni 0:75fc82583a41 255 RFAL_FDT_LISTEN_AP2P_POLLER = 64, /*!< FDT AP2P No actual FDTListen is required as fields switch and collision avoidance */
DiegoOstuni 0:75fc82583a41 256 RFAL_FDT_LISTEN_NFCA_LISTENER = 1172, /*!< FDTA,LISTEN,MIN Digital 1.1 6.10 */
DiegoOstuni 0:75fc82583a41 257 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 */
DiegoOstuni 0:75fc82583a41 258 RFAL_FDT_LISTEN_NFCF_LISTENER = 2688, /*!< TR0F,LISTEN,MIN Digital 1.1 8.7.1.1 & A.4 */
DiegoOstuni 0:75fc82583a41 259 RFAL_FDT_LISTEN_AP2P_LISTENER = 64 /*!< FDT AP2P No actual FDTListen exists as fields switch and collision avoidance */
DiegoOstuni 0:75fc82583a41 260 };
DiegoOstuni 0:75fc82583a41 261
DiegoOstuni 0:75fc82583a41 262
DiegoOstuni 0:75fc82583a41 263 /*! RFAL Frame Delay Time (FDT) Poll default values */
DiegoOstuni 0:75fc82583a41 264 enum {
DiegoOstuni 0:75fc82583a41 265 RFAL_FDT_POLL_NFCA_POLLER = 6780, /*!< FDTA,POLL,MIN Digital 1.1 6.10.3.1 & A.2 */
DiegoOstuni 0:75fc82583a41 266 RFAL_FDT_POLL_NFCA_T1T_POLLER = 384, /*!< RRDDT1T,MIN,B1 Digital 1.1 10.7.1 & A.5 */
DiegoOstuni 0:75fc82583a41 267 RFAL_FDT_POLL_NFCB_POLLER = 6780, /*!< FDTB,POLL,MIN = TR2B,MIN,DEFAULT Digital 1.1 7.9.3 & A.3 */
DiegoOstuni 0:75fc82583a41 268 RFAL_FDT_POLL_NFCF_POLLER = 2672, /*!< FDTF,POLL,MIN Digital 1.1 8.7.3 & A.4 */
DiegoOstuni 0:75fc82583a41 269 RFAL_FDT_POLL_NFCV_POLLER = 4192, /*!< FDTV,POLL NFC Forum NFCV Change Request A.2*/
DiegoOstuni 0:75fc82583a41 270 RFAL_FDT_POLL_PICOPASS_POLLER = 1790, /*!< FDT Max */
DiegoOstuni 0:75fc82583a41 271 RFAL_FDT_POLL_AP2P_POLLER = 0 /*!< FDT AP2P No actual FDTPoll exists as fields switch and collision avoidance */
DiegoOstuni 0:75fc82583a41 272 };
DiegoOstuni 0:75fc82583a41 273
DiegoOstuni 0:75fc82583a41 274
DiegoOstuni 0:75fc82583a41 275 /*
DiegoOstuni 0:75fc82583a41 276 ******************************************************************************
DiegoOstuni 0:75fc82583a41 277 * GLOBAL TYPES
DiegoOstuni 0:75fc82583a41 278 ******************************************************************************
DiegoOstuni 0:75fc82583a41 279 */
DiegoOstuni 0:75fc82583a41 280
DiegoOstuni 0:75fc82583a41 281 /*! RFAL modes */
DiegoOstuni 0:75fc82583a41 282 typedef enum {
DiegoOstuni 0:75fc82583a41 283 RFAL_MODE_NONE = 0, /*!< No mode selected/defined */
DiegoOstuni 0:75fc82583a41 284 RFAL_MODE_POLL_NFCA = 1, /*!< Mode to perform as NFCA (ISO14443A) Poller (PCD) */
DiegoOstuni 0:75fc82583a41 285 RFAL_MODE_POLL_NFCA_T1T = 2, /*!< Mode to perform as NFCA T1T (Topaz) Poller (PCD) */
DiegoOstuni 0:75fc82583a41 286 RFAL_MODE_POLL_NFCB = 3, /*!< Mode to perform as NFCB (ISO14443B) Poller (PCD) */
DiegoOstuni 0:75fc82583a41 287 RFAL_MODE_POLL_B_PRIME = 4, /*!< Mode to perform as B' Calypso (Innovatron) (PCD) */
DiegoOstuni 0:75fc82583a41 288 RFAL_MODE_POLL_B_CTS = 5, /*!< Mode to perform as CTS Poller (PCD) */
DiegoOstuni 0:75fc82583a41 289 RFAL_MODE_POLL_NFCF = 6, /*!< Mode to perform as NFCF (FeliCa) Poller (PCD) */
DiegoOstuni 0:75fc82583a41 290 RFAL_MODE_POLL_NFCV = 7, /*!< Mode to perform as NFCV (ISO15963) Poller (PCD) */
DiegoOstuni 0:75fc82583a41 291 RFAL_MODE_POLL_PICOPASS = 8, /*!< Mode to perform as PicoPass / iClass Poller (PCD) */
DiegoOstuni 0:75fc82583a41 292 RFAL_MODE_POLL_ACTIVE_P2P = 9, /*!< Mode to perform as Active P2P (ISO18092) Initiator */
DiegoOstuni 0:75fc82583a41 293 RFAL_MODE_LISTEN_NFCA = 10, /*!< Mode to perform as NFCA (ISO14443A) Listener (PICC) */
DiegoOstuni 0:75fc82583a41 294 RFAL_MODE_LISTEN_NFCB = 11, /*!< Mode to perform as NFCA (ISO14443B) Listener (PICC) */
DiegoOstuni 0:75fc82583a41 295 RFAL_MODE_LISTEN_NFCF = 12, /*!< Mode to perform as NFCA (ISO15963) Listener (PICC) */
DiegoOstuni 0:75fc82583a41 296 RFAL_MODE_LISTEN_ACTIVE_P2P = 13 /*!< Mode to perform as Active P2P (ISO18092) Target */
DiegoOstuni 0:75fc82583a41 297 } rfalMode;
DiegoOstuni 0:75fc82583a41 298
DiegoOstuni 0:75fc82583a41 299
DiegoOstuni 0:75fc82583a41 300 /*! RFAL Bit rates */
DiegoOstuni 0:75fc82583a41 301 typedef enum {
DiegoOstuni 0:75fc82583a41 302 RFAL_BR_106 = 0, /*!< Bit Rate 106 kbit/s (fc/128) */
DiegoOstuni 0:75fc82583a41 303 RFAL_BR_212 = 1, /*!< Bit Rate 212 kbit/s (fc/64) */
DiegoOstuni 0:75fc82583a41 304 RFAL_BR_424 = 2, /*!< Bit Rate 424 kbit/s (fc/32) */
DiegoOstuni 0:75fc82583a41 305 RFAL_BR_848 = 3, /*!< Bit Rate 848 kbit/s (fc/16) */
DiegoOstuni 0:75fc82583a41 306 RFAL_BR_1695 = 4, /*!< Bit Rate 1695 kbit/s (fc/8) */
DiegoOstuni 0:75fc82583a41 307 RFAL_BR_3390 = 5, /*!< Bit Rate 3390 kbit/s (fc/4) */
DiegoOstuni 0:75fc82583a41 308 RFAL_BR_6780 = 6, /*!< Bit Rate 6780 kbit/s (fc/2) */
DiegoOstuni 0:75fc82583a41 309 RFAL_BR_52p97 = 0xEB, /*!< Bit Rate 52.97 kbit/s (fc/256) Fast Mode VICC->VCD */
DiegoOstuni 0:75fc82583a41 310 RFAL_BR_26p48 = 0xEC, /*!< Bit Rate 26,48 kbit/s (fc/512) NFCV VICC->VCD & VCD->VICC 1of4 */
DiegoOstuni 0:75fc82583a41 311 RFAL_BR_1p66 = 0xED, /*!< Bit Rate 1,66 kbit/s (fc/8192) NFCV VCD->VICC 1of256 */
DiegoOstuni 0:75fc82583a41 312 RFAL_BR_KEEP = 0xFF /*!< Value indicating to keep the same previous bit rate */
DiegoOstuni 0:75fc82583a41 313 } rfalBitRate;
DiegoOstuni 0:75fc82583a41 314
DiegoOstuni 0:75fc82583a41 315
DiegoOstuni 0:75fc82583a41 316 /*! RFAL Compliance modes for upper modules */
DiegoOstuni 0:75fc82583a41 317 typedef enum {
DiegoOstuni 0:75fc82583a41 318 RFAL_COMPLIANCE_MODE_NFC, /*!< Perform with NFC Forum 1.1 compliance */
DiegoOstuni 0:75fc82583a41 319 RFAL_COMPLIANCE_MODE_EMV, /*!< Perform with EMVCo compliance */
DiegoOstuni 0:75fc82583a41 320 RFAL_COMPLIANCE_MODE_ISO /*!< Perform with ISO10373 compliance */
DiegoOstuni 0:75fc82583a41 321 }rfalComplianceMode;
DiegoOstuni 0:75fc82583a41 322
DiegoOstuni 0:75fc82583a41 323
DiegoOstuni 0:75fc82583a41 324 /*! RFAL main states flags */
DiegoOstuni 0:75fc82583a41 325 typedef enum {
DiegoOstuni 0:75fc82583a41 326 RFAL_STATE_IDLE = 0,
DiegoOstuni 0:75fc82583a41 327 RFAL_STATE_INIT = 1,
DiegoOstuni 0:75fc82583a41 328 RFAL_STATE_MODE_SET = 2,
DiegoOstuni 0:75fc82583a41 329
DiegoOstuni 0:75fc82583a41 330 RFAL_STATE_TXRX = 3,
DiegoOstuni 0:75fc82583a41 331 RFAL_STATE_LM = 4,
DiegoOstuni 0:75fc82583a41 332 RFAL_STATE_WUM = 5
DiegoOstuni 0:75fc82583a41 333
DiegoOstuni 0:75fc82583a41 334 } rfalState;
DiegoOstuni 0:75fc82583a41 335
DiegoOstuni 0:75fc82583a41 336 /*! RFAL transceive states */
DiegoOstuni 0:75fc82583a41 337 typedef enum {
DiegoOstuni 0:75fc82583a41 338 RFAL_TXRX_STATE_IDLE = 0,
DiegoOstuni 0:75fc82583a41 339 RFAL_TXRX_STATE_INIT = 1,
DiegoOstuni 0:75fc82583a41 340 RFAL_TXRX_STATE_START = 2,
DiegoOstuni 0:75fc82583a41 341
DiegoOstuni 0:75fc82583a41 342 RFAL_TXRX_STATE_TX_IDLE = 11,
DiegoOstuni 0:75fc82583a41 343 RFAL_TXRX_STATE_TX_WAIT_GT = 12,
DiegoOstuni 0:75fc82583a41 344 RFAL_TXRX_STATE_TX_WAIT_FDT = 13,
DiegoOstuni 0:75fc82583a41 345 RFAL_TXRX_STATE_TX_TRANSMIT = 14,
DiegoOstuni 0:75fc82583a41 346 RFAL_TXRX_STATE_TX_WAIT_WL = 15,
DiegoOstuni 0:75fc82583a41 347 RFAL_TXRX_STATE_TX_RELOAD_FIFO = 16,
DiegoOstuni 0:75fc82583a41 348 RFAL_TXRX_STATE_TX_WAIT_TXE = 17,
DiegoOstuni 0:75fc82583a41 349 RFAL_TXRX_STATE_TX_DONE = 18,
DiegoOstuni 0:75fc82583a41 350 RFAL_TXRX_STATE_TX_FAIL = 19,
DiegoOstuni 0:75fc82583a41 351
DiegoOstuni 0:75fc82583a41 352 RFAL_TXRX_STATE_RX_IDLE = 81,
DiegoOstuni 0:75fc82583a41 353 RFAL_TXRX_STATE_RX_WAIT_EON = 82,
DiegoOstuni 0:75fc82583a41 354 RFAL_TXRX_STATE_RX_WAIT_RXS = 83,
DiegoOstuni 0:75fc82583a41 355 RFAL_TXRX_STATE_RX_WAIT_RXE = 84,
DiegoOstuni 0:75fc82583a41 356 RFAL_TXRX_STATE_RX_READ_FIFO = 85,
DiegoOstuni 0:75fc82583a41 357 RFAL_TXRX_STATE_RX_ERR_CHECK = 86,
DiegoOstuni 0:75fc82583a41 358 RFAL_TXRX_STATE_RX_READ_DATA = 87,
DiegoOstuni 0:75fc82583a41 359 RFAL_TXRX_STATE_RX_WAIT_EOF = 88,
DiegoOstuni 0:75fc82583a41 360 RFAL_TXRX_STATE_RX_DONE = 89,
DiegoOstuni 0:75fc82583a41 361 RFAL_TXRX_STATE_RX_FAIL = 90,
DiegoOstuni 0:75fc82583a41 362
DiegoOstuni 0:75fc82583a41 363 } rfalTransceiveState;
DiegoOstuni 0:75fc82583a41 364
DiegoOstuni 0:75fc82583a41 365
DiegoOstuni 0:75fc82583a41 366 /*! RFAL transceive flags */
DiegoOstuni 0:75fc82583a41 367 enum {
DiegoOstuni 0:75fc82583a41 368 RFAL_TXRX_FLAGS_CRC_TX_AUTO = (0<<0), /*!< CRC will be generated automatic upon transmission */
DiegoOstuni 0:75fc82583a41 369 RFAL_TXRX_FLAGS_CRC_TX_MANUAL = (1<<0), /*!< CRC was calculated manually, included in txBuffer */
DiegoOstuni 0:75fc82583a41 370 RFAL_TXRX_FLAGS_CRC_RX_KEEP = (1<<1), /*!< Upon Reception keep the CRC in rxBuffer (reflected on rcvd length) */
DiegoOstuni 0:75fc82583a41 371 RFAL_TXRX_FLAGS_CRC_RX_REMV = (0<<1), /*!< Upon Reception remove the CRC from rxBuffer */
DiegoOstuni 0:75fc82583a41 372 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 */
DiegoOstuni 0:75fc82583a41 373 RFAL_TXRX_FLAGS_NFCIP1_OFF = (0<<2), /*!< Disable NFCIP1 mode: do not append protocol bytes while Tx nor skip while Rx */
DiegoOstuni 0:75fc82583a41 374 RFAL_TXRX_FLAGS_AGC_OFF = (1<<3), /*!< Disable Automatic Gain Control, improving multiple devices collision detection */
DiegoOstuni 0:75fc82583a41 375 RFAL_TXRX_FLAGS_AGC_ON = (0<<3), /*!< Enable Automatic Gain Control, improving single device reception */
DiegoOstuni 0:75fc82583a41 376 RFAL_TXRX_FLAGS_PAR_RX_KEEP = (1<<4), /*!< Disable Parity and CRC check and keep the Parity and CRC bits in the received buffer */
DiegoOstuni 0:75fc82583a41 377 RFAL_TXRX_FLAGS_PAR_RX_REMV = (0<<0), /*!< Enable Parity check and remove the parity bits from the received buffer */
DiegoOstuni 0:75fc82583a41 378 RFAL_TXRX_FLAGS_PAR_TX_NONE = (1<<5), /*!< Disable automatic Parity generation (ISO14443A) and use the one provided in the buffer*/
DiegoOstuni 0:75fc82583a41 379 RFAL_TXRX_FLAGS_PAR_TX_AUTO = (0<<5), /*!< Enable automatic Parity generation (ISO14443A) */
DiegoOstuni 0:75fc82583a41 380 RFAL_TXRX_FLAGS_NFCV_FLAG_MANUAL = (1<<6), /*!< Disable automatic adaption of flag byte (ISO15693) according to current comm params */
DiegoOstuni 0:75fc82583a41 381 RFAL_TXRX_FLAGS_NFCV_FLAG_AUTO = (0<<6), /*!< Enable automatic adaption of flag byte (ISO115693) according to current comm params */
DiegoOstuni 0:75fc82583a41 382 };
DiegoOstuni 0:75fc82583a41 383
DiegoOstuni 0:75fc82583a41 384
DiegoOstuni 0:75fc82583a41 385 /*! RFAL error handling */
DiegoOstuni 0:75fc82583a41 386 typedef enum {
DiegoOstuni 0:75fc82583a41 387 RFAL_ERRORHANDLING_NONE = 0, /*!< No special error handling will be performed */
DiegoOstuni 0:75fc82583a41 388 RFAL_ERRORHANDLING_NFC = 1, /*!< Error handling set to perform as NFC complaint device */
DiegoOstuni 0:75fc82583a41 389 RFAL_ERRORHANDLING_EMVCO = 2 /*!< Error handling set to perform as EMVCo complaint device */
DiegoOstuni 0:75fc82583a41 390 } rfalEHandling;
DiegoOstuni 0:75fc82583a41 391
DiegoOstuni 0:75fc82583a41 392
DiegoOstuni 0:75fc82583a41 393 /*! Struct that holds all context to be used on a Transceive */
DiegoOstuni 0:75fc82583a41 394 typedef struct {
DiegoOstuni 0:75fc82583a41 395 uint8_t* txBuf; /*!< (In) Buffer where outgoing message is located */
DiegoOstuni 0:75fc82583a41 396 uint16_t txBufLen; /*!< (In) Length of the outgoing message in bits */
DiegoOstuni 0:75fc82583a41 397
DiegoOstuni 0:75fc82583a41 398 uint8_t* rxBuf; /*!< (Out) Buffer where incoming message will be placed */
DiegoOstuni 0:75fc82583a41 399 uint16_t rxBufLen; /*!< (In) Maximum length of the incoming message in bits */
DiegoOstuni 0:75fc82583a41 400 uint16_t* rxRcvdLen; /*!< (Out) Actual received length in bits */
DiegoOstuni 0:75fc82583a41 401
DiegoOstuni 0:75fc82583a41 402 uint32_t flags; /*!< (In) TransceiveFlags indication special handling */
DiegoOstuni 0:75fc82583a41 403 uint32_t fwt; /*!< (In) Frame Waiting Time in 1/fc */
DiegoOstuni 0:75fc82583a41 404 } rfalTransceiveContext;
DiegoOstuni 0:75fc82583a41 405
DiegoOstuni 0:75fc82583a41 406
DiegoOstuni 0:75fc82583a41 407 /*! System callback to indicate an event that requires a system reRun */
DiegoOstuni 0:75fc82583a41 408 typedef void (* rfalUpperLayerCallback)(void);
DiegoOstuni 0:75fc82583a41 409
DiegoOstuni 0:75fc82583a41 410 /*! Callback to be executed before a Transceive */
DiegoOstuni 0:75fc82583a41 411 typedef void (* rfalPreTxRxCallback)(void);
DiegoOstuni 0:75fc82583a41 412
DiegoOstuni 0:75fc82583a41 413 /*! Callback to be executed after a Transceive */
DiegoOstuni 0:75fc82583a41 414 typedef void (* rfalPostTxRxCallback)(void);
DiegoOstuni 0:75fc82583a41 415
DiegoOstuni 0:75fc82583a41 416
DiegoOstuni 0:75fc82583a41 417 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 418 /* ISO14443A */
DiegoOstuni 0:75fc82583a41 419 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 420
DiegoOstuni 0:75fc82583a41 421 /*! RFAL ISO 14443A Short Frame Command */
DiegoOstuni 0:75fc82583a41 422 typedef enum
DiegoOstuni 0:75fc82583a41 423 {
DiegoOstuni 0:75fc82583a41 424 RFAL_14443A_SHORTFRAME_CMD_WUPA = 0x52, /*!< ISO14443A WUPA / NFC-A ALL_REQ */
DiegoOstuni 0:75fc82583a41 425 RFAL_14443A_SHORTFRAME_CMD_REQA = 0x26 /*!< ISO14443A REQA / NFC-A SENS_REQ */
DiegoOstuni 0:75fc82583a41 426 } rfal14443AShortFrameCmd;
DiegoOstuni 0:75fc82583a41 427
DiegoOstuni 0:75fc82583a41 428 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 429
DiegoOstuni 0:75fc82583a41 430
DiegoOstuni 0:75fc82583a41 431 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 432 /* FeliCa */
DiegoOstuni 0:75fc82583a41 433 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 434
DiegoOstuni 0:75fc82583a41 435 #define RFAL_FELICA_LEN_LEN 1 /*!< FeliCa LEN byte length */
DiegoOstuni 0:75fc82583a41 436 #define RFAL_FELICA_POLL_REQ_LEN (RFAL_FELICA_LEN_LEN + 1 + 2 + 1 + 1) /*!< FeliCa Poll Request length (LEN + CMD + SC + RC + TSN) */
DiegoOstuni 0:75fc82583a41 437 #define RFAL_FELICA_POLL_RES_LEN (RFAL_FELICA_LEN_LEN + 1 + 8 + 8 + 2) /*!< Maximum FeliCa Poll Response length (LEN + CMD + NFCID2 + PAD + RD) */
DiegoOstuni 0:75fc82583a41 438 #define RFAL_FELICA_POLL_MAX_SLOTS 16 /*!< Maximum number of slots (TSN) on FeliCa Poll */
DiegoOstuni 0:75fc82583a41 439
DiegoOstuni 0:75fc82583a41 440
DiegoOstuni 0:75fc82583a41 441 /*! NFC-F RC (Request Code) codes NFC Forum Digital 1.1 Table 42 */
DiegoOstuni 0:75fc82583a41 442 enum
DiegoOstuni 0:75fc82583a41 443 {
DiegoOstuni 0:75fc82583a41 444 RFAL_FELICA_POLL_RC_NO_REQUEST = 0x00, /*!< RC: No System Code information requested */
DiegoOstuni 0:75fc82583a41 445 RFAL_FELICA_POLL_RC_SYSTEM_CODE = 0x01, /*!< RC: System Code information requested */
DiegoOstuni 0:75fc82583a41 446 RFAL_FELICA_POLL_RC_COM_PERFORMANCE = 0x02 /*!< RC: Advanced protocol features supported */
DiegoOstuni 0:75fc82583a41 447 };
DiegoOstuni 0:75fc82583a41 448
DiegoOstuni 0:75fc82583a41 449
DiegoOstuni 0:75fc82583a41 450 /*! NFC-F TSN (Time Slot Number) codes NFC Forum Digital 1.1 Table 43 */
DiegoOstuni 0:75fc82583a41 451 typedef enum
DiegoOstuni 0:75fc82583a41 452 {
DiegoOstuni 0:75fc82583a41 453 RFAL_FELICA_1_SLOT = 0, /*!< TSN with number of Time Slots: 1 */
DiegoOstuni 0:75fc82583a41 454 RFAL_FELICA_2_SLOTS = 1, /*!< TSN with number of Time Slots: 2 */
DiegoOstuni 0:75fc82583a41 455 RFAL_FELICA_4_SLOTS = 3, /*!< TSN with number of Time Slots: 4 */
DiegoOstuni 0:75fc82583a41 456 RFAL_FELICA_8_SLOTS = 7, /*!< TSN with number of Time Slots: 8 */
DiegoOstuni 0:75fc82583a41 457 RFAL_FELICA_16_SLOTS = 15 /*!< TSN with number of Time Slots: 16 */
DiegoOstuni 0:75fc82583a41 458 } rfalFeliCaPollSlots;
DiegoOstuni 0:75fc82583a41 459
DiegoOstuni 0:75fc82583a41 460
DiegoOstuni 0:75fc82583a41 461 /*! NFCF Poll Response NFC Forum Digital 1.1 Table 44 */
DiegoOstuni 0:75fc82583a41 462 typedef uint8_t rfalFeliCaPollRes[RFAL_FELICA_POLL_RES_LEN];
DiegoOstuni 0:75fc82583a41 463
DiegoOstuni 0:75fc82583a41 464
DiegoOstuni 0:75fc82583a41 465 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 466
DiegoOstuni 0:75fc82583a41 467
DiegoOstuni 0:75fc82583a41 468 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 469 /* Listen Mode */
DiegoOstuni 0:75fc82583a41 470 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 471
DiegoOstuni 0:75fc82583a41 472 /*! RFAL Listen Mode NFCID Length */
DiegoOstuni 0:75fc82583a41 473 typedef enum
DiegoOstuni 0:75fc82583a41 474 {
DiegoOstuni 0:75fc82583a41 475 RFAL_LM_NFCID_LEN_04 = 4, /*!< Listen mode indicates 4 byte NFCID */
DiegoOstuni 0:75fc82583a41 476 RFAL_LM_NFCID_LEN_07 = 7, /*!< Listen mode indicates 7 byte NFCID */
DiegoOstuni 0:75fc82583a41 477 RFAL_LM_NFCID_LEN_10 = 10, /*!< Listen mode indicates 10 byte NFCID */
DiegoOstuni 0:75fc82583a41 478 } rfalLmNfcidLen;
DiegoOstuni 0:75fc82583a41 479
DiegoOstuni 0:75fc82583a41 480
DiegoOstuni 0:75fc82583a41 481 /*! RFAL Listen Mode States */
DiegoOstuni 0:75fc82583a41 482 typedef enum
DiegoOstuni 0:75fc82583a41 483 {
DiegoOstuni 0:75fc82583a41 484 RFAL_LM_STATE_NOT_INIT = 0x00, /*!< Not Initialized state */
DiegoOstuni 0:75fc82583a41 485 RFAL_LM_STATE_POWER_OFF = 0x01, /*!< Power Off state */
DiegoOstuni 0:75fc82583a41 486 RFAL_LM_STATE_IDLE = 0x02, /*!< Idle state Activity 1.1 5.2 */
DiegoOstuni 0:75fc82583a41 487 RFAL_LM_STATE_READY_A = 0x03, /*!< Ready A state Activity 1.1 5.3 5.4 & 5.5 */
DiegoOstuni 0:75fc82583a41 488 RFAL_LM_STATE_READY_B = 0x04, /*!< Ready B state Activity 1.1 5.11 5.12 */
DiegoOstuni 0:75fc82583a41 489 RFAL_LM_STATE_READY_F = 0x05, /*!< Ready F state Activity 1.1 5.15 */
DiegoOstuni 0:75fc82583a41 490 RFAL_LM_STATE_ACTIVE_A = 0x06, /*!< Active A state Activity 1.1 5.6 */
DiegoOstuni 0:75fc82583a41 491 RFAL_LM_STATE_CARDEMU_4A = 0x07, /*!< Card Emulation 4A state Activity 1.1 5.10 */
DiegoOstuni 0:75fc82583a41 492 RFAL_LM_STATE_CARDEMU_4B = 0x08, /*!< Card Emulation 4B state Activity 1.1 5.14 */
DiegoOstuni 0:75fc82583a41 493 RFAL_LM_STATE_CARDEMU_3 = 0x09, /*!< Card Emulation 3 state Activity 1.1 5.18 */
DiegoOstuni 0:75fc82583a41 494 RFAL_LM_STATE_TARGET_A = 0x0A, /*!< Target A state Activity 1.1 5.9 */
DiegoOstuni 0:75fc82583a41 495 RFAL_LM_STATE_TARGET_F = 0x0B, /*!< Target F state Activity 1.1 5.17 */
DiegoOstuni 0:75fc82583a41 496 RFAL_LM_STATE_SLEEP_A = 0x0C, /*!< Sleep A state Activity 1.1 5.7 */
DiegoOstuni 0:75fc82583a41 497 RFAL_LM_STATE_SLEEP_B = 0x0D, /*!< Sleep B state Activity 1.1 5.13 */
DiegoOstuni 0:75fc82583a41 498 RFAL_LM_STATE_READY_Ax = 0x0E, /*!< Ready A* state Activity 1.1 5.3 5.4 & 5.5 */
DiegoOstuni 0:75fc82583a41 499 RFAL_LM_STATE_ACTIVE_Ax = 0x0F, /*!< Active A* state Activity 1.1 5.6 */
DiegoOstuni 0:75fc82583a41 500 RFAL_LM_STATE_SLEEP_AF = 0x10, /*!< Sleep AF state Activity 1.1 5.19 */
DiegoOstuni 0:75fc82583a41 501 } rfalLmState;
DiegoOstuni 0:75fc82583a41 502
DiegoOstuni 0:75fc82583a41 503
DiegoOstuni 0:75fc82583a41 504 /*! RFAL Listen Mode Passive A configs */
DiegoOstuni 0:75fc82583a41 505 typedef struct
DiegoOstuni 0:75fc82583a41 506 {
DiegoOstuni 0:75fc82583a41 507 rfalLmNfcidLen nfcidLen; /*!< NFCID Len (00: 4bytes ; 01: 7bytes) */
DiegoOstuni 0:75fc82583a41 508 uint8_t nfcid[RFAL_NFCID3_LEN]; /*!< NFCID */
DiegoOstuni 0:75fc82583a41 509 uint8_t SENS_RES[RFAL_LM_SENS_RES_LEN]; /*!< NFC-106k; SENS_REQ Response */
DiegoOstuni 0:75fc82583a41 510 uint8_t SEL_RES; /*!< SEL_RES (SAK) with complete NFCID1 (UID) */
DiegoOstuni 0:75fc82583a41 511 } rfalLmConfPA;
DiegoOstuni 0:75fc82583a41 512
DiegoOstuni 0:75fc82583a41 513
DiegoOstuni 0:75fc82583a41 514 /*! RFAL Listen Mode Passive B configs */
DiegoOstuni 0:75fc82583a41 515 typedef struct
DiegoOstuni 0:75fc82583a41 516 {
DiegoOstuni 0:75fc82583a41 517 uint8_t SENSB_RES[RFAL_LM_SENSB_RES_LEN]; /*!< SENSF_RES */
DiegoOstuni 0:75fc82583a41 518 } rfalLmConfPB;
DiegoOstuni 0:75fc82583a41 519
DiegoOstuni 0:75fc82583a41 520
DiegoOstuni 0:75fc82583a41 521 /*! RFAL Listen Mode Passive F configs */
DiegoOstuni 0:75fc82583a41 522 typedef struct
DiegoOstuni 0:75fc82583a41 523 {
DiegoOstuni 0:75fc82583a41 524 uint8_t SC[RFAL_LM_SENSF_SC_LEN]; /*!< System Code to listen for */
DiegoOstuni 0:75fc82583a41 525 uint8_t SENSF_RES[RFAL_LM_SENSF_RES_LEN]; /*!< SENSF_RES */
DiegoOstuni 0:75fc82583a41 526 } rfalLmConfPF;
DiegoOstuni 0:75fc82583a41 527
DiegoOstuni 0:75fc82583a41 528 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 529
DiegoOstuni 0:75fc82583a41 530
DiegoOstuni 0:75fc82583a41 531 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 532 /* Wake-Up Mode */
DiegoOstuni 0:75fc82583a41 533 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 534
DiegoOstuni 0:75fc82583a41 535 /*! RFAL Wake-Up Mode States */
DiegoOstuni 0:75fc82583a41 536 typedef enum
DiegoOstuni 0:75fc82583a41 537 {
DiegoOstuni 0:75fc82583a41 538 RFAL_WUM_STATE_NOT_INIT = 0x00, /*!< Not Initialized state */
DiegoOstuni 0:75fc82583a41 539 RFAL_WUM_STATE_ENABLED = 0x01, /*!< Wake-Up mode is enabled */
DiegoOstuni 0:75fc82583a41 540 RFAL_WUM_STATE_ENABLED_WOKE = 0x02, /*!< Wake-Up mode enabled and has received IRQ(s)*/
DiegoOstuni 0:75fc82583a41 541 } rfalWumState;
DiegoOstuni 0:75fc82583a41 542 /*******************************************************************************/
DiegoOstuni 0:75fc82583a41 543
DiegoOstuni 0:75fc82583a41 544 /*
DiegoOstuni 0:75fc82583a41 545 ******************************************************************************
DiegoOstuni 0:75fc82583a41 546 * GLOBAL FUNCTION PROTOTYPES
DiegoOstuni 0:75fc82583a41 547 ******************************************************************************
DiegoOstuni 0:75fc82583a41 548 */
DiegoOstuni 0:75fc82583a41 549
DiegoOstuni 0:75fc82583a41 550
DiegoOstuni 0:75fc82583a41 551 /*!
DiegoOstuni 0:75fc82583a41 552 *****************************************************************************
DiegoOstuni 0:75fc82583a41 553 * \brief RFAL Initialize
DiegoOstuni 0:75fc82583a41 554 *
DiegoOstuni 0:75fc82583a41 555 * Initializes RFAL layer and the ST25R391x
DiegoOstuni 0:75fc82583a41 556 * Ensures that ST25R391x is properly connected and returns error if any problem
DiegoOstuni 0:75fc82583a41 557 * is detected
DiegoOstuni 0:75fc82583a41 558 *
DiegoOstuni 0:75fc82583a41 559 * \warning rfalAnalogConfigInitialize() should be called before so that
DiegoOstuni 0:75fc82583a41 560 * the Analog config table has been previously initialized.
DiegoOstuni 0:75fc82583a41 561 *
DiegoOstuni 0:75fc82583a41 562 * \return ERR_HW_MISMATCH : Expected HW do not match or communication error
DiegoOstuni 0:75fc82583a41 563 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 564 *****************************************************************************
DiegoOstuni 0:75fc82583a41 565 */
DiegoOstuni 0:75fc82583a41 566 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 );
DiegoOstuni 0:75fc82583a41 567
DiegoOstuni 0:75fc82583a41 568
DiegoOstuni 0:75fc82583a41 569 /*!
DiegoOstuni 0:75fc82583a41 570 *****************************************************************************
DiegoOstuni 0:75fc82583a41 571 * \brief RFAL Calibrate
DiegoOstuni 0:75fc82583a41 572 *
DiegoOstuni 0:75fc82583a41 573 * Performs necessary calibration of RF chip in case it is indicated by current
DiegoOstuni 0:75fc82583a41 574 * register settings. E.g. antenna calibration and regulator calibration
DiegoOstuni 0:75fc82583a41 575 *
DiegoOstuni 0:75fc82583a41 576 * \return ERR_WRONG_STATE : RFAL not initialized
DiegoOstuni 0:75fc82583a41 577 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 578 *
DiegoOstuni 0:75fc82583a41 579 *****************************************************************************
DiegoOstuni 0:75fc82583a41 580 */
DiegoOstuni 0:75fc82583a41 581 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 );
DiegoOstuni 0:75fc82583a41 582
DiegoOstuni 0:75fc82583a41 583
DiegoOstuni 0:75fc82583a41 584 /*!
DiegoOstuni 0:75fc82583a41 585 *****************************************************************************
DiegoOstuni 0:75fc82583a41 586 * \brief RFAL Adjust Regulators
DiegoOstuni 0:75fc82583a41 587 *
DiegoOstuni 0:75fc82583a41 588 * Adjusts ST25R391x regulators
DiegoOstuni 0:75fc82583a41 589 *
DiegoOstuni 0:75fc82583a41 590 * \param[out] result : the result of the calibrate antenna in mV
DiegoOstuni 0:75fc82583a41 591 * NULL if result not requested
DiegoOstuni 0:75fc82583a41 592 *
DiegoOstuni 0:75fc82583a41 593 * \return ERR_WRONG_STATE : RFAL not initialized
DiegoOstuni 0:75fc82583a41 594 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 595 *
DiegoOstuni 0:75fc82583a41 596 *****************************************************************************
DiegoOstuni 0:75fc82583a41 597 */
DiegoOstuni 0:75fc82583a41 598 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 );
DiegoOstuni 0:75fc82583a41 599
DiegoOstuni 0:75fc82583a41 600
DiegoOstuni 0:75fc82583a41 601 /*!
DiegoOstuni 0:75fc82583a41 602 *****************************************************************************
DiegoOstuni 0:75fc82583a41 603 * \brief RFAL Set System Callback
DiegoOstuni 0:75fc82583a41 604 *
DiegoOstuni 0:75fc82583a41 605 * Sets a callback for the driver to call when an event has occurred that
DiegoOstuni 0:75fc82583a41 606 * may require the system to be notified
DiegoOstuni 0:75fc82583a41 607 *
DiegoOstuni 0:75fc82583a41 608 * \param[in] pFunc : method pointer for the upper layer callback
DiegoOstuni 0:75fc82583a41 609 *
DiegoOstuni 0:75fc82583a41 610 *****************************************************************************
DiegoOstuni 0:75fc82583a41 611 */
DiegoOstuni 0:75fc82583a41 612 void rfalSetUpperLayerCallback( rfalUpperLayerCallback pFunc );
DiegoOstuni 0:75fc82583a41 613
DiegoOstuni 0:75fc82583a41 614
DiegoOstuni 0:75fc82583a41 615 /*!
DiegoOstuni 0:75fc82583a41 616 *****************************************************************************
DiegoOstuni 0:75fc82583a41 617 * \brief RFAL Set Pre Tx Callback
DiegoOstuni 0:75fc82583a41 618 *
DiegoOstuni 0:75fc82583a41 619 * Sets a callback for the driver to call before a Transceive
DiegoOstuni 0:75fc82583a41 620 *
DiegoOstuni 0:75fc82583a41 621 * \param[in] pFunc : method pointer for the Pre Tx callback
DiegoOstuni 0:75fc82583a41 622 *
DiegoOstuni 0:75fc82583a41 623 *****************************************************************************
DiegoOstuni 0:75fc82583a41 624 */
DiegoOstuni 0:75fc82583a41 625 void rfalSetPreTxRxCallback( rfalPreTxRxCallback pFunc );
DiegoOstuni 0:75fc82583a41 626
DiegoOstuni 0:75fc82583a41 627 /*!
DiegoOstuni 0:75fc82583a41 628 *****************************************************************************
DiegoOstuni 0:75fc82583a41 629 * \brief RFAL Set Post Tx Callback
DiegoOstuni 0:75fc82583a41 630 *
DiegoOstuni 0:75fc82583a41 631 * Sets a callback for the driver to call after a Transceive
DiegoOstuni 0:75fc82583a41 632 *
DiegoOstuni 0:75fc82583a41 633 * \param[in] pFunc : method pointer for the Post Tx callback
DiegoOstuni 0:75fc82583a41 634 *
DiegoOstuni 0:75fc82583a41 635 *****************************************************************************
DiegoOstuni 0:75fc82583a41 636 */
DiegoOstuni 0:75fc82583a41 637 void rfalSetPostTxRxCallback( rfalPostTxRxCallback pFunc );
DiegoOstuni 0:75fc82583a41 638
DiegoOstuni 0:75fc82583a41 639 /*!
DiegoOstuni 0:75fc82583a41 640 *****************************************************************************
DiegoOstuni 0:75fc82583a41 641 * \brief RFAL Deinitialize
DiegoOstuni 0:75fc82583a41 642 *
DiegoOstuni 0:75fc82583a41 643 * Deinitializes RFAL layer and the ST25R391x
DiegoOstuni 0:75fc82583a41 644 *
DiegoOstuni 0:75fc82583a41 645 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 646 *
DiegoOstuni 0:75fc82583a41 647 *****************************************************************************
DiegoOstuni 0:75fc82583a41 648 */
DiegoOstuni 0:75fc82583a41 649 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 );
DiegoOstuni 0:75fc82583a41 650
DiegoOstuni 0:75fc82583a41 651
DiegoOstuni 0:75fc82583a41 652 /*!
DiegoOstuni 0:75fc82583a41 653 *****************************************************************************
DiegoOstuni 0:75fc82583a41 654 * \brief RFAL Set Mode
DiegoOstuni 0:75fc82583a41 655 *
DiegoOstuni 0:75fc82583a41 656 * Sets the mode that RFAL will operate on the following communications.
DiegoOstuni 0:75fc82583a41 657 * Proper initializations will be performed on the ST25R391x
DiegoOstuni 0:75fc82583a41 658 *
DiegoOstuni 0:75fc82583a41 659 * \warning bit rate value RFAL_BR_KEEP is not allowed, only in rfalSetBitRate()
DiegoOstuni 0:75fc82583a41 660 *
DiegoOstuni 0:75fc82583a41 661 * \warning the mode will be applied immediately on the RFchip regardless of
DiegoOstuni 0:75fc82583a41 662 * any ongoing operations like Transceive, ListenMode
DiegoOstuni 0:75fc82583a41 663 *
DiegoOstuni 0:75fc82583a41 664 * \param[in] mode : mode for the RFAL/RFchip to perform
DiegoOstuni 0:75fc82583a41 665 * \param[in] txBR : transmit bit rate
DiegoOstuni 0:75fc82583a41 666 * \param[in] rxBR : receive bit rate
DiegoOstuni 0:75fc82583a41 667 *
DiegoOstuni 0:75fc82583a41 668 * \see rfalIsGTDone
DiegoOstuni 0:75fc82583a41 669 * \see rfalMode
DiegoOstuni 0:75fc82583a41 670 *
DiegoOstuni 0:75fc82583a41 671 * \return ERR_WRONG_STATE : RFAL not initialized
DiegoOstuni 0:75fc82583a41 672 * \return ERR_PARAM : Invalid parameter
DiegoOstuni 0:75fc82583a41 673 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 674 *
DiegoOstuni 0:75fc82583a41 675 *****************************************************************************
DiegoOstuni 0:75fc82583a41 676 */
DiegoOstuni 0:75fc82583a41 677 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 );
DiegoOstuni 0:75fc82583a41 678
DiegoOstuni 0:75fc82583a41 679
DiegoOstuni 0:75fc82583a41 680 /*!
DiegoOstuni 0:75fc82583a41 681 *****************************************************************************
DiegoOstuni 0:75fc82583a41 682 * \brief RFAL Get Mode
DiegoOstuni 0:75fc82583a41 683 *
DiegoOstuni 0:75fc82583a41 684 * Gets the mode that RFAL is set to operate
DiegoOstuni 0:75fc82583a41 685 *
DiegoOstuni 0:75fc82583a41 686 * \see rfalMode
DiegoOstuni 0:75fc82583a41 687 *
DiegoOstuni 0:75fc82583a41 688 * \return rfalMode : The current RFAL mode
DiegoOstuni 0:75fc82583a41 689 *****************************************************************************
DiegoOstuni 0:75fc82583a41 690 */
DiegoOstuni 0:75fc82583a41 691 rfalMode rfalGetMode( void );
DiegoOstuni 0:75fc82583a41 692
DiegoOstuni 0:75fc82583a41 693
DiegoOstuni 0:75fc82583a41 694 /*!
DiegoOstuni 0:75fc82583a41 695 *****************************************************************************
DiegoOstuni 0:75fc82583a41 696 * \brief RFAL Set Bit Rate
DiegoOstuni 0:75fc82583a41 697 *
DiegoOstuni 0:75fc82583a41 698 * Sets the Tx and Rx bit rates with the given values
DiegoOstuni 0:75fc82583a41 699 * The bit rate change is applied on the RF chip remaining in the same
DiegoOstuni 0:75fc82583a41 700 * mode previous defined with rfalSetMode()
DiegoOstuni 0:75fc82583a41 701 *
DiegoOstuni 0:75fc82583a41 702 * If no mode is defined bit rates will not be applied and an error
DiegoOstuni 0:75fc82583a41 703 * is returned
DiegoOstuni 0:75fc82583a41 704 *
DiegoOstuni 0:75fc82583a41 705 * \param[in] txBR : transmit bit rate
DiegoOstuni 0:75fc82583a41 706 * \param[in] rxBR : receive bit rate
DiegoOstuni 0:75fc82583a41 707 *
DiegoOstuni 0:75fc82583a41 708 * \see rfalSetMode
DiegoOstuni 0:75fc82583a41 709 * \see rfalMode
DiegoOstuni 0:75fc82583a41 710 * \see rfalBitRate
DiegoOstuni 0:75fc82583a41 711 *
DiegoOstuni 0:75fc82583a41 712 * \return ERR_WRONG_STATE : RFAL not initialized
DiegoOstuni 0:75fc82583a41 713 * \return ERR_PARAM : Invalid parameter
DiegoOstuni 0:75fc82583a41 714 * \return ERR_NOT_IMPLEMENTED : Mode not implemented
DiegoOstuni 0:75fc82583a41 715 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 716 *
DiegoOstuni 0:75fc82583a41 717 *****************************************************************************
DiegoOstuni 0:75fc82583a41 718 */
DiegoOstuni 0:75fc82583a41 719 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 );
DiegoOstuni 0:75fc82583a41 720
DiegoOstuni 0:75fc82583a41 721
DiegoOstuni 0:75fc82583a41 722 /*!
DiegoOstuni 0:75fc82583a41 723 *****************************************************************************
DiegoOstuni 0:75fc82583a41 724 * \brief RFAL Get Bit Rate
DiegoOstuni 0:75fc82583a41 725 *
DiegoOstuni 0:75fc82583a41 726 * Gets the Tx and Rx current bit rates
DiegoOstuni 0:75fc82583a41 727 *
DiegoOstuni 0:75fc82583a41 728 * If RFAL is not initialized or mode not set the bit rates return will
DiegoOstuni 0:75fc82583a41 729 * be invalid RFAL_BR_KEEP
DiegoOstuni 0:75fc82583a41 730 *
DiegoOstuni 0:75fc82583a41 731 * \param[out] txBR : RFAL's current Tx Bit Rate
DiegoOstuni 0:75fc82583a41 732 * \param[out] rxBR : RFAL's current Rx Bit Rate
DiegoOstuni 0:75fc82583a41 733 *
DiegoOstuni 0:75fc82583a41 734 * \see rfalSetBitRate
DiegoOstuni 0:75fc82583a41 735 * \see rfalBitRate
DiegoOstuni 0:75fc82583a41 736 *
DiegoOstuni 0:75fc82583a41 737 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 738 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 739 *****************************************************************************
DiegoOstuni 0:75fc82583a41 740 */
DiegoOstuni 0:75fc82583a41 741 ReturnCode rfalGetBitRate( rfalBitRate *txBR, rfalBitRate *rxBR );
DiegoOstuni 0:75fc82583a41 742
DiegoOstuni 0:75fc82583a41 743
DiegoOstuni 0:75fc82583a41 744 /*!
DiegoOstuni 0:75fc82583a41 745 *****************************************************************************
DiegoOstuni 0:75fc82583a41 746 * \brief RFAL Set Modulated RFO
DiegoOstuni 0:75fc82583a41 747 *
DiegoOstuni 0:75fc82583a41 748 * Sets the RFO value to be used in the modulated state
DiegoOstuni 0:75fc82583a41 749 *
DiegoOstuni 0:75fc82583a41 750 * \param[in] rfo : the RFO value to be used
DiegoOstuni 0:75fc82583a41 751 *
DiegoOstuni 0:75fc82583a41 752 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 753 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 754 *****************************************************************************
DiegoOstuni 0:75fc82583a41 755 */
DiegoOstuni 0:75fc82583a41 756 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 );
DiegoOstuni 0:75fc82583a41 757
DiegoOstuni 0:75fc82583a41 758
DiegoOstuni 0:75fc82583a41 759 /*!
DiegoOstuni 0:75fc82583a41 760 *****************************************************************************
DiegoOstuni 0:75fc82583a41 761 * \brief RFAL Get Modulated RFO
DiegoOstuni 0:75fc82583a41 762 *
DiegoOstuni 0:75fc82583a41 763 * Gets the RFO value used in the modulated state
DiegoOstuni 0:75fc82583a41 764 *
DiegoOstuni 0:75fc82583a41 765 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 766 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 767 *****************************************************************************
DiegoOstuni 0:75fc82583a41 768 */
DiegoOstuni 0:75fc82583a41 769 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 );
DiegoOstuni 0:75fc82583a41 770
DiegoOstuni 0:75fc82583a41 771
DiegoOstuni 0:75fc82583a41 772 /*!
DiegoOstuni 0:75fc82583a41 773 *****************************************************************************
DiegoOstuni 0:75fc82583a41 774 * \brief RFAL Measure RF Amplitude
DiegoOstuni 0:75fc82583a41 775 *
DiegoOstuni 0:75fc82583a41 776 * Measures the RF Amplitude
DiegoOstuni 0:75fc82583a41 777 *
DiegoOstuni 0:75fc82583a41 778 * \param[out] result : result of RF measurement
DiegoOstuni 0:75fc82583a41 779 *
DiegoOstuni 0:75fc82583a41 780 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 781 * \return ERR_NONE : No error
DiegoOstuni 0:75fc82583a41 782 *****************************************************************************
DiegoOstuni 0:75fc82583a41 783 */
DiegoOstuni 0:75fc82583a41 784 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 );
DiegoOstuni 0:75fc82583a41 785
DiegoOstuni 0:75fc82583a41 786
DiegoOstuni 0:75fc82583a41 787 /*!
DiegoOstuni 0:75fc82583a41 788 *****************************************************************************
DiegoOstuni 0:75fc82583a41 789 * \brief Set Error Handling Mode
DiegoOstuni 0:75fc82583a41 790 *
DiegoOstuni 0:75fc82583a41 791 * Sets the error handling mode to be used by the RFAL
DiegoOstuni 0:75fc82583a41 792 *
DiegoOstuni 0:75fc82583a41 793 * \param[in] eHandling : the error handling mode
DiegoOstuni 0:75fc82583a41 794 *
DiegoOstuni 0:75fc82583a41 795 *****************************************************************************
DiegoOstuni 0:75fc82583a41 796 */
DiegoOstuni 0:75fc82583a41 797 void rfalSetErrorHandling( rfalEHandling eHandling );
DiegoOstuni 0:75fc82583a41 798
DiegoOstuni 0:75fc82583a41 799
DiegoOstuni 0:75fc82583a41 800 /*!
DiegoOstuni 0:75fc82583a41 801 *****************************************************************************
DiegoOstuni 0:75fc82583a41 802 * \brief Get Error Handling Mode
DiegoOstuni 0:75fc82583a41 803 *
DiegoOstuni 0:75fc82583a41 804 * Gets the error handling mode currently used by the RFAL
DiegoOstuni 0:75fc82583a41 805 *
DiegoOstuni 0:75fc82583a41 806 * \return rfalEHandling : Current error handling mode
DiegoOstuni 0:75fc82583a41 807 *****************************************************************************
DiegoOstuni 0:75fc82583a41 808 */
DiegoOstuni 0:75fc82583a41 809 rfalEHandling rfalGetErrorHandling( void );
DiegoOstuni 0:75fc82583a41 810
DiegoOstuni 0:75fc82583a41 811
DiegoOstuni 0:75fc82583a41 812 /*!
DiegoOstuni 0:75fc82583a41 813 *****************************************************************************
DiegoOstuni 0:75fc82583a41 814 * \brief Set Observation Mode
DiegoOstuni 0:75fc82583a41 815 *
DiegoOstuni 0:75fc82583a41 816 * Sets ST25R391x observation modes for RF debug purposes
DiegoOstuni 0:75fc82583a41 817 *
DiegoOstuni 0:75fc82583a41 818 * \param[in] txMode : the observation mode to be used during transmission
DiegoOstuni 0:75fc82583a41 819 * \param[in] rxMode : the observation mode to be used during reception
DiegoOstuni 0:75fc82583a41 820 *
DiegoOstuni 0:75fc82583a41 821 * \warning The Observation Mode is an advanced feature and should be set
DiegoOstuni 0:75fc82583a41 822 * according to the documentation of the part number in use.
DiegoOstuni 0:75fc82583a41 823 * Please refer to the corresponding Datasheet or Application Note(s)
DiegoOstuni 0:75fc82583a41 824 *****************************************************************************
DiegoOstuni 0:75fc82583a41 825 */
DiegoOstuni 0:75fc82583a41 826 void rfalSetObsvMode( uint8_t txMode, uint8_t rxMode );
DiegoOstuni 0:75fc82583a41 827
DiegoOstuni 0:75fc82583a41 828
DiegoOstuni 0:75fc82583a41 829 /*!
DiegoOstuni 0:75fc82583a41 830 *****************************************************************************
DiegoOstuni 0:75fc82583a41 831 * \brief Get Observation Mode
DiegoOstuni 0:75fc82583a41 832 *
DiegoOstuni 0:75fc82583a41 833 * Gets ST25R391x the current configured observation modes
DiegoOstuni 0:75fc82583a41 834 *
DiegoOstuni 0:75fc82583a41 835 * \param[in] txMode : the current observation mode configured for transmission
DiegoOstuni 0:75fc82583a41 836 * \param[in] rxMode : the current observation mode configured for reception
DiegoOstuni 0:75fc82583a41 837 *
DiegoOstuni 0:75fc82583a41 838 *****************************************************************************
DiegoOstuni 0:75fc82583a41 839 */
DiegoOstuni 0:75fc82583a41 840 void rfalGetObsvMode( uint8_t* txMode, uint8_t* rxMode );
DiegoOstuni 0:75fc82583a41 841
DiegoOstuni 0:75fc82583a41 842
DiegoOstuni 0:75fc82583a41 843 /*!
DiegoOstuni 0:75fc82583a41 844 *****************************************************************************
DiegoOstuni 0:75fc82583a41 845 * \brief Disable Observation Mode
DiegoOstuni 0:75fc82583a41 846 *
DiegoOstuni 0:75fc82583a41 847 * Disables the ST25R391x observation mode
DiegoOstuni 0:75fc82583a41 848 *****************************************************************************
DiegoOstuni 0:75fc82583a41 849 */
DiegoOstuni 0:75fc82583a41 850 void rfalDisableObsvMode( void );
DiegoOstuni 0:75fc82583a41 851
DiegoOstuni 0:75fc82583a41 852
DiegoOstuni 0:75fc82583a41 853 /*!
DiegoOstuni 0:75fc82583a41 854 *****************************************************************************
DiegoOstuni 0:75fc82583a41 855 * \brief RFAL Set FDT Poll
DiegoOstuni 0:75fc82583a41 856 *
DiegoOstuni 0:75fc82583a41 857 * Sets the Frame Delay Time (FDT) to be used on the following
DiegoOstuni 0:75fc82583a41 858 * communications.
DiegoOstuni 0:75fc82583a41 859 *
DiegoOstuni 0:75fc82583a41 860 * FDT Poll is the minimum time following a Poll Frame during
DiegoOstuni 0:75fc82583a41 861 * which no subsequent Poll Frame can be sent (without a response from
DiegoOstuni 0:75fc82583a41 862 * the Listener in between)
DiegoOstuni 0:75fc82583a41 863 * FDTx,PP,MIN - Digital 1.1 6.10.2 & 7.9.2 & 8.7.2
DiegoOstuni 0:75fc82583a41 864 *
DiegoOstuni 0:75fc82583a41 865 * \param[in] fdt : Frame Delay Time in 1/fc cycles
DiegoOstuni 0:75fc82583a41 866 *
DiegoOstuni 0:75fc82583a41 867 *****************************************************************************
DiegoOstuni 0:75fc82583a41 868 */
DiegoOstuni 0:75fc82583a41 869 void rfalSetFDTPoll( uint32_t fdt );
DiegoOstuni 0:75fc82583a41 870
DiegoOstuni 0:75fc82583a41 871
DiegoOstuni 0:75fc82583a41 872 /*!
DiegoOstuni 0:75fc82583a41 873 *****************************************************************************
DiegoOstuni 0:75fc82583a41 874 * \brief RFAL Set FDT Poll
DiegoOstuni 0:75fc82583a41 875 *
DiegoOstuni 0:75fc82583a41 876 * Gets the current Frame Delay Time (FDT)
DiegoOstuni 0:75fc82583a41 877 *
DiegoOstuni 0:75fc82583a41 878 * FDT Poll is the minimum time following a Poll Frame during
DiegoOstuni 0:75fc82583a41 879 * which no subsequent Poll Frame can be sent (without a response from
DiegoOstuni 0:75fc82583a41 880 * the Listener in between)
DiegoOstuni 0:75fc82583a41 881 * FDTx,PP,MIN - Digital 1.1 6.10.2 & 7.9.2 & 8.7.2
DiegoOstuni 0:75fc82583a41 882 *
DiegoOstuni 0:75fc82583a41 883 * \return FDT : current FDT value in 1/fc cycles
DiegoOstuni 0:75fc82583a41 884 *
DiegoOstuni 0:75fc82583a41 885 *****************************************************************************
DiegoOstuni 0:75fc82583a41 886 */
DiegoOstuni 0:75fc82583a41 887 uint32_t rfalGetFDTPoll( void );
DiegoOstuni 0:75fc82583a41 888
DiegoOstuni 0:75fc82583a41 889
DiegoOstuni 0:75fc82583a41 890 /*!
DiegoOstuni 0:75fc82583a41 891 *****************************************************************************
DiegoOstuni 0:75fc82583a41 892 * \brief RFAL Set FDT Listen
DiegoOstuni 0:75fc82583a41 893 *
DiegoOstuni 0:75fc82583a41 894 * Sets the Frame Delay Time (FDT) Listen minimum to be used on the
DiegoOstuni 0:75fc82583a41 895 * following communications.
DiegoOstuni 0:75fc82583a41 896 *
DiegoOstuni 0:75fc82583a41 897 * FDT Listen is the minimum time between a Poll Frame and a Listen Frame
DiegoOstuni 0:75fc82583a41 898 * FDTx,LISTEN,MIN - Digital 1.1 6.10.1 & 7.9.1 & 8.7.1
DiegoOstuni 0:75fc82583a41 899 *
DiegoOstuni 0:75fc82583a41 900 * \param[in] fdt : Frame Delay Time in 1/fc cycles
DiegoOstuni 0:75fc82583a41 901 *
DiegoOstuni 0:75fc82583a41 902 *****************************************************************************
DiegoOstuni 0:75fc82583a41 903 */
DiegoOstuni 0:75fc82583a41 904 void rfalSetFDTListen( uint32_t fdt );
DiegoOstuni 0:75fc82583a41 905
DiegoOstuni 0:75fc82583a41 906
DiegoOstuni 0:75fc82583a41 907 /*!
DiegoOstuni 0:75fc82583a41 908 *****************************************************************************
DiegoOstuni 0:75fc82583a41 909 * \brief RFAL Set FDT Listen
DiegoOstuni 0:75fc82583a41 910 *
DiegoOstuni 0:75fc82583a41 911 * Gets the Frame Delay Time (FDT) Listen minimum
DiegoOstuni 0:75fc82583a41 912 *
DiegoOstuni 0:75fc82583a41 913 * FDT Listen is the minimum time between a Poll Frame and a Listen Frame
DiegoOstuni 0:75fc82583a41 914 * FDTx,LISTEN,MIN - Digital 1.1 6.10.1 & 7.9.1 & 8.7.1
DiegoOstuni 0:75fc82583a41 915 *
DiegoOstuni 0:75fc82583a41 916 * \return FDT : current FDT value in 1/fc cycles
DiegoOstuni 0:75fc82583a41 917 *
DiegoOstuni 0:75fc82583a41 918 *****************************************************************************
DiegoOstuni 0:75fc82583a41 919 */
DiegoOstuni 0:75fc82583a41 920 uint32_t rfalGetFDTListen( void );
DiegoOstuni 0:75fc82583a41 921
DiegoOstuni 0:75fc82583a41 922
DiegoOstuni 0:75fc82583a41 923 /*!
DiegoOstuni 0:75fc82583a41 924 *****************************************************************************
DiegoOstuni 0:75fc82583a41 925 * \brief RFAL Get GT
DiegoOstuni 0:75fc82583a41 926 *
DiegoOstuni 0:75fc82583a41 927 * Gets the current Guard Time (GT)
DiegoOstuni 0:75fc82583a41 928 *
DiegoOstuni 0:75fc82583a41 929 * GT is the minimum time when a device in Listen Mode is exposed to an
DiegoOstuni 0:75fc82583a41 930 * unmodulated carrier
DiegoOstuni 0:75fc82583a41 931 *
DiegoOstuni 0:75fc82583a41 932 * \return GT : Guard Time in 1/fc cycles
DiegoOstuni 0:75fc82583a41 933 *
DiegoOstuni 0:75fc82583a41 934 *****************************************************************************
DiegoOstuni 0:75fc82583a41 935 */
DiegoOstuni 0:75fc82583a41 936 uint32_t rfalGetGT( void );
DiegoOstuni 0:75fc82583a41 937
DiegoOstuni 0:75fc82583a41 938
DiegoOstuni 0:75fc82583a41 939 /*!
DiegoOstuni 0:75fc82583a41 940 *****************************************************************************
DiegoOstuni 0:75fc82583a41 941 * \brief RFAL Set GT
DiegoOstuni 0:75fc82583a41 942 *
DiegoOstuni 0:75fc82583a41 943 * Sets the Guard Time (GT) to be used on the following communications.
DiegoOstuni 0:75fc82583a41 944 *
DiegoOstuni 0:75fc82583a41 945 * GT is the minimum time when a device in Listen Mode is exposed to an
DiegoOstuni 0:75fc82583a41 946 * unmodulated carrier
DiegoOstuni 0:75fc82583a41 947 *
DiegoOstuni 0:75fc82583a41 948 * \param[in] gt : Guard Time in 1/fc cycles
DiegoOstuni 0:75fc82583a41 949 * RFAL_GT_NONE if no GT should be applied
DiegoOstuni 0:75fc82583a41 950 *
DiegoOstuni 0:75fc82583a41 951 *****************************************************************************
DiegoOstuni 0:75fc82583a41 952 */
DiegoOstuni 0:75fc82583a41 953 void rfalSetGT( uint32_t gt );
DiegoOstuni 0:75fc82583a41 954
DiegoOstuni 0:75fc82583a41 955
DiegoOstuni 0:75fc82583a41 956 /*!
DiegoOstuni 0:75fc82583a41 957 *****************************************************************************
DiegoOstuni 0:75fc82583a41 958 * \brief RFAL Is GT expired
DiegoOstuni 0:75fc82583a41 959 *
DiegoOstuni 0:75fc82583a41 960 * Checks whether the GT timer has expired
DiegoOstuni 0:75fc82583a41 961 *
DiegoOstuni 0:75fc82583a41 962 * \return true : GT has expired or not running
DiegoOstuni 0:75fc82583a41 963 * \return false : GT is still running
DiegoOstuni 0:75fc82583a41 964 *
DiegoOstuni 0:75fc82583a41 965 *****************************************************************************
DiegoOstuni 0:75fc82583a41 966 */
DiegoOstuni 0:75fc82583a41 967 bool rfalIsGTExpired( void );
DiegoOstuni 0:75fc82583a41 968
DiegoOstuni 0:75fc82583a41 969
DiegoOstuni 0:75fc82583a41 970 /*!
DiegoOstuni 0:75fc82583a41 971 *****************************************************************************
DiegoOstuni 0:75fc82583a41 972 * \brief RFAL Turn Field On and Start GT
DiegoOstuni 0:75fc82583a41 973 *
DiegoOstuni 0:75fc82583a41 974 * Turns the Field On, performing Initial Collision Avoidance
DiegoOstuni 0:75fc82583a41 975 *
DiegoOstuni 0:75fc82583a41 976 * After Field On, if GT was set before, it starts the GT timer to be
DiegoOstuni 0:75fc82583a41 977 * used on the following communications.
DiegoOstuni 0:75fc82583a41 978 *
DiegoOstuni 0:75fc82583a41 979 * \return ERR_RF_COLLISION : External field detected
DiegoOstuni 0:75fc82583a41 980 * \return ERR_NONE : Field turned On
DiegoOstuni 0:75fc82583a41 981 *
DiegoOstuni 0:75fc82583a41 982 *****************************************************************************
DiegoOstuni 0:75fc82583a41 983 */
DiegoOstuni 0:75fc82583a41 984 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 );
DiegoOstuni 0:75fc82583a41 985
DiegoOstuni 0:75fc82583a41 986
DiegoOstuni 0:75fc82583a41 987 /*!
DiegoOstuni 0:75fc82583a41 988 *****************************************************************************
DiegoOstuni 0:75fc82583a41 989 * \brief RFAL Turn Field Off
DiegoOstuni 0:75fc82583a41 990 *
DiegoOstuni 0:75fc82583a41 991 * Turns the Field Off
DiegoOstuni 0:75fc82583a41 992 *
DiegoOstuni 0:75fc82583a41 993 * \return ERR_NONE : Field turned Off
DiegoOstuni 0:75fc82583a41 994 *****************************************************************************
DiegoOstuni 0:75fc82583a41 995 */
DiegoOstuni 0:75fc82583a41 996 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 );
DiegoOstuni 0:75fc82583a41 997
DiegoOstuni 0:75fc82583a41 998
DiegoOstuni 0:75fc82583a41 999
DiegoOstuni 0:75fc82583a41 1000 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1001 * Transceive *
DiegoOstuni 0:75fc82583a41 1002 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1003
DiegoOstuni 0:75fc82583a41 1004 /*!
DiegoOstuni 0:75fc82583a41 1005 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1006 * \brief RFAL Set transceive context
DiegoOstuni 0:75fc82583a41 1007 *
DiegoOstuni 0:75fc82583a41 1008 * Set the context that will be used for the following Transceive
DiegoOstuni 0:75fc82583a41 1009 * Output and input buffers have to be passed and all other details prior to
DiegoOstuni 0:75fc82583a41 1010 * the Transceive itself has been started
DiegoOstuni 0:75fc82583a41 1011 *
DiegoOstuni 0:75fc82583a41 1012 * This method only sets the context, once set rfalWorker has
DiegoOstuni 0:75fc82583a41 1013 * to be executed until is done
DiegoOstuni 0:75fc82583a41 1014 *
DiegoOstuni 0:75fc82583a41 1015 * \param[in] ctx : the context for the following Transceive
DiegoOstuni 0:75fc82583a41 1016 *
DiegoOstuni 0:75fc82583a41 1017 * \see rfalWorker
DiegoOstuni 0:75fc82583a41 1018 * \see rfalGetTransceiveStatus
DiegoOstuni 0:75fc82583a41 1019 *
DiegoOstuni 0:75fc82583a41 1020 * \return ERR_NONE : Done with no error
DiegoOstuni 0:75fc82583a41 1021 * \return ERR_WRONG_STATE : Not initialized properly
DiegoOstuni 0:75fc82583a41 1022 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1023 */
DiegoOstuni 0:75fc82583a41 1024 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 );
DiegoOstuni 0:75fc82583a41 1025
DiegoOstuni 0:75fc82583a41 1026
DiegoOstuni 0:75fc82583a41 1027 /*!
DiegoOstuni 0:75fc82583a41 1028 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1029 * \brief Get Transceive State
DiegoOstuni 0:75fc82583a41 1030 *
DiegoOstuni 0:75fc82583a41 1031 * Gets current Transceive internal State
DiegoOstuni 0:75fc82583a41 1032 *
DiegoOstuni 0:75fc82583a41 1033 * \return rfalTransceiveState : the current Transceive internal State
DiegoOstuni 0:75fc82583a41 1034 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1035 */
DiegoOstuni 0:75fc82583a41 1036 rfalTransceiveState rfalGetTransceiveState( void );
DiegoOstuni 0:75fc82583a41 1037
DiegoOstuni 0:75fc82583a41 1038 /*!
DiegoOstuni 0:75fc82583a41 1039 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1040 * \brief Get Transceive Status
DiegoOstuni 0:75fc82583a41 1041 *
DiegoOstuni 0:75fc82583a41 1042 * Gets current Transceive status
DiegoOstuni 0:75fc82583a41 1043 *
DiegoOstuni 0:75fc82583a41 1044 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1045 * \return ERR_BUSY : Transceive ongoing
DiegoOstuni 0:75fc82583a41 1046 * \return ERR_XXXX : Error occurred
DiegoOstuni 0:75fc82583a41 1047 * \return ERR_TIMEOUT : No response
DiegoOstuni 0:75fc82583a41 1048 * \return ERR_FRAMING : Framing error detected
DiegoOstuni 0:75fc82583a41 1049 * \return ERR_PAR : Parity error detected
DiegoOstuni 0:75fc82583a41 1050 * \return ERR_CRC : CRC error detected
DiegoOstuni 0:75fc82583a41 1051 * \return ERR_LINK_LOSS : Link Loss - External Field is Off
DiegoOstuni 0:75fc82583a41 1052 * \return ERR_RF_COLLISION : Collision detected
DiegoOstuni 0:75fc82583a41 1053 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1054 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1055 */
DiegoOstuni 0:75fc82583a41 1056 ReturnCode rfalGetTransceiveStatus( void );
DiegoOstuni 0:75fc82583a41 1057
DiegoOstuni 0:75fc82583a41 1058
DiegoOstuni 0:75fc82583a41 1059 /*!
DiegoOstuni 0:75fc82583a41 1060 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1061 * \brief RFAL Worker
DiegoOstuni 0:75fc82583a41 1062 *
DiegoOstuni 0:75fc82583a41 1063 * This runs RFAL layer, which drives the actual Transceive procedure
DiegoOstuni 0:75fc82583a41 1064 * It MUST be executed frequently in order to execute the RFAL internal
DiegoOstuni 0:75fc82583a41 1065 * states and perform the requested operations
DiegoOstuni 0:75fc82583a41 1066 *
DiegoOstuni 0:75fc82583a41 1067 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1068 */
DiegoOstuni 0:75fc82583a41 1069 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 );
DiegoOstuni 0:75fc82583a41 1070
DiegoOstuni 0:75fc82583a41 1071
DiegoOstuni 0:75fc82583a41 1072 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1073 * ISO1443A *
DiegoOstuni 0:75fc82583a41 1074 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1075
DiegoOstuni 0:75fc82583a41 1076 /*!
DiegoOstuni 0:75fc82583a41 1077 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1078 * \brief Transceives an ISO14443A ShortFrame
DiegoOstuni 0:75fc82583a41 1079 *
DiegoOstuni 0:75fc82583a41 1080 * Sends REQA to detect if there is any PICC in the field
DiegoOstuni 0:75fc82583a41 1081 *
DiegoOstuni 0:75fc82583a41 1082 * \param[in] txCmd: Command to be sent:
DiegoOstuni 0:75fc82583a41 1083 * 0x52 WUPA / ALL_REQ
DiegoOstuni 0:75fc82583a41 1084 * 0x26 REQA / SENS_REQ
DiegoOstuni 0:75fc82583a41 1085 *
DiegoOstuni 0:75fc82583a41 1086 * \param[in] txCmd : type of short frame to be sent REQA or WUPA
DiegoOstuni 0:75fc82583a41 1087 * \param[out] rxBuf : buffer to place the response
DiegoOstuni 0:75fc82583a41 1088 * \param[in] rxBufLen : length of rxBuf
DiegoOstuni 0:75fc82583a41 1089 * \param[out] rxRcvdLen: received length
DiegoOstuni 0:75fc82583a41 1090 * \param[in] fwt : Frame Waiting Time in 1/fc
DiegoOstuni 0:75fc82583a41 1091 *
DiegoOstuni 0:75fc82583a41 1092 * \warning If fwt is set to RFAL_FWT_NONE it will make endlessly for
DiegoOstuni 0:75fc82583a41 1093 * a response, which on a blocking method may not be the
DiegoOstuni 0:75fc82583a41 1094 * desired usage
DiegoOstuni 0:75fc82583a41 1095 *
DiegoOstuni 0:75fc82583a41 1096 * \return ERR_NONE if there is response
DiegoOstuni 0:75fc82583a41 1097 * \return ERR_TIMEOUT if there is no response
DiegoOstuni 0:75fc82583a41 1098 * \return ERR_COLLISION collision has occurred
DiegoOstuni 0:75fc82583a41 1099 *
DiegoOstuni 0:75fc82583a41 1100 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1101 */
DiegoOstuni 0:75fc82583a41 1102 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 );
DiegoOstuni 0:75fc82583a41 1103
DiegoOstuni 0:75fc82583a41 1104
DiegoOstuni 0:75fc82583a41 1105 /*!
DiegoOstuni 0:75fc82583a41 1106 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1107 * \brief Sends an ISO14443A Anticollision Frame
DiegoOstuni 0:75fc82583a41 1108 *
DiegoOstuni 0:75fc82583a41 1109 * This is use to perform ISO14443A anti-collision.
DiegoOstuni 0:75fc82583a41 1110 * \note Anticollision is sent without CRC
DiegoOstuni 0:75fc82583a41 1111 *
DiegoOstuni 0:75fc82583a41 1112 *
DiegoOstuni 0:75fc82583a41 1113 * \param[in] buf : reference to ANTICOLLISION command (with known UID if any) to be sent (also out param)
DiegoOstuni 0:75fc82583a41 1114 * reception will be place on this buf after bytesToSend
DiegoOstuni 0:75fc82583a41 1115 * \param[in] bytesToSend: reference number of full bytes to be sent (including CMD byte and SEL_PAR)
DiegoOstuni 0:75fc82583a41 1116 * if a collision occurs will contain the number of clear bytes
DiegoOstuni 0:75fc82583a41 1117 * \param[in] bitsToSend : reference to number of bits (0-7) to be sent; and received (also out param)
DiegoOstuni 0:75fc82583a41 1118 * if a collision occurs will indicate the number of clear bits (also out param)
DiegoOstuni 0:75fc82583a41 1119 * \param[out] rxLength : reference to the return the received length
DiegoOstuni 0:75fc82583a41 1120 * \param[in] fwt : Frame Waiting Time in 1/fc
DiegoOstuni 0:75fc82583a41 1121 *
DiegoOstuni 0:75fc82583a41 1122 * \return ERR_NONE if there is no error
DiegoOstuni 0:75fc82583a41 1123 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1124 */
DiegoOstuni 0:75fc82583a41 1125 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 );
DiegoOstuni 0:75fc82583a41 1126
DiegoOstuni 0:75fc82583a41 1127
DiegoOstuni 0:75fc82583a41 1128 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1129 * FeliCa *
DiegoOstuni 0:75fc82583a41 1130 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1131
DiegoOstuni 0:75fc82583a41 1132 /*!
DiegoOstuni 0:75fc82583a41 1133 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1134 * \brief FeliCa Poll
DiegoOstuni 0:75fc82583a41 1135 *
DiegoOstuni 0:75fc82583a41 1136 * Sends a Poll Request and collects all Poll Responses according to the
DiegoOstuni 0:75fc82583a41 1137 * given slots
DiegoOstuni 0:75fc82583a41 1138 *
DiegoOstuni 0:75fc82583a41 1139 *
DiegoOstuni 0:75fc82583a41 1140 * \param[in] slots : number of slots for the Poll Request
DiegoOstuni 0:75fc82583a41 1141 * \param[in] sysCode : system code (SC) for the Poll Request
DiegoOstuni 0:75fc82583a41 1142 * \param[in] reqCode : request code (RC) for the Poll Request
DiegoOstuni 0:75fc82583a41 1143 * \param[out] pollResList : list of all responses
DiegoOstuni 0:75fc82583a41 1144 * \param[in] pollResListSize : number of responses that can be placed in pollResList
DiegoOstuni 0:75fc82583a41 1145 * \param[out] devicesDetected : number of cards found
DiegoOstuni 0:75fc82583a41 1146 * \param[out] collisionsDetected: number of collisions detected
DiegoOstuni 0:75fc82583a41 1147 *
DiegoOstuni 0:75fc82583a41 1148 * \return ERR_NONE if there is no error
DiegoOstuni 0:75fc82583a41 1149 * \return ERR_TIMEOUT if there is no response
DiegoOstuni 0:75fc82583a41 1150 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1151 */
DiegoOstuni 0:75fc82583a41 1152 ReturnCode rfalFeliCaPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint8_t reqCode, rfalFeliCaPollRes* pollResList,
DiegoOstuni 0:75fc82583a41 1153 uint8_t pollResListSize, uint8_t *devicesDetected,
DiegoOstuni 0:75fc82583a41 1154 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 );
DiegoOstuni 0:75fc82583a41 1155
DiegoOstuni 0:75fc82583a41 1156
DiegoOstuni 0:75fc82583a41 1157 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1158 * ISO15693 *
DiegoOstuni 0:75fc82583a41 1159 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1160
DiegoOstuni 0:75fc82583a41 1161 /*!
DiegoOstuni 0:75fc82583a41 1162 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1163 * \brief Sends an ISO15693 Anticollision Frame
DiegoOstuni 0:75fc82583a41 1164 *
DiegoOstuni 0:75fc82583a41 1165 * This send the Anticollision|Inventory frame (INVENTORY_REQ)
DiegoOstuni 0:75fc82583a41 1166 *
DiegoOstuni 0:75fc82583a41 1167 * \warning rxBuf must be able to contain the payload and CRC
DiegoOstuni 0:75fc82583a41 1168 *
DiegoOstuni 0:75fc82583a41 1169 * \param[in] txBuf : Buffer where outgoing message is located
DiegoOstuni 0:75fc82583a41 1170 * \param[in] txBufLen : Length of the outgoing message in bytes
DiegoOstuni 0:75fc82583a41 1171 * \param[out] rxBuf : Buffer where incoming message will be placed
DiegoOstuni 0:75fc82583a41 1172 * \param[in] rxBufLen : Maximum length of the incoming message in bytes
DiegoOstuni 0:75fc82583a41 1173 * \param[out] actLen : Actual received length in bits
DiegoOstuni 0:75fc82583a41 1174 *
DiegoOstuni 0:75fc82583a41 1175 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1176 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 1177 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1178 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1179 */
DiegoOstuni 0:75fc82583a41 1180 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 );
DiegoOstuni 0:75fc82583a41 1181
DiegoOstuni 0:75fc82583a41 1182
DiegoOstuni 0:75fc82583a41 1183 /*!
DiegoOstuni 0:75fc82583a41 1184 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1185 * \brief Sends an ISO15693 Anticollision EOF
DiegoOstuni 0:75fc82583a41 1186 *
DiegoOstuni 0:75fc82583a41 1187 * This sends the Anticollision|Inventory EOF used as a slot marker
DiegoOstuni 0:75fc82583a41 1188 *
DiegoOstuni 0:75fc82583a41 1189 * \warning rxBuf must be able to contain the payload and CRC
DiegoOstuni 0:75fc82583a41 1190 *
DiegoOstuni 0:75fc82583a41 1191 * \param[out] rxBuf : Buffer where incoming message will be placed
DiegoOstuni 0:75fc82583a41 1192 * \param[in] rxBufLen : Maximum length of the incoming message in bytes
DiegoOstuni 0:75fc82583a41 1193 * \param[out] actLen : Actual received length in bits
DiegoOstuni 0:75fc82583a41 1194 *
DiegoOstuni 0:75fc82583a41 1195 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1196 * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
DiegoOstuni 0:75fc82583a41 1197 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1198 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1199 */
DiegoOstuni 0:75fc82583a41 1200 ReturnCode rfalISO15693TransceiveAnticollisionEOF( uint8_t *rxBuf, uint8_t rxBufLen, uint16_t *actLen, SPI* mspiChannel,
DiegoOstuni 0:75fc82583a41 1201 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 1202
DiegoOstuni 0:75fc82583a41 1203
DiegoOstuni 0:75fc82583a41 1204 /*!
DiegoOstuni 0:75fc82583a41 1205 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1206 * \brief Sends an ISO15693 Slot Marker
DiegoOstuni 0:75fc82583a41 1207 *
DiegoOstuni 0:75fc82583a41 1208 * This is method sends an ISO15693 (EoF) used for a Write operation
DiegoOstuni 0:75fc82583a41 1209 *
DiegoOstuni 0:75fc82583a41 1210 * \warning rxBuf must be able to contain the payload and CRC
DiegoOstuni 0:75fc82583a41 1211 *
DiegoOstuni 0:75fc82583a41 1212 * \param[out] rxBuf : Buffer where incoming message will be placed
DiegoOstuni 0:75fc82583a41 1213 * \param[in] rxBufLen : Maximum length of the incoming message in bytes
DiegoOstuni 0:75fc82583a41 1214 * \param[out] actLen : Actual received length in bytes
DiegoOstuni 0:75fc82583a41 1215 *
DiegoOstuni 0:75fc82583a41 1216 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1217 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1218 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1219 */
DiegoOstuni 0:75fc82583a41 1220 ReturnCode rfalISO15693TransceiveEOF( uint8_t *rxBuf, uint8_t rxBufLen, uint16_t *actLen, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ );
DiegoOstuni 0:75fc82583a41 1221
DiegoOstuni 0:75fc82583a41 1222
DiegoOstuni 0:75fc82583a41 1223 /*!
DiegoOstuni 0:75fc82583a41 1224 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1225 * \brief Transceive Blocking Tx
DiegoOstuni 0:75fc82583a41 1226 *
DiegoOstuni 0:75fc82583a41 1227 * This is method triggers a Transceive and executes it blocking until the
DiegoOstuni 0:75fc82583a41 1228 * Tx has been completed
DiegoOstuni 0:75fc82583a41 1229 *
DiegoOstuni 0:75fc82583a41 1230 * \param[in] txBuf : Buffer where outgoing message is located
DiegoOstuni 0:75fc82583a41 1231 * \param[in] txBufLen : Length of the outgoing message in bytes
DiegoOstuni 0:75fc82583a41 1232 * \param[out] rxBuf : Buffer where incoming message will be placed
DiegoOstuni 0:75fc82583a41 1233 * \param[in] rxBufLen : Maximum length of the incoming message in bytes
DiegoOstuni 0:75fc82583a41 1234 * \param[out] actLen : Actual received length in bits
DiegoOstuni 0:75fc82583a41 1235 * \param[in] flags : TransceiveFlags indication special handling
DiegoOstuni 0:75fc82583a41 1236 * \param[in] fwt : Frame Waiting Time in 1/fc
DiegoOstuni 0:75fc82583a41 1237 *
DiegoOstuni 0:75fc82583a41 1238 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1239 * \return ERR_BUSY : Transceive ongoing
DiegoOstuni 0:75fc82583a41 1240 * \return ERR_XXXX : Error occurred
DiegoOstuni 0:75fc82583a41 1241 * \return ERR_LINK_LOSS : Link Loss - External Field is Off
DiegoOstuni 0:75fc82583a41 1242 * \return ERR_RF_COLLISION : Collision detected
DiegoOstuni 0:75fc82583a41 1243 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1244 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1245 */
DiegoOstuni 0:75fc82583a41 1246 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 );
DiegoOstuni 0:75fc82583a41 1247
DiegoOstuni 0:75fc82583a41 1248 /*!
DiegoOstuni 0:75fc82583a41 1249 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1250 * \brief Transceive Blocking Rx
DiegoOstuni 0:75fc82583a41 1251 *
DiegoOstuni 0:75fc82583a41 1252 * This is method executes the reception of an ongoing Transceive triggered
DiegoOstuni 0:75fc82583a41 1253 * before by rfalTransceiveBlockingTx()
DiegoOstuni 0:75fc82583a41 1254 *
DiegoOstuni 0:75fc82583a41 1255 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1256 * \return ERR_BUSY : Transceive ongoing
DiegoOstuni 0:75fc82583a41 1257 * \return ERR_XXXX : Error occurred
DiegoOstuni 0:75fc82583a41 1258 * \return ERR_TIMEOUT : No response
DiegoOstuni 0:75fc82583a41 1259 * \return ERR_FRAMING : Framing error detected
DiegoOstuni 0:75fc82583a41 1260 * \return ERR_PAR : Parity error detected
DiegoOstuni 0:75fc82583a41 1261 * \return ERR_CRC : CRC error detected
DiegoOstuni 0:75fc82583a41 1262 * \return ERR_LINK_LOSS : Link Loss - External Field is Off
DiegoOstuni 0:75fc82583a41 1263 * \return ERR_RF_COLLISION : Collision detected
DiegoOstuni 0:75fc82583a41 1264 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1265 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1266 */
DiegoOstuni 0:75fc82583a41 1267 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 );
DiegoOstuni 0:75fc82583a41 1268
DiegoOstuni 0:75fc82583a41 1269 /*!
DiegoOstuni 0:75fc82583a41 1270 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1271 * \brief Transceive Blocking
DiegoOstuni 0:75fc82583a41 1272 *
DiegoOstuni 0:75fc82583a41 1273 * This is method triggers a Transceive and executes it blocking until it
DiegoOstuni 0:75fc82583a41 1274 * has been completed
DiegoOstuni 0:75fc82583a41 1275 *
DiegoOstuni 0:75fc82583a41 1276 * \param[in] txBuf : Buffer where outgoing message is located
DiegoOstuni 0:75fc82583a41 1277 * \param[in] txBufLen : Length of the outgoing message in bytes
DiegoOstuni 0:75fc82583a41 1278 * \param[out] rxBuf : Buffer where incoming message will be placed
DiegoOstuni 0:75fc82583a41 1279 * \param[in] rxBufLen : Maximum length of the incoming message in bytes
DiegoOstuni 0:75fc82583a41 1280 * \param[out] actLen : Actual received length in bytes
DiegoOstuni 0:75fc82583a41 1281 * \param[in] flags : TransceiveFlags indication special handling
DiegoOstuni 0:75fc82583a41 1282 * \param[in] fwt : Frame Waiting Time in 1/fc
DiegoOstuni 0:75fc82583a41 1283 *
DiegoOstuni 0:75fc82583a41 1284 * \return ERR_NONE : Transceive done with no error
DiegoOstuni 0:75fc82583a41 1285 * \return ERR_BUSY : Transceive ongoing
DiegoOstuni 0:75fc82583a41 1286 * \return ERR_XXXX : Error occurred
DiegoOstuni 0:75fc82583a41 1287 * \return ERR_TIMEOUT : No response
DiegoOstuni 0:75fc82583a41 1288 * \return ERR_FRAMING : Framing error detected
DiegoOstuni 0:75fc82583a41 1289 * \return ERR_PAR : Parity error detected
DiegoOstuni 0:75fc82583a41 1290 * \return ERR_CRC : CRC error detected
DiegoOstuni 0:75fc82583a41 1291 * \return ERR_LINK_LOSS : Link Loss - External Field is Off
DiegoOstuni 0:75fc82583a41 1292 * \return ERR_RF_COLLISION : Collision detected
DiegoOstuni 0:75fc82583a41 1293 * \return ERR_IO : Internal error
DiegoOstuni 0:75fc82583a41 1294 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1295 */
DiegoOstuni 0:75fc82583a41 1296 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 );
DiegoOstuni 0:75fc82583a41 1297
DiegoOstuni 0:75fc82583a41 1298
DiegoOstuni 0:75fc82583a41 1299
DiegoOstuni 0:75fc82583a41 1300 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1301 * Listen Mode *
DiegoOstuni 0:75fc82583a41 1302 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1303
DiegoOstuni 0:75fc82583a41 1304 /*!
DiegoOstuni 0:75fc82583a41 1305 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1306 * \brief Is external Field On
DiegoOstuni 0:75fc82583a41 1307 *
DiegoOstuni 0:75fc82583a41 1308 * Checks if external field (other peer/device) is on/detected
DiegoOstuni 0:75fc82583a41 1309 *
DiegoOstuni 0:75fc82583a41 1310 *
DiegoOstuni 0:75fc82583a41 1311 *
DiegoOstuni 0:75fc82583a41 1312 * \return true External field is On
DiegoOstuni 0:75fc82583a41 1313 * \return false No external field is detected
DiegoOstuni 0:75fc82583a41 1314 *
DiegoOstuni 0:75fc82583a41 1315 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1316 */
DiegoOstuni 0:75fc82583a41 1317 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 );
DiegoOstuni 0:75fc82583a41 1318
DiegoOstuni 0:75fc82583a41 1319
DiegoOstuni 0:75fc82583a41 1320 /*!
DiegoOstuni 0:75fc82583a41 1321 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1322 * \brief Listen Mode start
DiegoOstuni 0:75fc82583a41 1323 *
DiegoOstuni 0:75fc82583a41 1324 * Configures RF Chip to go into listen mode enabling the given technologies
DiegoOstuni 0:75fc82583a41 1325 *
DiegoOstuni 0:75fc82583a41 1326 *
DiegoOstuni 0:75fc82583a41 1327 * \param[in] lmMask: mask with the enabled/disabled listen modes
DiegoOstuni 0:75fc82583a41 1328 * use: RFAL_LM_MASK_NFCA ; RFAL_LM_MASK_NFCB ;
DiegoOstuni 0:75fc82583a41 1329 * RFAL_LM_MASK_NFCF ; RFAL_LM_MASK_ACTIVE_P2P
DiegoOstuni 0:75fc82583a41 1330 * \param[in] confA: pointer to Passive A configurations (NULL if disabled)
DiegoOstuni 0:75fc82583a41 1331 * \param[in] confB: pointer to Passive B configurations (NULL if disabled)
DiegoOstuni 0:75fc82583a41 1332 * \param[in] confF: pointer to Passive F configurations (NULL if disabled)
DiegoOstuni 0:75fc82583a41 1333 * \param[in] rxBuf: buffer to place incoming data
DiegoOstuni 0:75fc82583a41 1334 * \param[in] rxBufLen: length in bits of rxBuf
DiegoOstuni 0:75fc82583a41 1335 * \param[in] rxLen: pointer to write the data length in bits placed into rxBuf
DiegoOstuni 0:75fc82583a41 1336 *
DiegoOstuni 0:75fc82583a41 1337 *
DiegoOstuni 0:75fc82583a41 1338 * \return ERR_PARAM Invalid parameter
DiegoOstuni 0:75fc82583a41 1339 * \return ERR_REQUEST Invalid listen mode mask
DiegoOstuni 0:75fc82583a41 1340 * \return ERR_NONE Done with no error
DiegoOstuni 0:75fc82583a41 1341 *
DiegoOstuni 0:75fc82583a41 1342 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1343 */
DiegoOstuni 0:75fc82583a41 1344 ReturnCode rfalListenStart( uint32_t lmMask, rfalLmConfPA *confA, rfalLmConfPB *confB, rfalLmConfPF *confF, uint8_t *rxBuf,
DiegoOstuni 0:75fc82583a41 1345 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 );
DiegoOstuni 0:75fc82583a41 1346
DiegoOstuni 0:75fc82583a41 1347
DiegoOstuni 0:75fc82583a41 1348 /*!
DiegoOstuni 0:75fc82583a41 1349 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1350 * \brief Listen Mode start Sleeping
DiegoOstuni 0:75fc82583a41 1351 *
DiegoOstuni 0:75fc82583a41 1352 *
DiegoOstuni 0:75fc82583a41 1353 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1354 */
DiegoOstuni 0:75fc82583a41 1355 ReturnCode rfalListenSleepStart( rfalLmState sleepSt, uint8_t *rxBuf, uint16_t rxBufLen, uint16_t *rxLen );
DiegoOstuni 0:75fc82583a41 1356
DiegoOstuni 0:75fc82583a41 1357
DiegoOstuni 0:75fc82583a41 1358 /*!
DiegoOstuni 0:75fc82583a41 1359 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1360 * \brief Listen Mode Stop
DiegoOstuni 0:75fc82583a41 1361 *
DiegoOstuni 0:75fc82583a41 1362 * Disables the listen mode on the RF Chip
DiegoOstuni 0:75fc82583a41 1363 *
DiegoOstuni 0:75fc82583a41 1364 * \warning the listen mode will be disabled immediately on the RFchip regardless
DiegoOstuni 0:75fc82583a41 1365 * of any ongoing operations like Transceive
DiegoOstuni 0:75fc82583a41 1366 *
DiegoOstuni 0:75fc82583a41 1367 * \return ERR_NONE Done with no error
DiegoOstuni 0:75fc82583a41 1368 *
DiegoOstuni 0:75fc82583a41 1369 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1370 */
DiegoOstuni 0:75fc82583a41 1371 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 );
DiegoOstuni 0:75fc82583a41 1372
DiegoOstuni 0:75fc82583a41 1373
DiegoOstuni 0:75fc82583a41 1374 /*!
DiegoOstuni 0:75fc82583a41 1375 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1376 * \brief Listen Mode get state
DiegoOstuni 0:75fc82583a41 1377 *
DiegoOstuni 0:75fc82583a41 1378 * Sets the new state of the Listen Mode and applies the necessary changes
DiegoOstuni 0:75fc82583a41 1379 * on the RF Chip
DiegoOstuni 0:75fc82583a41 1380 *
DiegoOstuni 0:75fc82583a41 1381 * \param[out] dataFlag: indicates that Listen Mode has rcvd data and caller
DiegoOstuni 0:75fc82583a41 1382 * must process it. The received message is located
DiegoOstuni 0:75fc82583a41 1383 * at the rxBuf passed on rfalListenStart()
DiegoOstuni 0:75fc82583a41 1384 * rfalListenSetState() will clear this flag
DiegoOstuni 0:75fc82583a41 1385 * if NULL output parameter will no be written/returned
DiegoOstuni 0:75fc82583a41 1386 * \param[out] lastBR: bit rate detected of the last initiator request
DiegoOstuni 0:75fc82583a41 1387 * if NULL output parameter will no be written/returned
DiegoOstuni 0:75fc82583a41 1388 *
DiegoOstuni 0:75fc82583a41 1389 * \return rfalLmState RFAL_LM_STATE_NOT_INIT : LM not initialized properly
DiegoOstuni 0:75fc82583a41 1390 * Any Other : LM State
DiegoOstuni 0:75fc82583a41 1391 *
DiegoOstuni 0:75fc82583a41 1392 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1393 */
DiegoOstuni 0:75fc82583a41 1394 rfalLmState rfalListenGetState( bool *dataFlag, rfalBitRate *lastBR );
DiegoOstuni 0:75fc82583a41 1395
DiegoOstuni 0:75fc82583a41 1396
DiegoOstuni 0:75fc82583a41 1397 /*!
DiegoOstuni 0:75fc82583a41 1398 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1399 * \brief Listen Mode set state
DiegoOstuni 0:75fc82583a41 1400 *
DiegoOstuni 0:75fc82583a41 1401 * Sets the new state of the Listen Mode and applies the necessary changes
DiegoOstuni 0:75fc82583a41 1402 * on the RF Chip
DiegoOstuni 0:75fc82583a41 1403 *
DiegoOstuni 0:75fc82583a41 1404 * \param[in] newSt : New state to go to
DiegoOstuni 0:75fc82583a41 1405 *
DiegoOstuni 0:75fc82583a41 1406 * \return ERR_WRONG_STATE : Not initialized properly
DiegoOstuni 0:75fc82583a41 1407 * \return ERR_PARAM : Invalid parameter
DiegoOstuni 0:75fc82583a41 1408 * \return ERR_NONE : Done with no error
DiegoOstuni 0:75fc82583a41 1409 *
DiegoOstuni 0:75fc82583a41 1410 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1411 */
DiegoOstuni 0:75fc82583a41 1412 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 );
DiegoOstuni 0:75fc82583a41 1413
DiegoOstuni 0:75fc82583a41 1414
DiegoOstuni 0:75fc82583a41 1415 /*****************************************************************************
DiegoOstuni 0:75fc82583a41 1416 * Wake-Up Mode *
DiegoOstuni 0:75fc82583a41 1417 *****************************************************************************/
DiegoOstuni 0:75fc82583a41 1418
DiegoOstuni 0:75fc82583a41 1419 /*!
DiegoOstuni 0:75fc82583a41 1420 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1421 * \brief Wake-Up Mode Start
DiegoOstuni 0:75fc82583a41 1422 *
DiegoOstuni 0:75fc82583a41 1423 * Sets the RF Chip in Low Power Wake-Up Mode according to the given
DiegoOstuni 0:75fc82583a41 1424 * configuration.
DiegoOstuni 0:75fc82583a41 1425 *
DiegoOstuni 0:75fc82583a41 1426 * \param[in] config : Generic Wake-Up configuration provided by lower
DiegoOstuni 0:75fc82583a41 1427 * layers. If NULL will automatically configure the
DiegoOstuni 0:75fc82583a41 1428 * Wake-Up mode
DiegoOstuni 0:75fc82583a41 1429 *
DiegoOstuni 0:75fc82583a41 1430 * \return ERR_WRONG_STATE : Not initialized properly
DiegoOstuni 0:75fc82583a41 1431 * \return ERR_PARAM : Invalid parameter
DiegoOstuni 0:75fc82583a41 1432 * \return ERR_NONE : Done with no error
DiegoOstuni 0:75fc82583a41 1433 *
DiegoOstuni 0:75fc82583a41 1434 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1435 */
DiegoOstuni 0:75fc82583a41 1436 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 );
DiegoOstuni 0:75fc82583a41 1437
DiegoOstuni 0:75fc82583a41 1438
DiegoOstuni 0:75fc82583a41 1439 /*!
DiegoOstuni 0:75fc82583a41 1440 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1441 * \brief Wake-Up Has Woke
DiegoOstuni 0:75fc82583a41 1442 *
DiegoOstuni 0:75fc82583a41 1443 * Returns true if the Wake-Up mode is enabled and it has already received
DiegoOstuni 0:75fc82583a41 1444 * the indication from the RF Chip that the surrounding environment has changed
DiegoOstuni 0:75fc82583a41 1445 * and flagged at least one wake-Up interrupt
DiegoOstuni 0:75fc82583a41 1446 *
DiegoOstuni 0:75fc82583a41 1447 * \return true : Wake-Up mode enabled and has received a wake-up IRQ
DiegoOstuni 0:75fc82583a41 1448 * \return false : no Wake-Up IRQ has been received
DiegoOstuni 0:75fc82583a41 1449 *
DiegoOstuni 0:75fc82583a41 1450 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1451 */
DiegoOstuni 0:75fc82583a41 1452 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 );
DiegoOstuni 0:75fc82583a41 1453
DiegoOstuni 0:75fc82583a41 1454
DiegoOstuni 0:75fc82583a41 1455 /*!
DiegoOstuni 0:75fc82583a41 1456 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1457 * \brief Wake-Up Mode Stop
DiegoOstuni 0:75fc82583a41 1458 *
DiegoOstuni 0:75fc82583a41 1459 * Stops the Wake-Up Mode
DiegoOstuni 0:75fc82583a41 1460 *
DiegoOstuni 0:75fc82583a41 1461 * \return ERR_WRONG_STATE : Not initialized properly
DiegoOstuni 0:75fc82583a41 1462 * \return ERR_PARAM : Invalid parameter
DiegoOstuni 0:75fc82583a41 1463 * \return ERR_NONE : Done with no error
DiegoOstuni 0:75fc82583a41 1464 *
DiegoOstuni 0:75fc82583a41 1465 *****************************************************************************
DiegoOstuni 0:75fc82583a41 1466 */
DiegoOstuni 0:75fc82583a41 1467 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 );
DiegoOstuni 0:75fc82583a41 1468
DiegoOstuni 0:75fc82583a41 1469
DiegoOstuni 0:75fc82583a41 1470 void rfalSetWumState( void );
DiegoOstuni 0:75fc82583a41 1471
DiegoOstuni 0:75fc82583a41 1472
DiegoOstuni 0:75fc82583a41 1473 #endif /* RFAL_RF_H */
DiegoOstuni 0:75fc82583a41 1474
DiegoOstuni 0:75fc82583a41 1475
DiegoOstuni 0:75fc82583a41 1476 /**
DiegoOstuni 0:75fc82583a41 1477 * @}
DiegoOstuni 0:75fc82583a41 1478 *
DiegoOstuni 0:75fc82583a41 1479 * @}
DiegoOstuni 0:75fc82583a41 1480 *
DiegoOstuni 0:75fc82583a41 1481 * @}
DiegoOstuni 0:75fc82583a41 1482 */