Fork of the GitHub
rfal_t1t.h@0:75fc82583a41, 2019-11-14 (annotated)
- Committer:
- DiegoOstuni
- Date:
- Thu Nov 14 14:34:50 2019 +0000
- Revision:
- 0:75fc82583a41
Add files
Who changed what in which revision?
User | Revision | Line number | New 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>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
DiegoOstuni | 0:75fc82583a41 | 6 | * |
DiegoOstuni | 0:75fc82583a41 | 7 | * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); |
DiegoOstuni | 0:75fc82583a41 | 8 | * You may not use this file except in compliance with the License. |
DiegoOstuni | 0:75fc82583a41 | 9 | * You may obtain a copy of the License at: |
DiegoOstuni | 0:75fc82583a41 | 10 | * |
DiegoOstuni | 0:75fc82583a41 | 11 | * http://www.st.com/myliberty |
DiegoOstuni | 0:75fc82583a41 | 12 | * |
DiegoOstuni | 0:75fc82583a41 | 13 | * Unless required by applicable law or agreed to in writing, software |
DiegoOstuni | 0:75fc82583a41 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
DiegoOstuni | 0:75fc82583a41 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, |
DiegoOstuni | 0:75fc82583a41 | 16 | * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, |
DiegoOstuni | 0:75fc82583a41 | 17 | * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. |
DiegoOstuni | 0:75fc82583a41 | 18 | * See the License for the specific language governing permissions and |
DiegoOstuni | 0:75fc82583a41 | 19 | * limitations under the License. |
DiegoOstuni | 0:75fc82583a41 | 20 | * |
DiegoOstuni | 0:75fc82583a41 | 21 | ******************************************************************************/ |
DiegoOstuni | 0:75fc82583a41 | 22 | |
DiegoOstuni | 0:75fc82583a41 | 23 | /* |
DiegoOstuni | 0:75fc82583a41 | 24 | * PROJECT: ST25R391x firmware |
DiegoOstuni | 0:75fc82583a41 | 25 | * $Revision: $ |
DiegoOstuni | 0:75fc82583a41 | 26 | * LANGUAGE: ISO C99 |
DiegoOstuni | 0:75fc82583a41 | 27 | */ |
DiegoOstuni | 0:75fc82583a41 | 28 | |
DiegoOstuni | 0:75fc82583a41 | 29 | /*! \file rfal_t1t.h |
DiegoOstuni | 0:75fc82583a41 | 30 | * |
DiegoOstuni | 0:75fc82583a41 | 31 | * \author Gustavo Patricio |
DiegoOstuni | 0:75fc82583a41 | 32 | * |
DiegoOstuni | 0:75fc82583a41 | 33 | * \brief Provides NFC-A T1T convenience methods and definitions |
DiegoOstuni | 0:75fc82583a41 | 34 | * |
DiegoOstuni | 0:75fc82583a41 | 35 | * This module provides an interface to perform as a NFC-A Reader/Writer |
DiegoOstuni | 0:75fc82583a41 | 36 | * to handle a Type 1 Tag T1T (Topaz) |
DiegoOstuni | 0:75fc82583a41 | 37 | * |
DiegoOstuni | 0:75fc82583a41 | 38 | * |
DiegoOstuni | 0:75fc82583a41 | 39 | * @addtogroup RFAL |
DiegoOstuni | 0:75fc82583a41 | 40 | * @{ |
DiegoOstuni | 0:75fc82583a41 | 41 | * |
DiegoOstuni | 0:75fc82583a41 | 42 | * @addtogroup RFAL-AL |
DiegoOstuni | 0:75fc82583a41 | 43 | * @brief RFAL Abstraction Layer |
DiegoOstuni | 0:75fc82583a41 | 44 | * @{ |
DiegoOstuni | 0:75fc82583a41 | 45 | * |
DiegoOstuni | 0:75fc82583a41 | 46 | * @addtogroup T1T |
DiegoOstuni | 0:75fc82583a41 | 47 | * @brief RFAL T1T Module |
DiegoOstuni | 0:75fc82583a41 | 48 | * @{ |
DiegoOstuni | 0:75fc82583a41 | 49 | * |
DiegoOstuni | 0:75fc82583a41 | 50 | */ |
DiegoOstuni | 0:75fc82583a41 | 51 | |
DiegoOstuni | 0:75fc82583a41 | 52 | |
DiegoOstuni | 0:75fc82583a41 | 53 | #ifndef RFAL_T1T_H |
DiegoOstuni | 0:75fc82583a41 | 54 | #define RFAL_T1T_H |
DiegoOstuni | 0:75fc82583a41 | 55 | |
DiegoOstuni | 0:75fc82583a41 | 56 | /* |
DiegoOstuni | 0:75fc82583a41 | 57 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 58 | * INCLUDES |
DiegoOstuni | 0:75fc82583a41 | 59 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 60 | */ |
DiegoOstuni | 0:75fc82583a41 | 61 | #include "platform1.h" |
DiegoOstuni | 0:75fc82583a41 | 62 | #include "st_errno.h" |
DiegoOstuni | 0:75fc82583a41 | 63 | #include "rfal_rf.h" |
DiegoOstuni | 0:75fc82583a41 | 64 | |
DiegoOstuni | 0:75fc82583a41 | 65 | /* |
DiegoOstuni | 0:75fc82583a41 | 66 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 67 | * GLOBAL DEFINES |
DiegoOstuni | 0:75fc82583a41 | 68 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 69 | */ |
DiegoOstuni | 0:75fc82583a41 | 70 | #define RFAL_T1T_UID_LEN 4 /*!< T1T UID length of cascade level 1 only tag */ |
DiegoOstuni | 0:75fc82583a41 | 71 | #define RFAL_T1T_HR_LENGTH 2 /*!< T1T HR(Header ROM) length */ |
DiegoOstuni | 0:75fc82583a41 | 72 | |
DiegoOstuni | 0:75fc82583a41 | 73 | #define RFAL_T1T_HR0_NDEF_MASK 0xF0 /*!< T1T HR0 NDEF capability mask T1T 1.2 2.2.2 */ |
DiegoOstuni | 0:75fc82583a41 | 74 | #define RFAL_T1T_HR0_NDEF_SUPPORT 0x10 /*!< T1T HR0 NDEF capable value T1T 1.2 2.2.2 */ |
DiegoOstuni | 0:75fc82583a41 | 75 | |
DiegoOstuni | 0:75fc82583a41 | 76 | |
DiegoOstuni | 0:75fc82583a41 | 77 | /*! NFC-A T1T (Topaz) command set */ |
DiegoOstuni | 0:75fc82583a41 | 78 | typedef enum |
DiegoOstuni | 0:75fc82583a41 | 79 | { |
DiegoOstuni | 0:75fc82583a41 | 80 | RFAL_T1T_CMD_RID = 0x78, /*!< T1T Read UID */ |
DiegoOstuni | 0:75fc82583a41 | 81 | RFAL_T1T_CMD_RALL = 0x00, /*!< T1T Read All */ |
DiegoOstuni | 0:75fc82583a41 | 82 | RFAL_T1T_CMD_READ = 0x01, /*!< T1T Read */ |
DiegoOstuni | 0:75fc82583a41 | 83 | RFAL_T1T_CMD_WRITE_E = 0x53, /*!< T1T Write with erase (single byte) */ |
DiegoOstuni | 0:75fc82583a41 | 84 | RFAL_T1T_CMD_WRITE_NE = 0x1A /*!< T1T Write with no erase (single byte) */ |
DiegoOstuni | 0:75fc82583a41 | 85 | } rfalT1Tcmds; |
DiegoOstuni | 0:75fc82583a41 | 86 | |
DiegoOstuni | 0:75fc82583a41 | 87 | |
DiegoOstuni | 0:75fc82583a41 | 88 | /* |
DiegoOstuni | 0:75fc82583a41 | 89 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 90 | * GLOBAL TYPES |
DiegoOstuni | 0:75fc82583a41 | 91 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 92 | */ |
DiegoOstuni | 0:75fc82583a41 | 93 | |
DiegoOstuni | 0:75fc82583a41 | 94 | |
DiegoOstuni | 0:75fc82583a41 | 95 | /*! NFC-A T1T (Topaz) RID_RES Digital 1.1 10.6.2 & Table 50 */ |
DiegoOstuni | 0:75fc82583a41 | 96 | typedef struct |
DiegoOstuni | 0:75fc82583a41 | 97 | { |
DiegoOstuni | 0:75fc82583a41 | 98 | uint8_t hr0; /*!< T1T Header ROM: HR0 */ |
DiegoOstuni | 0:75fc82583a41 | 99 | uint8_t hr1; /*!< T1T Header ROM: HR1 */ |
DiegoOstuni | 0:75fc82583a41 | 100 | uint8_t uid[RFAL_T1T_UID_LEN]; /*!< T1T UID */ |
DiegoOstuni | 0:75fc82583a41 | 101 | } rfalT1TRidRes; |
DiegoOstuni | 0:75fc82583a41 | 102 | |
DiegoOstuni | 0:75fc82583a41 | 103 | /* |
DiegoOstuni | 0:75fc82583a41 | 104 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 105 | * GLOBAL FUNCTION PROTOTYPES |
DiegoOstuni | 0:75fc82583a41 | 106 | ****************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 107 | */ |
DiegoOstuni | 0:75fc82583a41 | 108 | |
DiegoOstuni | 0:75fc82583a41 | 109 | |
DiegoOstuni | 0:75fc82583a41 | 110 | /*! |
DiegoOstuni | 0:75fc82583a41 | 111 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 112 | * \brief Initialize NFC-A T1T Poller mode |
DiegoOstuni | 0:75fc82583a41 | 113 | * |
DiegoOstuni | 0:75fc82583a41 | 114 | * This methods configures RFAL RF layer to perform as a |
DiegoOstuni | 0:75fc82583a41 | 115 | * NFC-A T1T Poller/RW (Topaz) including all default timings |
DiegoOstuni | 0:75fc82583a41 | 116 | * |
DiegoOstuni | 0:75fc82583a41 | 117 | * \return ERR_WRONG_STATE : RFAL not initialized or mode not set |
DiegoOstuni | 0:75fc82583a41 | 118 | * \return ERR_NONE : No error |
DiegoOstuni | 0:75fc82583a41 | 119 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 120 | */ |
DiegoOstuni | 0:75fc82583a41 | 121 | ReturnCode rfalT1TPollerInitialize( 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 | 122 | |
DiegoOstuni | 0:75fc82583a41 | 123 | |
DiegoOstuni | 0:75fc82583a41 | 124 | /*! |
DiegoOstuni | 0:75fc82583a41 | 125 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 126 | * \brief NFC-A T1T Poller RID |
DiegoOstuni | 0:75fc82583a41 | 127 | * |
DiegoOstuni | 0:75fc82583a41 | 128 | * This method reads the UID of a NFC-A T1T Listener device |
DiegoOstuni | 0:75fc82583a41 | 129 | * |
DiegoOstuni | 0:75fc82583a41 | 130 | * |
DiegoOstuni | 0:75fc82583a41 | 131 | * \param[out] ridRes : pointer to place the RID_RES |
DiegoOstuni | 0:75fc82583a41 | 132 | * |
DiegoOstuni | 0:75fc82583a41 | 133 | * \return ERR_WRONG_STATE : RFAL not initialized or mode not set |
DiegoOstuni | 0:75fc82583a41 | 134 | * \return ERR_PARAM : Invalid parameter |
DiegoOstuni | 0:75fc82583a41 | 135 | * \return ERR_NONE : No error |
DiegoOstuni | 0:75fc82583a41 | 136 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 137 | */ |
DiegoOstuni | 0:75fc82583a41 | 138 | ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes, 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 | 139 | |
DiegoOstuni | 0:75fc82583a41 | 140 | |
DiegoOstuni | 0:75fc82583a41 | 141 | /*! |
DiegoOstuni | 0:75fc82583a41 | 142 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 143 | * \brief NFC-A T1T Poller RALL |
DiegoOstuni | 0:75fc82583a41 | 144 | * |
DiegoOstuni | 0:75fc82583a41 | 145 | * This method send a Read All command to a NFC-A T1T Listener device |
DiegoOstuni | 0:75fc82583a41 | 146 | * |
DiegoOstuni | 0:75fc82583a41 | 147 | * |
DiegoOstuni | 0:75fc82583a41 | 148 | * \param[in] uid : the UID of the device to read data |
DiegoOstuni | 0:75fc82583a41 | 149 | * \param[out] rxBuf : pointer to place the read data |
DiegoOstuni | 0:75fc82583a41 | 150 | * \param[in] rxBufLen : size of rxBuf |
DiegoOstuni | 0:75fc82583a41 | 151 | * \param[out] rxRcvdLen : actual received data |
DiegoOstuni | 0:75fc82583a41 | 152 | * |
DiegoOstuni | 0:75fc82583a41 | 153 | * \return ERR_WRONG_STATE : RFAL not initialized or mode not set |
DiegoOstuni | 0:75fc82583a41 | 154 | * \return ERR_PARAM : Invalid parameter |
DiegoOstuni | 0:75fc82583a41 | 155 | * \return ERR_NONE : No error |
DiegoOstuni | 0:75fc82583a41 | 156 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 157 | */ |
DiegoOstuni | 0:75fc82583a41 | 158 | ReturnCode rfalT1TPollerRall( uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rxRcvdLen,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 | 159 | |
DiegoOstuni | 0:75fc82583a41 | 160 | |
DiegoOstuni | 0:75fc82583a41 | 161 | /*! |
DiegoOstuni | 0:75fc82583a41 | 162 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 163 | * \brief NFC-A T1T Poller Write |
DiegoOstuni | 0:75fc82583a41 | 164 | * |
DiegoOstuni | 0:75fc82583a41 | 165 | * This method writes the given data on the address of a NFC-A T1T Listener device |
DiegoOstuni | 0:75fc82583a41 | 166 | * |
DiegoOstuni | 0:75fc82583a41 | 167 | * |
DiegoOstuni | 0:75fc82583a41 | 168 | * \param[in] uid : the UID of the device to read data |
DiegoOstuni | 0:75fc82583a41 | 169 | * \param[in] address : address to write the data |
DiegoOstuni | 0:75fc82583a41 | 170 | * \param[in] data : the data to be written |
DiegoOstuni | 0:75fc82583a41 | 171 | * |
DiegoOstuni | 0:75fc82583a41 | 172 | * \return ERR_WRONG_STATE : RFAL not initialized or mode not set |
DiegoOstuni | 0:75fc82583a41 | 173 | * \return ERR_PARAM : Invalid parameter |
DiegoOstuni | 0:75fc82583a41 | 174 | * \return ERR_NONE : No error |
DiegoOstuni | 0:75fc82583a41 | 175 | ***************************************************************************** |
DiegoOstuni | 0:75fc82583a41 | 176 | */ |
DiegoOstuni | 0:75fc82583a41 | 177 | ReturnCode rfalT1TPollerWrite( uint8_t* uid, uint8_t address, uint8_t data,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 | 178 | |
DiegoOstuni | 0:75fc82583a41 | 179 | #endif /* RFAL_T1T_H */ |
DiegoOstuni | 0:75fc82583a41 | 180 | |
DiegoOstuni | 0:75fc82583a41 | 181 | /** |
DiegoOstuni | 0:75fc82583a41 | 182 | * @} |
DiegoOstuni | 0:75fc82583a41 | 183 | * |
DiegoOstuni | 0:75fc82583a41 | 184 | * @} |
DiegoOstuni | 0:75fc82583a41 | 185 | * |
DiegoOstuni | 0:75fc82583a41 | 186 | * @} |
DiegoOstuni | 0:75fc82583a41 | 187 | */ |