ST Expansion SW Team / RFAL

Dependents:   mbed-os-nfc05a1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rfal_st25tb.h Source File

rfal_st25tb.h

Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003   * @attention
00004   *
00005   * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
00006   *
00007   * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
00008   * You may not use this file except in compliance with the License.
00009   * You may obtain a copy of the License at:
00010   *
00011   *        http://www.st.com/myliberty
00012   *
00013   * Unless required by applicable law or agreed to in writing, software
00014   * distributed under the License is distributed on an "AS IS" BASIS,
00015   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
00016   * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
00017   * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
00018   * See the License for the specific language governing permissions and
00019   * limitations under the License.
00020   *
00021 ******************************************************************************/
00022 
00023 /*
00024  *      PROJECT:   ST25R391x firmware
00025  *      $Revision: $
00026  *      LANGUAGE:  ISO C99
00027  */
00028 
00029 /*! \file rfal_st25tb.h
00030  *
00031  *  \author Gustavo Patricio
00032  *
00033  *  \brief Implementation of ST25TB interface
00034  *
00035  *
00036  * @addtogroup RFAL
00037  * @{
00038  *
00039  * @addtogroup RFAL-AL
00040  * @brief RFAL Abstraction Layer
00041  * @{
00042  *
00043  * @addtogroup ST25TB
00044  * @brief RFAL ST25TB Module
00045  * @{
00046  *
00047  */
00048 
00049 
00050 #ifndef RFAL_ST25TB_H
00051 #define RFAL_ST25TB_H
00052 
00053 /*
00054  ******************************************************************************
00055  * INCLUDES
00056  ******************************************************************************
00057  */
00058 #include "platform1.h"
00059 #include "st_errno.h"
00060 #include "rfal_rf.h"
00061 #include "rfal_nfcb.h"
00062 
00063 /*
00064  ******************************************************************************
00065  * GLOBAL DEFINES
00066  ******************************************************************************
00067  */
00068 
00069 #define RFAL_ST25TB_CHIP_ID_LEN      1       /*!< ST25TB chip ID length       */
00070 #define RFAL_ST25TB_CRC_LEN          2       /*!< ST25TB CRC length           */
00071 #define RFAL_ST25TB_UID_LEN          8       /*!< ST25TB Unique ID length     */
00072 #define RFAL_ST25TB_BLOCK_LEN        4       /*!< ST25TB Data Block length    */
00073 
00074 /*
00075 ******************************************************************************
00076 * GLOBAL MACROS
00077 ******************************************************************************
00078 */
00079 
00080 
00081 
00082 /*
00083 ******************************************************************************
00084 * GLOBAL TYPES
00085 ******************************************************************************
00086 */
00087 typedef uint8_t rfalSt25tbUID [RFAL_ST25TB_UID_LEN];        /*!< ST25TB UID type          */
00088 typedef uint8_t rfalSt25tbBlock [RFAL_ST25TB_BLOCK_LEN];    /*!< ST25TB Block type        */
00089 
00090 
00091 /*! ST25TB listener device (PICC) struct  */
00092 typedef struct
00093 {
00094     uint8_t           chipID ;                              /*!< Device's session Chip ID */
00095     rfalSt25tbUID      UID ;                                 /*!< Device's UID             */
00096     bool              isDeselected ;                        /*!< Device deselect flag     */
00097 }rfalSt25tbListenDevice ;
00098 
00099 
00100 /*
00101 ******************************************************************************
00102 * GLOBAL FUNCTION PROTOTYPES
00103 ******************************************************************************
00104 */
00105 
00106 /*!
00107  *****************************************************************************
00108  * \brief  Initialize ST25TB Poller mode
00109  *
00110  * This methods configures RFAL RF layer to perform as a
00111  * ST25TB Poller/RW including all default timings
00112  *
00113  * \return ERR_WRONG_STATE  : RFAL not initialized or mode not set
00114  * \return ERR_NONE         : No error
00115  *****************************************************************************
00116  */
00117 ReturnCode rfalSt25tbPollerInitialize( 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 );
00118 
00119 
00120 /*!
00121  *****************************************************************************
00122  * \brief  ST25TB Poller Check Presence
00123  *
00124  * This method checks if a ST25TB Listen device (PICC) is present on the field
00125  * by sending an Initiate command
00126  *
00127  * \param[out] chipId : if successfully retrieved, the device's chip ID
00128  *
00129  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00130  * \return ERR_PARAM        : Invalid parameters
00131  * \return ERR_IO           : Generic internal error
00132  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00133  * \return ERR_RF_COLLISION : Collision detected one or more device in the field
00134  * \return ERR_PROTO        : Protocol error detected
00135  * \return ERR_NONE         : No error
00136  *****************************************************************************
00137  */
00138 ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId, 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 );
00139 
00140 
00141 /*!
00142  *****************************************************************************
00143  * \brief  ST25TB Poller Collision Resolution
00144  *
00145  * This method performs ST25TB Collision resolution, selects the each device,
00146  * retrieves its UID and then deselects.
00147  * In case only one device is identified the ST25TB device is left in select
00148  * state.
00149  *
00150  * \param[in]  devLimit      : device limit value, and size st25tbDevList
00151  * \param[out] st25tbDevList : ST35TB listener device info
00152  * \param[out] devCnt        : Devices found counter
00153  *
00154  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00155  * \return ERR_PARAM        : Invalid parameters
00156  * \return ERR_IO           : Generic internal error
00157  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00158  * \return ERR_RF_COLLISION : Collision detected one or more device in the field
00159  * \return ERR_PROTO        : Protocol error detected
00160  * \return ERR_NONE         : No error
00161  *****************************************************************************
00162  */
00163 ReturnCode rfalSt25tbPollerCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice  *st25tbDevList, uint8_t *devCnt,SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 );
00164 
00165 /*!
00166  *****************************************************************************
00167  * \brief  ST25TB Poller Initiate
00168  *
00169  * This method sends an Initiate command
00170  *
00171  * If a single device responds the chip ID will be retrieved
00172  *
00173  * \param[out]  chipId      : chip ID of the device
00174  *
00175  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00176  * \return ERR_PARAM        : Invalid parameters
00177  * \return ERR_IO           : Generic internal error
00178  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00179  * \return ERR_PROTO        : Protocol error detected
00180  * \return ERR_NONE         : No error
00181  *****************************************************************************
00182  */
00183 ReturnCode rfalSt25tbPollerInitiate( uint8_t *chipId,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 );
00184 
00185 
00186 /*!
00187  *****************************************************************************
00188  * \brief  ST25TB Poller Pcall
00189  *
00190  * This method sends a Pcall command
00191  * If successful the device's chip ID will be retrieved
00192  *
00193  * \param[out]  chipId      : Chip ID of the device
00194  *
00195  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00196  * \return ERR_PARAM        : Invalid parameters
00197  * \return ERR_IO           : Generic internal error
00198  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00199  * \return ERR_PROTO        : Protocol error detected
00200  * \return ERR_NONE         : No error
00201  *****************************************************************************
00202  */
00203 ReturnCode rfalSt25tbPollerPcall( uint8_t *chipId );
00204 
00205 
00206 /*!
00207  *****************************************************************************
00208  * \brief  ST25TB Poller Slot Marker
00209  *
00210  * This method sends a Slot Marker
00211  *
00212  * If a single device responds the chip ID will be retrieved
00213  *
00214  * \param[in]  slotNum      : Slot Number
00215  * \param[out]  chipIdRes   : Chip ID of the device
00216  *
00217  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00218  * \return ERR_PARAM        : Invalid parameters
00219  * \return ERR_IO           : Generic internal error
00220  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00221  * \return ERR_PROTO        : Protocol error detected
00222  * \return ERR_NONE         : No error
00223  *****************************************************************************
00224  */
00225 ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes,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 );
00226 
00227 
00228 /*!
00229  *****************************************************************************
00230  * \brief  ST25TB Poller Select
00231  *
00232  * This method sends a ST25TB Select command with the given chip ID.
00233  *
00234  * If the device is already in Selected state and receives an incorrect chip
00235  * ID, it goes into Deselected state
00236  *
00237  * \param[in]  chipId       : chip ID of the device to be selected
00238  *
00239  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00240  * \return ERR_PARAM        : Invalid parameters
00241  * \return ERR_IO           : Generic internal error
00242  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00243  * \return ERR_PROTO        : Protocol error detected
00244  * \return ERR_NONE         : No error
00245  *****************************************************************************
00246  */
00247 ReturnCode rfalSt25tbPollerSelect( uint8_t chipId,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 );
00248 
00249 
00250 /*!
00251  *****************************************************************************
00252  * \brief  ST25TB Get UID
00253  *
00254  * This method sends a Get_UID command
00255  *
00256  * If a single device responds the chip UID will be retrieved
00257  *
00258  * \param[out]  UID      : UID of the found device
00259  *
00260  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00261  * \return ERR_PARAM        : Invalid parameters
00262  * \return ERR_IO           : Generic internal error
00263  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00264  * \return ERR_PROTO        : Protocol error detected
00265  * \return ERR_NONE         : No error
00266  *****************************************************************************
00267  */
00268 ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID  *UID,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 );
00269 
00270 
00271 /*!
00272  *****************************************************************************
00273  * \brief  ST25TB Poller Read Block
00274  *
00275  * This method reads a block of the ST25TB
00276  *
00277  * \param[in]   blockAddress : address of the block to be read
00278  * \param[out]  blockData    : location to place the data read from block
00279  *
00280  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00281  * \return ERR_PARAM        : Invalid parameters
00282  * \return ERR_IO           : Generic internal error
00283  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00284  * \return ERR_PROTO        : Protocol error detected
00285  * \return ERR_NONE         : No error
00286  *****************************************************************************
00287  */
00288 ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock  *blockData,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 );
00289 
00290 
00291 /*!
00292  *****************************************************************************
00293  * \brief  ST25TB Poller Write Block
00294  *
00295  * This method writes a block of the ST25TB
00296  *
00297  * \param[in]  blockAddress : address of the block to be written
00298  * \param[in]  blockData    : data to be written on the block
00299  *
00300  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00301  * \return ERR_PARAM        : Invalid parameters
00302  * \return ERR_IO           : Generic internal error
00303  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00304  * \return ERR_PROTO        : Protocol error detected
00305  * \return ERR_NONE         : No error
00306  *****************************************************************************
00307  */
00308 ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, rfalSt25tbBlock  *blockData,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 );
00309 
00310 
00311 /*!
00312  *****************************************************************************
00313  * \brief  ST25TB Poller Completion
00314  *
00315  * This method sends a completion command to the ST25TB. After the
00316  * completion the card no longer will reply to any command.
00317  *
00318  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00319  * \return ERR_PARAM        : Invalid parameters
00320  * \return ERR_IO           : Generic internal error
00321  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00322  * \return ERR_PROTO        : Protocol error detected, invalid SENSB_RES received
00323  * \return ERR_NONE         : No error
00324  *****************************************************************************
00325  */
00326 ReturnCode rfalSt25tbPollerCompletion( 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 );
00327 
00328 
00329 /*!
00330  *****************************************************************************
00331  * \brief  ST25TB Poller Reset to Inventory
00332  *
00333  * This method sends a Reset to Inventory command to the ST25TB.
00334  *
00335  * \return ERR_WRONG_STATE  : RFAL not initialized or incorrect mode
00336  * \return ERR_PARAM        : Invalid parameters
00337  * \return ERR_IO           : Generic internal error
00338  * \return ERR_TIMEOUT      : Timeout error, no listener device detected
00339  * \return ERR_PROTO        : Protocol error detected, invalid SENSB_RES received
00340  * \return ERR_NONE         : No error
00341  *****************************************************************************
00342  */
00343 ReturnCode rfalSt25tbPollerResetToInventory( 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 );
00344 
00345 
00346 #endif /* RFAL_ST25TB_H */
00347 
00348 /**
00349   * @}
00350   *
00351   * @}
00352   *
00353   * @}
00354   */
00355