rfal_nfcv.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R391x firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file rfal_nfcv.h
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief Implementation of NFC-V Poller (ISO15693) device
  31. *
  32. * The definitions and helpers methods provided by this module
  33. * are aligned with NFC-V Digital 2.1
  34. *
  35. *
  36. * \addtogroup RFAL
  37. * @{
  38. *
  39. * \addtogroup RFAL-AL
  40. * \brief RFAL Abstraction Layer
  41. * @{
  42. *
  43. * \addtogroup NFC-V
  44. * \brief RFAL NFC-V Module
  45. * @{
  46. *
  47. */
  48. #ifndef RFAL_NFCV_H
  49. #define RFAL_NFCV_H
  50. /*
  51. ******************************************************************************
  52. * INCLUDES
  53. ******************************************************************************
  54. */
  55. #include "platform.h"
  56. #include "st_errno.h"
  57. #include "rfal_rf.h"
  58. /*
  59. ******************************************************************************
  60. * GLOBAL DEFINES
  61. ******************************************************************************
  62. */
  63. #define RFAL_NFCV_UID_LEN 8U /*!< NFC-V UID length */
  64. #define RFAL_NFCV_MAX_BLOCK_LEN 32U /*!< Max Block size: can be of up to 256 bits ISO 15693 2000 5 */
  65. #define RFAL_NFCV_BNO_LEN 1U /*!< NFC-V Block Number length */
  66. #define RFAL_NFCV_CRC_LEN 2U /*!< NFC-V CRC length */
  67. #define RFAL_NFCV_MAX_GEN_DATA_LEN (RFAL_NFCV_MAX_BLOCK_LEN + RFAL_NFCV_BNO_LEN + RFAL_NFCV_UID_LEN) /*!<Max data */
  68. #define RFAL_NFCV_BLOCKNUM_LEN 1U /*!< Block Number length on normal commands: 8 bits */
  69. #define RFAL_NFCV_BLOCKNUM_EXTENDED_LEN 2U /*!< Block Number length on extended commands: 16 bits */
  70. #define RFAL_NFCV_PARAM_SKIP 0U /*!< Skip proprietary Param Request */
  71. /*! NFC-V RequestFlags ISO15693 2000 7.3.1 */
  72. enum{
  73. RFAL_NFCV_REQ_FLAG_DEFAULT = 0x02U, /*!< Default Request Flags */
  74. RFAL_NFCV_REQ_FLAG_SUB_CARRIER = 0x01U, /*!< Sub Carrier flag */
  75. RFAL_NFCV_REQ_FLAG_DATA_RATE = 0x02U, /*!< Data Rate flag */
  76. RFAL_NFCV_REQ_FLAG_INVENTORY = 0x04U, /*!< Inventory flag */
  77. RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT = 0x08U, /*!< Protocol Extension flag */
  78. RFAL_NFCV_REQ_FLAG_SELECT = 0x10U, /*!< Select flag */
  79. RFAL_NFCV_REQ_FLAG_ADDRESS = 0x20U, /*!< Address flag */
  80. RFAL_NFCV_REQ_FLAG_OPTION = 0x40U, /*!< Option flag */
  81. RFAL_NFCV_REQ_FLAG_RFU = 0x80U, /*!< RFU flag */
  82. RFAL_NFCV_REQ_FLAG_AFI = 0x10U, /*!< AFI flag */
  83. RFAL_NFCV_REQ_FLAG_NB_SLOTS = 0x20U, /*!< Number of Slots flag */
  84. };
  85. /*! NFC-V Response Flags ISO15693 2000 7.4.1 */
  86. enum{
  87. RFAL_NFCV_RES_FLAG_ERROR = 0x01U, /*!< Error flag */
  88. RFAL_NFCV_RES_FLAG_RFU1 = 0x02U, /*!< RFU flag */
  89. RFAL_NFCV_RES_FLAG_RFU2 = 0x04U, /*!< RFU flag */
  90. RFAL_NFCV_RES_FLAG_EXTENSION = 0x08U, /*!< Extension flag */
  91. RFAL_NFCV_RES_FLAG_RFU3 = 0x10U, /*!< RFU flag */
  92. RFAL_NFCV_RES_FLAG_RFU4 = 0x20U, /*!< RFU flag */
  93. RFAL_NFCV_RES_FLAG_RFU5 = 0x40U, /*!< RFU flag */
  94. RFAL_NFCV_RES_FLAG_RFU6 = 0x80U /*!< RFU flag */
  95. };
  96. /*! NFC-V Error code ISO15693 2000 7.4.2 */
  97. enum{
  98. RFAL_NFCV_ERROR_CMD_NOT_SUPPORTED = 0x01U, /*!< The command is not supported, code is not recognised */
  99. RFAL_NFCV_ERROR_CMD_NOT_RECOGNIZED = 0x02U, /*!< The command is not recognised, format error occurred */
  100. RFAL_NFCV_ERROR_OPTION_NOT_SUPPORTED = 0x03U, /*!< The option is not supported */
  101. RFAL_NFCV_ERROR_UNKNOWN = 0x0FU, /*!< Unknown error */
  102. RFAL_NFCV_ERROR_BLOCK_NOT_AVALIABLE = 0x10U, /*!< The specified block is not available */
  103. RFAL_NFCV_ERROR_BLOCK_ALREDY_LOCKED = 0x11U, /*!< The specified block is already locked */
  104. RFAL_NFCV_ERROR_BLOCK_LOCKED = 0x12U, /*!< The specified block is locked */
  105. RFAL_NFCV_ERROR_WRITE_FAILED = 0x13U, /*!< The specified block was not successfully programmed */
  106. RFAL_NFCV_ERROR_BLOCK_FAILED = 0x14U /*!< The specified block was not successfully locked */
  107. };
  108. /*! NFC-V command set ISO15693 2000 9.1 */
  109. enum
  110. {
  111. RFAL_NFCV_CMD_INVENTORY = 0x01U, /*!< INVENTORY_REQ (Inventory) command */
  112. RFAL_NFCV_CMD_SLPV = 0x02U, /*!< SLPV_REQ (Stay quiet) command */
  113. RFAL_NFCV_CMD_READ_SINGLE_BLOCK = 0x20U, /*!< Read single block command */
  114. RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK = 0x21U, /*!< Write single block command */
  115. RFAL_NFCV_CMD_LOCK_BLOCK = 0x22U, /*!< Lock block command */
  116. RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS = 0x23U, /*!< Read multiple blocks command */
  117. RFAL_NFCV_CMD_WRITE_MULTIPLE_BLOCKS = 0x24U, /*!< Write multiple blocks command */
  118. RFAL_NFCV_CMD_SELECT = 0x25U, /*!< Select command */
  119. RFAL_NFCV_CMD_RESET_TO_READY = 0x26U, /*!< Reset To Ready command */
  120. RFAL_NFCV_CMD_GET_SYS_INFO = 0x2BU, /*!< Get System Information command */
  121. RFAL_NFCV_CMD_EXTENDED_READ_SINGLE_BLOCK = 0x30U, /*!< Extended read single block command */
  122. RFAL_NFCV_CMD_EXTENDED_WRITE_SINGLE_BLOCK = 0x31U, /*!< Extended write single block command */
  123. RFAL_NFCV_CMD_EXTENDED_LOCK_SINGLE_BLOCK = 0x32U, /*!< Extended lock single block command */
  124. RFAL_NFCV_CMD_EXTENDED_READ_MULTIPLE_BLOCK = 0x33U, /*!< Extended read multiple block command */
  125. RFAL_NFCV_CMD_EXTENDED_WRITE_MULTIPLE_BLOCK = 0x34U, /*!< Extended read multiple block command */
  126. RFAL_NFCV_CMD_EXTENDED_GET_SYS_INFO = 0x3BU /*!< Extended Get System Information command */
  127. };
  128. /*! ST25TV/ST25DV command set */
  129. enum
  130. {
  131. RFAL_NFCV_CMD_READ_CONFIGURATION = 0xA0U, /*!< Read configuration command */
  132. RFAL_NFCV_CMD_WRITE_CONFIGURATION = 0xA1U, /*!< Write configuration command */
  133. RFAL_NFCV_CMD_SET_EAS = 0xA2U, /*!< Set EAS command */
  134. RFAL_NFCV_CMD_RESET_EAS = 0xA3U, /*!< Reset EAS command */
  135. RFAL_NFCV_CMD_LOCK_EAS = 0xA4U, /*!< Lock EAS command */
  136. RFAL_NFCV_CMD_ENABLE_EAS = 0xA5U, /*!< Enable EAS command */
  137. RFAL_NFCV_CMD_KILL = 0xA6U, /*!< Kill command */
  138. RFAL_NFCV_CMD_WRITE_EAS_ID = 0xA7U, /*!< Write EAS ID command */
  139. RFAL_NFCV_CMD_WRITE_EAS_CONFIG = 0xA8U, /*!< Write EAS CONFIG command */
  140. RFAL_NFCV_CMD_MANAGE_GPO = 0xA9U, /*!< Manage GPO command */
  141. RFAL_NFCV_CMD_WRITE_MESSAGE = 0xAAU, /*!< Write Message command */
  142. RFAL_NFCV_CMD_READ_MESSAGE_LENGTH = 0xABU, /*!< Read Message Length command */
  143. RFAL_NFCV_CMD_READ_MESSAGE = 0xACU, /*!< Read Message command */
  144. RFAL_NFCV_CMD_READ_DYN_CONFIGURATION = 0xADU, /*!< Read Dynamic Configuration command */
  145. RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION = 0xAEU, /*!< Write Dynamic Configuration command */
  146. RFAL_NFCV_CMD_WRITE_PASSWORD = 0xB1U, /*!< Write Kill Password / Write Password command */
  147. RFAL_NFCV_CMD_LOCK_KILL = 0xB2U, /*!< Lock Kill command */
  148. RFAL_NFCV_CMD_PRESENT_PASSWORD = 0xB3U, /*!< Present Password command */
  149. RFAL_NFCV_CMD_GET_RANDOM_NUMBER = 0xB4U, /*!< Get Random Number command */
  150. RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK = 0xC0U, /*!< Fast Read single block command */
  151. RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS = 0xC3U, /*!< Fast Read multiple blocks command */
  152. RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK = 0xC4U, /*!< Fast Extended Read single block command */
  153. RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS = 0xC5U, /*!< Fast Extended Read multiple blocks command */
  154. RFAL_NFCV_CMD_FAST_WRITE_MESSAGE = 0xCAU, /*!< Fast Write Message */
  155. RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH = 0xCBU, /*!< Fast Read Message Length */
  156. RFAL_NFCV_CMD_FAST_READ_MESSAGE = 0xCCU, /*!< Fast Read Message */
  157. RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION = 0xCDU, /*!< Fast Read Dynamic configuration */
  158. RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION = 0xCEU /*!< Fast Write Dynamic Configuration */
  159. };
  160. /*! ISO 15693 Get System info parameter request field ISO15693 2018 Table 94 */
  161. enum
  162. {
  163. RFAL_NFCV_SYSINFO_DFSID = 0x01U, /*!< Get System info DFSID flag */
  164. RFAL_NFCV_SYSINFO_AFI = 0x02U, /*!< Get System info AFI flag */
  165. RFAL_NFCV_SYSINFO_MEMSIZE = 0x04U, /*!< Get System info MEMSIZE flag */
  166. RFAL_NFCV_SYSINFO_ICREF = 0x08U, /*!< Get System info ICREF flag */
  167. RFAL_NFCV_SYSINFO_MOI = 0x10U, /*!< Get System info MOI flag */
  168. RFAL_NFCV_SYSINFO_CMDLIST = 0x20U, /*!< Get System info CMDLIST flag */
  169. RFAL_NFCV_SYSINFO_CSI = 0x40U, /*!< Get System info CSI flag */
  170. RFAL_NFCV_SYSINFO_REQ_ALL = 0x7FU /*!< Get System info request of all parameters */
  171. };
  172. /*
  173. ******************************************************************************
  174. * GLOBAL MACROS
  175. ******************************************************************************
  176. */
  177. /*
  178. ******************************************************************************
  179. * GLOBAL TYPES
  180. ******************************************************************************
  181. */
  182. /*! NFC-V Number of slots Digital 2.0 9.6.1 */
  183. typedef enum
  184. {
  185. RFAL_NFCV_NUM_SLOTS_1 = 0x20, /*!< Number of slots: 1 */
  186. RFAL_NFCV_NUM_SLOTS_16 = 0x00, /*!< Number of slots: 16 */
  187. } rfalNfcvNumSlots;
  188. /*! NFC-V INVENTORY_RES format Digital 2.0 9.6.2 */
  189. typedef struct
  190. {
  191. uint8_t RES_FLAG; /*!< Response Flags */
  192. uint8_t DSFID; /*!< Data Storage Format Identifier */
  193. uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< NFC-V device UID */
  194. uint8_t crc[RFAL_CRC_LEN]; /*!< CRC */
  195. } rfalNfcvInventoryRes;
  196. /*! NFC-V Generic Req format */
  197. typedef struct
  198. {
  199. uint8_t REQ_FLAG; /*!< Request Flags */
  200. uint8_t CMD; /*!< Command code */
  201. union { /* PRQA S 0750 # MISRA 19.2 - Both members are of the same type, just different names. Thus no problem can occur. */
  202. uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< Mask Value */
  203. uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
  204. }payload; /*!< Payload */
  205. } rfalNfcvGenericReq;
  206. /*! NFC-V Generic Response format */
  207. typedef struct
  208. {
  209. uint8_t RES_FLAG; /*!< Response Flags */
  210. uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
  211. } rfalNfcvGenericRes;
  212. /*! NFC-V listener device (VICC) struct */
  213. typedef struct
  214. {
  215. rfalNfcvInventoryRes InvRes; /*!< INVENTORY_RES */
  216. bool isSleep; /*!< Device sleeping flag */
  217. } rfalNfcvListenDevice;
  218. /*
  219. ******************************************************************************
  220. * GLOBAL FUNCTION PROTOTYPES
  221. ******************************************************************************
  222. */
  223. /*!
  224. *****************************************************************************
  225. * \brief Initialize NFC-V Poller mode
  226. *
  227. * This methods configures RFAL RF layer to perform as a
  228. * NFC-F Poller/RW (ISO15693) including all default timings
  229. *
  230. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  231. * \return ERR_PARAM : Incorrect bitrate
  232. * \return ERR_NONE : No error
  233. *****************************************************************************
  234. */
  235. ReturnCode rfalNfcvPollerInitialize( void );
  236. /*!
  237. *****************************************************************************
  238. * \brief NFC-V Poller Check Presence
  239. *
  240. * This method checks if a NFC-V Listen device (VICC) is present on the field
  241. * by sending an Inventory (INVENTORY_REQ)
  242. *
  243. * \param[out] invRes : If received, the INVENTORY_RES
  244. *
  245. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  246. * \return ERR_PARAM : Invalid parameters
  247. * \return ERR_IO : Generic internal error
  248. * \return ERR_TIMEOUT : Timeout error, no listener device detectedd
  249. * \return ERR_NONE : No error, one or more device in the field
  250. *****************************************************************************
  251. */
  252. ReturnCode rfalNfcvPollerCheckPresence( rfalNfcvInventoryRes *invRes );
  253. /*!
  254. *****************************************************************************
  255. * \brief NFC-F Poller Poll
  256. *
  257. * This function sends to all VICCs in field the INVENTORY command with the
  258. * given number of slots
  259. *
  260. * If more than one slot is used the following EOF need to be handled
  261. * by the caller using rfalISO15693TransceiveEOFAnticollision()
  262. *
  263. * \param[in] nSlots : Number of Slots to be sent (1 or 16)
  264. * \param[in] maskLen : Number bits on the Mask value
  265. * \param[in] maskVal : location of the Mask value
  266. * \param[out] invRes : location to place the INVENTORY_RES
  267. * \param[out] rcvdLen : number of bits received (without collision)
  268. *
  269. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  270. * \return ERR_PARAM : Invalid parameters
  271. * \return ERR_IO : Generic internal error
  272. * \return ERR_RF_COLLISION : Collision detected
  273. * \return ERR_CRC : CRC error detected
  274. * \return ERR_PROTO : Protocol error detected
  275. * \return ERR_NONE : No error
  276. *****************************************************************************
  277. */
  278. ReturnCode rfalNfcvPollerInventory( rfalNfcvNumSlots nSlots, uint8_t maskLen, const uint8_t *maskVal, rfalNfcvInventoryRes *invRes, uint16_t* rcvdLen );
  279. /*!
  280. *****************************************************************************
  281. * \brief NFC-V Poller Full Collision Resolution
  282. *
  283. * Performs a full Collision resolution as defined in Activity 2.0 9.3.7
  284. * Once done, the devCnt will indicate how many (if any) devices have
  285. * been identified and their details are contained on nfcvDevList
  286. *
  287. * \param[in] compMode : compliance mode to be performed
  288. * \param[in] devLimit : device limit value, and size nfcaDevList
  289. * \param[out] nfcvDevList : NFC-v listener devices list
  290. * \param[out] devCnt : Devices found counter
  291. *
  292. * When compMode is set to ISO the function immediately goes to 16 slots improving
  293. * chances to detect more than only one strong card.
  294. *
  295. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  296. * \return ERR_PARAM : Invalid parameters
  297. * \return ERR_IO : Generic internal error
  298. * \return ERR_NONE : No error
  299. *****************************************************************************
  300. */
  301. ReturnCode rfalNfcvPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcvListenDevice *nfcvDevList, uint8_t *devCnt );
  302. /*!
  303. *****************************************************************************
  304. * \brief NFC-V Poller Full Collision Resolution With Sleep
  305. *
  306. * Performs a full Collision resolution which is different from Activity 2.0 9.3.7.
  307. * The implementation uses SLPV (StayQuiet) command to make sure all cards are found.
  308. * Once done, the devCnt will indicate how many (if any) devices have
  309. * been identified and their details are contained on nfcvDevList
  310. *
  311. * \param[in] devLimit : device limit value, and size nfcaDevList
  312. * \param[out] nfcvDevList : NFC-v listener devices list
  313. * \param[out] devCnt : Devices found counter
  314. *
  315. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  316. * \return ERR_PARAM : Invalid parameters
  317. * \return ERR_IO : Generic internal error
  318. * \return ERR_NONE : No error
  319. *****************************************************************************
  320. */
  321. ReturnCode rfalNfcvPollerSleepCollisionResolution( uint8_t devLimit, rfalNfcvListenDevice *nfcvDevList, uint8_t *devCnt );
  322. /*!
  323. *****************************************************************************
  324. * \brief NFC-V Poller Sleep
  325. *
  326. * This function is used to send the SLPV_REQ (Stay Quiet) command to put the VICC
  327. * with the given UID to state QUIET so that they do not reply to more Inventory
  328. *
  329. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  330. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  331. * \param[in] uid : UID of the device to be put to Sleep
  332. *
  333. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  334. * \return ERR_PARAM : Invalid parameters
  335. * \return ERR_IO : Generic internal error
  336. * \return ERR_NONE : No error
  337. *****************************************************************************
  338. */
  339. ReturnCode rfalNfcvPollerSleep( uint8_t flags, const uint8_t* uid );
  340. /*!
  341. *****************************************************************************
  342. * \brief NFC-V Poller Select
  343. *
  344. * Selects a device (VICC) by its UID
  345. *
  346. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  347. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  348. * \param[in] uid : UID of the device to be put to be Selected
  349. *
  350. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  351. * \return ERR_PARAM : Invalid parameters
  352. * \return ERR_IO : Generic internal error
  353. * \return ERR_CRC : CRC error detected
  354. * \return ERR_FRAMING : Framing error detected
  355. * \return ERR_PROTO : Protocol error detected
  356. * \return ERR_TIMEOUT : Timeout error
  357. * \return ERR_NONE : No error
  358. *****************************************************************************
  359. */
  360. ReturnCode rfalNfcvPollerSelect( uint8_t flags, const uint8_t* uid );
  361. /*!
  362. *****************************************************************************
  363. * \brief NFC-V Poller Read Single Block
  364. *
  365. * Reads a Single Block from a device (VICC)
  366. *
  367. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  368. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  369. * \param[in] uid : UID of the device to be put to be read
  370. * if UID is provided Addressed mode will be used
  371. * \param[in] blockNum : Number of the block to read
  372. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  373. * \param[in] rxBufLen : length of rxBuf
  374. * \param[out] rcvLen : number of bytes received
  375. *
  376. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  377. * \return ERR_PARAM : Invalid parameters
  378. * \return ERR_IO : Generic internal error
  379. * \return ERR_CRC : CRC error detected
  380. * \return ERR_FRAMING : Framing error detected
  381. * \return ERR_PROTO : Protocol error detected
  382. * \return ERR_TIMEOUT : Timeout error
  383. * \return ERR_NONE : No error
  384. *****************************************************************************
  385. */
  386. ReturnCode rfalNfcvPollerReadSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  387. /*!
  388. *****************************************************************************
  389. * \brief NFC-V Poller Write Single Block
  390. *
  391. * Writes a Single Block from a device (VICC)
  392. *
  393. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  394. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  395. * \param[in] uid : UID of the device to be put to be written
  396. * if UID is provided Addressed mode will be used
  397. * \param[in] blockNum : Number of the block to write
  398. * \param[in] wrData : data to be written on the given block
  399. * \param[in] blockLen : number of bytes of a block
  400. *
  401. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  402. * \return ERR_PARAM : Invalid parameters
  403. * \return ERR_IO : Generic internal error
  404. * \return ERR_CRC : CRC error detected
  405. * \return ERR_FRAMING : Framing error detected
  406. * \return ERR_PROTO : Protocol error detected
  407. * \return ERR_TIMEOUT : Timeout error
  408. * \return ERR_NONE : No error
  409. *****************************************************************************
  410. */
  411. ReturnCode rfalNfcvPollerWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, const uint8_t* wrData, uint8_t blockLen );
  412. /*!
  413. *****************************************************************************
  414. * \brief NFC-V Poller Read Multiple Blocks
  415. *
  416. * Reads Multiple Blocks from a device (VICC)
  417. *
  418. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  419. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  420. * \param[in] uid : UID of the device to be put to be read
  421. * if UID is provided Addressed mode will be used
  422. * \param[in] firstBlockNum : first block to be read
  423. * \param[in] numOfBlocks : number of block to read
  424. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  425. * \param[in] rxBufLen : length of rxBuf
  426. * \param[out] rcvLen : number of bytes received
  427. *
  428. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  429. * \return ERR_PARAM : Invalid parameters
  430. * \return ERR_IO : Generic internal error
  431. * \return ERR_CRC : CRC error detected
  432. * \return ERR_FRAMING : Framing error detected
  433. * \return ERR_PROTO : Protocol error detected
  434. * \return ERR_TIMEOUT : Timeout error
  435. * \return ERR_NONE : No error
  436. *****************************************************************************
  437. */
  438. ReturnCode rfalNfcvPollerReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  439. /*!
  440. *****************************************************************************
  441. * \brief NFC-V Poller Write Multiple Blocks
  442. *
  443. * Reads Multiple Blocks from a device (VICC)
  444. * In order to not limit the length of the Write multiple command, a buffer
  445. * must be provided where the request will be composed and then sent.
  446. *
  447. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  448. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  449. * \param[in] uid : UID of the device to be put to be read
  450. * if UID is provided Addressed mode will be used
  451. * \param[in] firstBlockNum : first block to be write
  452. * \param[in] numOfBlocks : number of consecutive blocks to write
  453. * \param[in] txBuf : buffer where the request will be composed
  454. * \param[in] txBufLen : length of txBuf
  455. * \param[in] blockLen : number of bytes of a block
  456. * \param[in] wrData : data to be written
  457. * \param[in] wrDataLen : length of the data do be written. Must be
  458. * aligned with number of blocks to write and
  459. * the size of a block
  460. *
  461. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  462. * \return ERR_PARAM : Invalid parameters
  463. * \return ERR_IO : Generic internal error
  464. * \return ERR_CRC : CRC error detected
  465. * \return ERR_FRAMING : Framing error detected
  466. * \return ERR_PROTO : Protocol error detected
  467. * \return ERR_TIMEOUT : Timeout error
  468. * \return ERR_NONE : No error
  469. *****************************************************************************
  470. */
  471. ReturnCode rfalNfcvPollerWriteMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t *txBuf, uint16_t txBufLen, uint8_t blockLen, const uint8_t* wrData, uint16_t wrDataLen );
  472. /*!
  473. *****************************************************************************
  474. * \brief NFC-V Poller Extended Lock Single Block
  475. *
  476. * Blocks a Single Block from a device (VICC) supporting extended commands
  477. *
  478. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  479. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  480. * \param[in] uid : UID of the device
  481. * if UID is provided Addressed mode will be used
  482. * \param[in] blockNum : Number of the block to be locked
  483. *
  484. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  485. * \return ERR_PARAM : Invalid parameters
  486. * \return ERR_IO : Generic internal error
  487. * \return ERR_CRC : CRC error detected
  488. * \return ERR_FRAMING : Framing error detected
  489. * \return ERR_PROTO : Protocol error detected
  490. * \return ERR_TIMEOUT : Timeout error
  491. * \return ERR_NONE : No error
  492. *****************************************************************************
  493. */
  494. ReturnCode rfalNfcvPollerLockBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum );
  495. /*!
  496. *****************************************************************************
  497. * \brief NFC-V Poller Extended Lock Single Block
  498. *
  499. * Blocks a Single Block from a device (VICC) supporting extended commands
  500. *
  501. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  502. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  503. * \param[in] uid : UID of the device
  504. * if UID is provided Addressed mode will be used
  505. * \param[in] blockNum : Number of the block to be locked (16 bits)
  506. *
  507. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  508. * \return ERR_PARAM : Invalid parameters
  509. * \return ERR_IO : Generic internal error
  510. * \return ERR_CRC : CRC error detected
  511. * \return ERR_FRAMING : Framing error detected
  512. * \return ERR_PROTO : Protocol error detected
  513. * \return ERR_TIMEOUT : Timeout error
  514. * \return ERR_NONE : No error
  515. *****************************************************************************
  516. */
  517. ReturnCode rfalNfcvPollerExtendedLockSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum );
  518. /*!
  519. *****************************************************************************
  520. * \brief NFC-V Poller Extended Read Single Block
  521. *
  522. * Reads a Single Block from a device (VICC) supporting extended commands
  523. *
  524. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  525. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  526. * \param[in] uid : UID of the device to be put to be read
  527. * if UID is provided Addressed mode will be used
  528. * \param[in] blockNum : Number of the block to read (16 bits)
  529. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  530. * \param[in] rxBufLen : length of rxBuf
  531. * \param[out] rcvLen : number of bytes received
  532. *
  533. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  534. * \return ERR_PARAM : Invalid parameters
  535. * \return ERR_IO : Generic internal error
  536. * \return ERR_CRC : CRC error detected
  537. * \return ERR_FRAMING : Framing error detected
  538. * \return ERR_PROTO : Protocol error detected
  539. * \return ERR_TIMEOUT : Timeout error
  540. * \return ERR_NONE : No error
  541. *****************************************************************************
  542. */
  543. ReturnCode rfalNfcvPollerExtendedReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  544. /*!
  545. *****************************************************************************
  546. * \brief NFC-V Poller Extended Write Single Block
  547. *
  548. * Writes a Single Block from a device (VICC) supporting extended commands
  549. *
  550. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  551. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  552. * \param[in] uid : UID of the device
  553. * if UID is provided Addressed mode will be used
  554. * \param[in] blockNum : Number of the block to write (16 bits)
  555. * \param[in] wrData : data to be written on the given block
  556. * \param[in] blockLen : number of bytes of a block
  557. *
  558. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  559. * \return ERR_PARAM : Invalid parameters
  560. * \return ERR_IO : Generic internal error
  561. * \return ERR_CRC : CRC error detected
  562. * \return ERR_FRAMING : Framing error detected
  563. * \return ERR_PROTO : Protocol error detected
  564. * \return ERR_TIMEOUT : Timeout error
  565. * \return ERR_NONE : No error
  566. *****************************************************************************
  567. */
  568. ReturnCode rfalNfcvPollerExtendedWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, const uint8_t* wrData, uint8_t blockLen );
  569. /*!
  570. *****************************************************************************
  571. * \brief NFC-V Poller Extended Read Multiple Blocks
  572. *
  573. * Reads Multiple Blocks from a device (VICC) supporting extended commands
  574. *
  575. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  576. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  577. * \param[in] uid : UID of the device to be put to be read
  578. * if UID is provided Addressed mode will be used
  579. * \param[in] firstBlockNum : first block to be read (16 bits)
  580. * \param[in] numOfBlocks : number of consecutive blocks to read (16 bits)
  581. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  582. * \param[in] rxBufLen : length of rxBuf
  583. * \param[out] rcvLen : number of bytes received
  584. *
  585. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  586. * \return ERR_PARAM : Invalid parameters
  587. * \return ERR_IO : Generic internal error
  588. * \return ERR_CRC : CRC error detected
  589. * \return ERR_FRAMING : Framing error detected
  590. * \return ERR_PROTO : Protocol error detected
  591. * \return ERR_TIMEOUT : Timeout error
  592. * \return ERR_NONE : No error
  593. *****************************************************************************
  594. */
  595. ReturnCode rfalNfcvPollerExtendedReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  596. /*!
  597. *****************************************************************************
  598. * \brief NFC-V Poller Extended Write Multiple Blocks
  599. *
  600. * Writes Multiple Blocks from a device (VICC) supporting extended commands
  601. * In order to not limit the length of the Write multiple command, a buffer
  602. * must be provided where the request will be composed and then sent.
  603. *
  604. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  605. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  606. * \param[in] uid : UID of the device to be put to be read
  607. * if UID is provided Addressed mode will be used
  608. * \param[in] firstBlockNum : first block to be write (16 bits)
  609. * \param[in] numOfBlocks : number of consecutive blocks to write (16 bits)
  610. * \param[in] txBuf : buffer where the request will be composed
  611. * \param[in] txBufLen : length of txBuf
  612. * \param[in] blockLen : number of bytes of a block
  613. * \param[in] wrData : data to be written
  614. * \param[in] wrDataLen : length of the data do be written. Must be
  615. * aligned with number of blocks to write and
  616. * the size of a block
  617. *
  618. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  619. * \return ERR_PARAM : Invalid parameters
  620. * \return ERR_IO : Generic internal error
  621. * \return ERR_CRC : CRC error detected
  622. * \return ERR_FRAMING : Framing error detected
  623. * \return ERR_PROTO : Protocol error detected
  624. * \return ERR_TIMEOUT : Timeout error
  625. * \return ERR_NONE : No error
  626. *****************************************************************************
  627. */
  628. ReturnCode rfalNfcvPollerExtendedWriteMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t *txBuf, uint16_t txBufLen, uint8_t blockLen, const uint8_t* wrData, uint16_t wrDataLen );
  629. /*!
  630. *****************************************************************************
  631. * \brief NFC-V Get System Information
  632. *
  633. * Sends Get System Information command
  634. *
  635. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  636. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  637. * \param[in] uid : UID of the device to be put to be read
  638. * if UID is provided Addressed mode will be used
  639. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  640. * \param[in] rxBufLen : length of rxBuf
  641. * \param[out] rcvLen : number of bytes received
  642. *
  643. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  644. * \return ERR_PARAM : Invalid parameters
  645. * \return ERR_IO : Generic internal error
  646. * \return ERR_CRC : CRC error detected
  647. * \return ERR_FRAMING : Framing error detected
  648. * \return ERR_PROTO : Protocol error detected
  649. * \return ERR_TIMEOUT : Timeout error
  650. * \return ERR_NONE : No error
  651. *****************************************************************************
  652. */
  653. ReturnCode rfalNfcvPollerGetSystemInformation( uint8_t flags, const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  654. /*!
  655. *****************************************************************************
  656. * \brief NFC-V Extended Get System Information
  657. *
  658. * Sends Extended Get System Information command
  659. *
  660. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  661. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  662. * \param[in] uid : UID of the device to be put to be read
  663. * if UID is provided Addressed mode will be used
  664. * \param[in] requestField : Get System info parameter request field
  665. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  666. * \param[in] rxBufLen : length of rxBuf
  667. * \param[out] rcvLen : number of bytes received
  668. *
  669. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  670. * \return ERR_PARAM : Invalid parameters
  671. * \return ERR_IO : Generic internal error
  672. * \return ERR_CRC : CRC error detected
  673. * \return ERR_FRAMING : Framing error detected
  674. * \return ERR_PROTO : Protocol error detected
  675. * \return ERR_TIMEOUT : Timeout error
  676. * \return ERR_NONE : No error
  677. *****************************************************************************
  678. */
  679. ReturnCode rfalNfcvPollerExtendedGetSystemInformation( uint8_t flags, const uint8_t* uid, uint8_t requestField, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  680. /*!
  681. *****************************************************************************
  682. * \brief NFC-V Transceive Request
  683. *
  684. * Performs a generic transceive with an ISO15693 tag
  685. *
  686. * \param[in] cmd : NFC-V command
  687. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  688. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  689. * \param[in] param : Prepend parameter on certain proprietary requests
  690. * For default commands skip: RFAL_NFCV_PARAM_SKIP
  691. * \param[in] uid : UID of the device to be put to be read
  692. * if UID is provided Addressed mode will be used
  693. * \param[in] data : command parameters append after UID
  694. * \param[in] dataLen : command parameters Len
  695. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  696. * \param[in] rxBufLen : length of rxBuf
  697. * \param[out] rcvLen : number of bytes received
  698. *
  699. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  700. * \return ERR_PARAM : Invalid parameters
  701. * \return ERR_IO : Generic internal error
  702. * \return ERR_CRC : CRC error detected
  703. * \return ERR_FRAMING : Framing error detected
  704. * \return ERR_PROTO : Protocol error detected
  705. * \return ERR_TIMEOUT : Timeout error
  706. * \return ERR_NONE : No error
  707. *****************************************************************************
  708. */
  709. ReturnCode rfalNfcvPollerTransceiveReq( uint8_t cmd, uint8_t flags, uint8_t param, const uint8_t* uid, const uint8_t *data, uint16_t dataLen, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
  710. #endif /* RFAL_NFCV_H */
  711. /**
  712. * @}
  713. *
  714. * @}
  715. *
  716. * @}
  717. */