rfal_nfcv.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  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 \
  65. 32U /*!< Max Block size: can be of up to 256 bits ISO 15693 2000 5 */
  66. #define RFAL_NFCV_BNO_LEN 1U /*!< NFC-V Block Number length */
  67. #define RFAL_NFCV_CRC_LEN 2U /*!< NFC-V CRC length */
  68. #define RFAL_NFCV_MAX_GEN_DATA_LEN \
  69. (RFAL_NFCV_MAX_BLOCK_LEN + RFAL_NFCV_BNO_LEN + RFAL_NFCV_UID_LEN) /*!<Max data */
  70. #define RFAL_NFCV_BLOCKNUM_LEN \
  71. 1U /*!< Block Number length on normal commands: 8 bits */
  72. #define RFAL_NFCV_BLOCKNUM_EXTENDED_LEN \
  73. 2U /*!< Block Number length on extended commands: 16 bits */
  74. #define RFAL_NFCV_PARAM_SKIP \
  75. 0U /*!< Skip proprietary Param Request */
  76. /*! NFC-V RequestFlags ISO15693 2000 7.3.1 */
  77. enum {
  78. RFAL_NFCV_REQ_FLAG_DEFAULT =
  79. 0x02U, /*!< Default Request Flags */
  80. RFAL_NFCV_REQ_FLAG_SUB_CARRIER =
  81. 0x01U, /*!< Sub Carrier flag */
  82. RFAL_NFCV_REQ_FLAG_DATA_RATE =
  83. 0x02U, /*!< Data Rate flag */
  84. RFAL_NFCV_REQ_FLAG_INVENTORY =
  85. 0x04U, /*!< Inventory flag */
  86. RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT =
  87. 0x08U, /*!< Protocol Extension flag */
  88. RFAL_NFCV_REQ_FLAG_SELECT =
  89. 0x10U, /*!< Select flag */
  90. RFAL_NFCV_REQ_FLAG_ADDRESS =
  91. 0x20U, /*!< Address flag */
  92. RFAL_NFCV_REQ_FLAG_OPTION =
  93. 0x40U, /*!< Option flag */
  94. RFAL_NFCV_REQ_FLAG_RFU =
  95. 0x80U, /*!< RFU flag */
  96. RFAL_NFCV_REQ_FLAG_AFI =
  97. 0x10U, /*!< AFI flag */
  98. RFAL_NFCV_REQ_FLAG_NB_SLOTS =
  99. 0x20U, /*!< Number of Slots flag */
  100. };
  101. /*! NFC-V Response Flags ISO15693 2000 7.4.1 */
  102. enum {
  103. RFAL_NFCV_RES_FLAG_ERROR =
  104. 0x01U, /*!< Error flag */
  105. RFAL_NFCV_RES_FLAG_RFU1 =
  106. 0x02U, /*!< RFU flag */
  107. RFAL_NFCV_RES_FLAG_RFU2 =
  108. 0x04U, /*!< RFU flag */
  109. RFAL_NFCV_RES_FLAG_EXTENSION =
  110. 0x08U, /*!< Extension flag */
  111. RFAL_NFCV_RES_FLAG_RFU3 =
  112. 0x10U, /*!< RFU flag */
  113. RFAL_NFCV_RES_FLAG_RFU4 =
  114. 0x20U, /*!< RFU flag */
  115. RFAL_NFCV_RES_FLAG_RFU5 =
  116. 0x40U, /*!< RFU flag */
  117. RFAL_NFCV_RES_FLAG_RFU6 =
  118. 0x80U /*!< RFU flag */
  119. };
  120. /*! NFC-V Error code ISO15693 2000 7.4.2 */
  121. enum {
  122. RFAL_NFCV_ERROR_CMD_NOT_SUPPORTED =
  123. 0x01U, /*!< The command is not supported, code is not recognised */
  124. RFAL_NFCV_ERROR_CMD_NOT_RECOGNIZED =
  125. 0x02U, /*!< The command is not recognised, format error occurred */
  126. RFAL_NFCV_ERROR_OPTION_NOT_SUPPORTED =
  127. 0x03U, /*!< The option is not supported */
  128. RFAL_NFCV_ERROR_UNKNOWN =
  129. 0x0FU, /*!< Unknown error */
  130. RFAL_NFCV_ERROR_BLOCK_NOT_AVALIABLE =
  131. 0x10U, /*!< The specified block is not available */
  132. RFAL_NFCV_ERROR_BLOCK_ALREDY_LOCKED =
  133. 0x11U, /*!< The specified block is already locked */
  134. RFAL_NFCV_ERROR_BLOCK_LOCKED =
  135. 0x12U, /*!< The specified block is locked */
  136. RFAL_NFCV_ERROR_WRITE_FAILED =
  137. 0x13U, /*!< The specified block was not successfully programmed */
  138. RFAL_NFCV_ERROR_BLOCK_FAILED =
  139. 0x14U /*!< The specified block was not successfully locked */
  140. };
  141. /*! NFC-V command set ISO15693 2000 9.1 */
  142. enum {
  143. RFAL_NFCV_CMD_INVENTORY =
  144. 0x01U, /*!< INVENTORY_REQ (Inventory) command */
  145. RFAL_NFCV_CMD_SLPV =
  146. 0x02U, /*!< SLPV_REQ (Stay quiet) command */
  147. RFAL_NFCV_CMD_READ_SINGLE_BLOCK =
  148. 0x20U, /*!< Read single block command */
  149. RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK =
  150. 0x21U, /*!< Write single block command */
  151. RFAL_NFCV_CMD_LOCK_BLOCK =
  152. 0x22U, /*!< Lock block command */
  153. RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS =
  154. 0x23U, /*!< Read multiple blocks command */
  155. RFAL_NFCV_CMD_WRITE_MULTIPLE_BLOCKS =
  156. 0x24U, /*!< Write multiple blocks command */
  157. RFAL_NFCV_CMD_SELECT =
  158. 0x25U, /*!< Select command */
  159. RFAL_NFCV_CMD_RESET_TO_READY =
  160. 0x26U, /*!< Reset To Ready command */
  161. RFAL_NFCV_CMD_GET_SYS_INFO =
  162. 0x2BU, /*!< Get System Information command */
  163. RFAL_NFCV_CMD_EXTENDED_READ_SINGLE_BLOCK =
  164. 0x30U, /*!< Extended read single block command */
  165. RFAL_NFCV_CMD_EXTENDED_WRITE_SINGLE_BLOCK =
  166. 0x31U, /*!< Extended write single block command */
  167. RFAL_NFCV_CMD_EXTENDED_LOCK_SINGLE_BLOCK =
  168. 0x32U, /*!< Extended lock single block command */
  169. RFAL_NFCV_CMD_EXTENDED_READ_MULTIPLE_BLOCK =
  170. 0x33U, /*!< Extended read multiple block command */
  171. RFAL_NFCV_CMD_EXTENDED_WRITE_MULTIPLE_BLOCK =
  172. 0x34U, /*!< Extended read multiple block command */
  173. RFAL_NFCV_CMD_EXTENDED_GET_SYS_INFO =
  174. 0x3BU /*!< Extended Get System Information command */
  175. };
  176. /*! ST25TV/ST25DV command set */
  177. enum {
  178. RFAL_NFCV_CMD_READ_CONFIGURATION =
  179. 0xA0U, /*!< Read configuration command */
  180. RFAL_NFCV_CMD_WRITE_CONFIGURATION =
  181. 0xA1U, /*!< Write configuration command */
  182. RFAL_NFCV_CMD_SET_EAS =
  183. 0xA2U, /*!< Set EAS command */
  184. RFAL_NFCV_CMD_RESET_EAS =
  185. 0xA3U, /*!< Reset EAS command */
  186. RFAL_NFCV_CMD_LOCK_EAS =
  187. 0xA4U, /*!< Lock EAS command */
  188. RFAL_NFCV_CMD_ENABLE_EAS =
  189. 0xA5U, /*!< Enable EAS command */
  190. RFAL_NFCV_CMD_KILL = 0xA6U, /*!< Kill command */
  191. RFAL_NFCV_CMD_WRITE_EAS_ID =
  192. 0xA7U, /*!< Write EAS ID command */
  193. RFAL_NFCV_CMD_WRITE_EAS_CONFIG =
  194. 0xA8U, /*!< Write EAS CONFIG command */
  195. RFAL_NFCV_CMD_MANAGE_GPO =
  196. 0xA9U, /*!< Manage GPO command */
  197. RFAL_NFCV_CMD_WRITE_MESSAGE =
  198. 0xAAU, /*!< Write Message command */
  199. RFAL_NFCV_CMD_READ_MESSAGE_LENGTH =
  200. 0xABU, /*!< Read Message Length command */
  201. RFAL_NFCV_CMD_READ_MESSAGE =
  202. 0xACU, /*!< Read Message command */
  203. RFAL_NFCV_CMD_READ_DYN_CONFIGURATION =
  204. 0xADU, /*!< Read Dynamic Configuration command */
  205. RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION =
  206. 0xAEU, /*!< Write Dynamic Configuration command */
  207. RFAL_NFCV_CMD_WRITE_PASSWORD =
  208. 0xB1U, /*!< Write Kill Password / Write Password command */
  209. RFAL_NFCV_CMD_LOCK_KILL =
  210. 0xB2U, /*!< Lock Kill command */
  211. RFAL_NFCV_CMD_PRESENT_PASSWORD =
  212. 0xB3U, /*!< Present Password command */
  213. RFAL_NFCV_CMD_GET_RANDOM_NUMBER =
  214. 0xB4U, /*!< Get Random Number command */
  215. RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK =
  216. 0xC0U, /*!< Fast Read single block command */
  217. RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS =
  218. 0xC3U, /*!< Fast Read multiple blocks command */
  219. RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK =
  220. 0xC4U, /*!< Fast Extended Read single block command */
  221. RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS =
  222. 0xC5U, /*!< Fast Extended Read multiple blocks command */
  223. RFAL_NFCV_CMD_FAST_WRITE_MESSAGE =
  224. 0xCAU, /*!< Fast Write Message */
  225. RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH =
  226. 0xCBU, /*!< Fast Read Message Length */
  227. RFAL_NFCV_CMD_FAST_READ_MESSAGE =
  228. 0xCCU, /*!< Fast Read Message */
  229. RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION =
  230. 0xCDU, /*!< Fast Read Dynamic configuration */
  231. RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION =
  232. 0xCEU /*!< Fast Write Dynamic Configuration */
  233. };
  234. /*! ISO 15693 Get System info parameter request field ISO15693 2018 Table 94 */
  235. enum {
  236. RFAL_NFCV_SYSINFO_DFSID =
  237. 0x01U, /*!< Get System info DFSID flag */
  238. RFAL_NFCV_SYSINFO_AFI =
  239. 0x02U, /*!< Get System info AFI flag */
  240. RFAL_NFCV_SYSINFO_MEMSIZE =
  241. 0x04U, /*!< Get System info MEMSIZE flag */
  242. RFAL_NFCV_SYSINFO_ICREF =
  243. 0x08U, /*!< Get System info ICREF flag */
  244. RFAL_NFCV_SYSINFO_MOI =
  245. 0x10U, /*!< Get System info MOI flag */
  246. RFAL_NFCV_SYSINFO_CMDLIST =
  247. 0x20U, /*!< Get System info CMDLIST flag */
  248. RFAL_NFCV_SYSINFO_CSI =
  249. 0x40U, /*!< Get System info CSI flag */
  250. RFAL_NFCV_SYSINFO_REQ_ALL =
  251. 0x7FU /*!< Get System info request of all parameters */
  252. };
  253. /*
  254. ******************************************************************************
  255. * GLOBAL MACROS
  256. ******************************************************************************
  257. */
  258. /*
  259. ******************************************************************************
  260. * GLOBAL TYPES
  261. ******************************************************************************
  262. */
  263. /*! NFC-V Number of slots Digital 2.0 9.6.1 */
  264. typedef enum {
  265. RFAL_NFCV_NUM_SLOTS_1 = 0x20, /*!< Number of slots: 1 */
  266. RFAL_NFCV_NUM_SLOTS_16 = 0x00, /*!< Number of slots: 16 */
  267. } rfalNfcvNumSlots;
  268. /*! NFC-V INVENTORY_RES format Digital 2.0 9.6.2 */
  269. typedef struct {
  270. uint8_t RES_FLAG; /*!< Response Flags */
  271. uint8_t DSFID; /*!< Data Storage Format Identifier */
  272. uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< NFC-V device UID */
  273. uint8_t crc[RFAL_CRC_LEN]; /*!< CRC */
  274. } rfalNfcvInventoryRes;
  275. /*! NFC-V Generic Req format */
  276. typedef struct {
  277. uint8_t REQ_FLAG; /*!< Request Flags */
  278. uint8_t CMD; /*!< Command code */
  279. union { /* PRQA S 0750 # MISRA 19.2 - Both members are of the same type, just different names. Thus no problem can occur. */
  280. uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< Mask Value */
  281. uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
  282. } payload; /*!< Payload */
  283. } rfalNfcvGenericReq;
  284. /*! NFC-V Generic Response format */
  285. typedef struct {
  286. uint8_t RES_FLAG; /*!< Response Flags */
  287. uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
  288. } rfalNfcvGenericRes;
  289. /*! NFC-V listener device (VICC) struct */
  290. typedef struct {
  291. rfalNfcvInventoryRes InvRes; /*!< INVENTORY_RES */
  292. bool isSleep; /*!< Device sleeping flag */
  293. } rfalNfcvListenDevice;
  294. /*
  295. ******************************************************************************
  296. * GLOBAL FUNCTION PROTOTYPES
  297. ******************************************************************************
  298. */
  299. /*!
  300. *****************************************************************************
  301. * \brief Initialize NFC-V Poller mode
  302. *
  303. * This methods configures RFAL RF layer to perform as a
  304. * NFC-F Poller/RW (ISO15693) including all default timings
  305. *
  306. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  307. * \return ERR_PARAM : Incorrect bitrate
  308. * \return ERR_NONE : No error
  309. *****************************************************************************
  310. */
  311. ReturnCode rfalNfcvPollerInitialize(void);
  312. /*!
  313. *****************************************************************************
  314. * \brief NFC-V Poller Check Presence
  315. *
  316. * This method checks if a NFC-V Listen device (VICC) is present on the field
  317. * by sending an Inventory (INVENTORY_REQ)
  318. *
  319. * \param[out] invRes : If received, the INVENTORY_RES
  320. *
  321. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  322. * \return ERR_PARAM : Invalid parameters
  323. * \return ERR_IO : Generic internal error
  324. * \return ERR_TIMEOUT : Timeout error, no listener device detectedd
  325. * \return ERR_NONE : No error, one or more device in the field
  326. *****************************************************************************
  327. */
  328. ReturnCode rfalNfcvPollerCheckPresence(rfalNfcvInventoryRes* invRes);
  329. /*!
  330. *****************************************************************************
  331. * \brief NFC-F Poller Poll
  332. *
  333. * This function sends to all VICCs in field the INVENTORY command with the
  334. * given number of slots
  335. *
  336. * If more than one slot is used the following EOF need to be handled
  337. * by the caller using rfalISO15693TransceiveEOFAnticollision()
  338. *
  339. * \param[in] nSlots : Number of Slots to be sent (1 or 16)
  340. * \param[in] maskLen : Number bits on the Mask value
  341. * \param[in] maskVal : location of the Mask value
  342. * \param[out] invRes : location to place the INVENTORY_RES
  343. * \param[out] rcvdLen : number of bits received (without collision)
  344. *
  345. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  346. * \return ERR_PARAM : Invalid parameters
  347. * \return ERR_IO : Generic internal error
  348. * \return ERR_RF_COLLISION : Collision detected
  349. * \return ERR_CRC : CRC error detected
  350. * \return ERR_PROTO : Protocol error detected
  351. * \return ERR_NONE : No error
  352. *****************************************************************************
  353. */
  354. ReturnCode rfalNfcvPollerInventory(
  355. rfalNfcvNumSlots nSlots,
  356. uint8_t maskLen,
  357. const uint8_t* maskVal,
  358. rfalNfcvInventoryRes* invRes,
  359. uint16_t* rcvdLen);
  360. /*!
  361. *****************************************************************************
  362. * \brief NFC-V Poller Full Collision Resolution
  363. *
  364. * Performs a full Collision resolution as defined in Activity 2.0 9.3.7
  365. * Once done, the devCnt will indicate how many (if any) devices have
  366. * been identified and their details are contained on nfcvDevList
  367. *
  368. * \param[in] compMode : compliance mode to be performed
  369. * \param[in] devLimit : device limit value, and size nfcaDevList
  370. * \param[out] nfcvDevList : NFC-v listener devices list
  371. * \param[out] devCnt : Devices found counter
  372. *
  373. * When compMode is set to ISO the function immediately goes to 16 slots improving
  374. * chances to detect more than only one strong card.
  375. *
  376. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  377. * \return ERR_PARAM : Invalid parameters
  378. * \return ERR_IO : Generic internal error
  379. * \return ERR_NONE : No error
  380. *****************************************************************************
  381. */
  382. ReturnCode rfalNfcvPollerCollisionResolution(
  383. rfalComplianceMode compMode,
  384. uint8_t devLimit,
  385. rfalNfcvListenDevice* nfcvDevList,
  386. uint8_t* devCnt);
  387. /*!
  388. *****************************************************************************
  389. * \brief NFC-V Poller Full Collision Resolution With Sleep
  390. *
  391. * Performs a full Collision resolution which is different from Activity 2.0 9.3.7.
  392. * The implementation uses SLPV (StayQuiet) command to make sure all cards are found.
  393. * Once done, the devCnt will indicate how many (if any) devices have
  394. * been identified and their details are contained on nfcvDevList
  395. *
  396. * \param[in] devLimit : device limit value, and size nfcaDevList
  397. * \param[out] nfcvDevList : NFC-v listener devices list
  398. * \param[out] devCnt : Devices found counter
  399. *
  400. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  401. * \return ERR_PARAM : Invalid parameters
  402. * \return ERR_IO : Generic internal error
  403. * \return ERR_NONE : No error
  404. *****************************************************************************
  405. */
  406. ReturnCode rfalNfcvPollerSleepCollisionResolution(
  407. uint8_t devLimit,
  408. rfalNfcvListenDevice* nfcvDevList,
  409. uint8_t* devCnt);
  410. /*!
  411. *****************************************************************************
  412. * \brief NFC-V Poller Sleep
  413. *
  414. * This function is used to send the SLPV_REQ (Stay Quiet) command to put the VICC
  415. * with the given UID to state QUIET so that they do not reply to more Inventory
  416. *
  417. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  418. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  419. * \param[in] uid : UID of the device to be put to Sleep
  420. *
  421. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  422. * \return ERR_PARAM : Invalid parameters
  423. * \return ERR_IO : Generic internal error
  424. * \return ERR_NONE : No error
  425. *****************************************************************************
  426. */
  427. ReturnCode rfalNfcvPollerSleep(uint8_t flags, const uint8_t* uid);
  428. /*!
  429. *****************************************************************************
  430. * \brief NFC-V Poller Select
  431. *
  432. * Selects a device (VICC) by its UID
  433. *
  434. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  435. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  436. * \param[in] uid : UID of the device to be put to be Selected
  437. *
  438. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  439. * \return ERR_PARAM : Invalid parameters
  440. * \return ERR_IO : Generic internal error
  441. * \return ERR_CRC : CRC error detected
  442. * \return ERR_FRAMING : Framing error detected
  443. * \return ERR_PROTO : Protocol error detected
  444. * \return ERR_TIMEOUT : Timeout error
  445. * \return ERR_NONE : No error
  446. *****************************************************************************
  447. */
  448. ReturnCode rfalNfcvPollerSelect(uint8_t flags, const uint8_t* uid);
  449. /*!
  450. *****************************************************************************
  451. * \brief NFC-V Poller Read Single Block
  452. *
  453. * Reads a Single Block from a device (VICC)
  454. *
  455. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  456. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  457. * \param[in] uid : UID of the device to be put to be read
  458. * if UID is provided Addressed mode will be used
  459. * \param[in] blockNum : Number of the block to read
  460. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  461. * \param[in] rxBufLen : length of rxBuf
  462. * \param[out] rcvLen : number of bytes received
  463. *
  464. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  465. * \return ERR_PARAM : Invalid parameters
  466. * \return ERR_IO : Generic internal error
  467. * \return ERR_CRC : CRC error detected
  468. * \return ERR_FRAMING : Framing error detected
  469. * \return ERR_PROTO : Protocol error detected
  470. * \return ERR_TIMEOUT : Timeout error
  471. * \return ERR_NONE : No error
  472. *****************************************************************************
  473. */
  474. ReturnCode rfalNfcvPollerReadSingleBlock(
  475. uint8_t flags,
  476. const uint8_t* uid,
  477. uint8_t blockNum,
  478. uint8_t* rxBuf,
  479. uint16_t rxBufLen,
  480. uint16_t* rcvLen);
  481. /*!
  482. *****************************************************************************
  483. * \brief NFC-V Poller Write Single Block
  484. *
  485. * Writes a Single Block from a device (VICC)
  486. *
  487. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  488. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  489. * \param[in] uid : UID of the device to be put to be written
  490. * if UID is provided Addressed mode will be used
  491. * \param[in] blockNum : Number of the block to write
  492. * \param[in] wrData : data to be written on the given block
  493. * \param[in] blockLen : number of bytes of a block
  494. *
  495. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  496. * \return ERR_PARAM : Invalid parameters
  497. * \return ERR_IO : Generic internal error
  498. * \return ERR_CRC : CRC error detected
  499. * \return ERR_FRAMING : Framing error detected
  500. * \return ERR_PROTO : Protocol error detected
  501. * \return ERR_TIMEOUT : Timeout error
  502. * \return ERR_NONE : No error
  503. *****************************************************************************
  504. */
  505. ReturnCode rfalNfcvPollerWriteSingleBlock(
  506. uint8_t flags,
  507. const uint8_t* uid,
  508. uint8_t blockNum,
  509. const uint8_t* wrData,
  510. uint8_t blockLen);
  511. /*!
  512. *****************************************************************************
  513. * \brief NFC-V Poller Read Multiple Blocks
  514. *
  515. * Reads Multiple Blocks from a device (VICC)
  516. *
  517. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  518. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  519. * \param[in] uid : UID of the device to be put to be read
  520. * if UID is provided Addressed mode will be used
  521. * \param[in] firstBlockNum : first block to be read
  522. * \param[in] numOfBlocks : number of block to read
  523. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  524. * \param[in] rxBufLen : length of rxBuf
  525. * \param[out] rcvLen : number of bytes received
  526. *
  527. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  528. * \return ERR_PARAM : Invalid parameters
  529. * \return ERR_IO : Generic internal error
  530. * \return ERR_CRC : CRC error detected
  531. * \return ERR_FRAMING : Framing error detected
  532. * \return ERR_PROTO : Protocol error detected
  533. * \return ERR_TIMEOUT : Timeout error
  534. * \return ERR_NONE : No error
  535. *****************************************************************************
  536. */
  537. ReturnCode rfalNfcvPollerReadMultipleBlocks(
  538. uint8_t flags,
  539. const uint8_t* uid,
  540. uint8_t firstBlockNum,
  541. uint8_t numOfBlocks,
  542. uint8_t* rxBuf,
  543. uint16_t rxBufLen,
  544. uint16_t* rcvLen);
  545. /*!
  546. *****************************************************************************
  547. * \brief NFC-V Poller Write Multiple Blocks
  548. *
  549. * Reads Multiple Blocks from a device (VICC)
  550. * In order to not limit the length of the Write multiple command, a buffer
  551. * must be provided where the request will be composed and then sent.
  552. *
  553. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  554. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  555. * \param[in] uid : UID of the device to be put to be read
  556. * if UID is provided Addressed mode will be used
  557. * \param[in] firstBlockNum : first block to be write
  558. * \param[in] numOfBlocks : number of consecutive blocks to write
  559. * \param[in] txBuf : buffer where the request will be composed
  560. * \param[in] txBufLen : length of txBuf
  561. * \param[in] blockLen : number of bytes of a block
  562. * \param[in] wrData : data to be written
  563. * \param[in] wrDataLen : length of the data do be written. Must be
  564. * aligned with number of blocks to write and
  565. * the size of a block
  566. *
  567. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  568. * \return ERR_PARAM : Invalid parameters
  569. * \return ERR_IO : Generic internal error
  570. * \return ERR_CRC : CRC error detected
  571. * \return ERR_FRAMING : Framing error detected
  572. * \return ERR_PROTO : Protocol error detected
  573. * \return ERR_TIMEOUT : Timeout error
  574. * \return ERR_NONE : No error
  575. *****************************************************************************
  576. */
  577. ReturnCode rfalNfcvPollerWriteMultipleBlocks(
  578. uint8_t flags,
  579. const uint8_t* uid,
  580. uint8_t firstBlockNum,
  581. uint8_t numOfBlocks,
  582. uint8_t* txBuf,
  583. uint16_t txBufLen,
  584. uint8_t blockLen,
  585. const uint8_t* wrData,
  586. uint16_t wrDataLen);
  587. /*!
  588. *****************************************************************************
  589. * \brief NFC-V Poller Extended Lock Single Block
  590. *
  591. * Blocks a Single Block from a device (VICC) supporting extended commands
  592. *
  593. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  594. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  595. * \param[in] uid : UID of the device
  596. * if UID is provided Addressed mode will be used
  597. * \param[in] blockNum : Number of the block to be locked
  598. *
  599. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  600. * \return ERR_PARAM : Invalid parameters
  601. * \return ERR_IO : Generic internal error
  602. * \return ERR_CRC : CRC error detected
  603. * \return ERR_FRAMING : Framing error detected
  604. * \return ERR_PROTO : Protocol error detected
  605. * \return ERR_TIMEOUT : Timeout error
  606. * \return ERR_NONE : No error
  607. *****************************************************************************
  608. */
  609. ReturnCode rfalNfcvPollerLockBlock(uint8_t flags, const uint8_t* uid, uint8_t blockNum);
  610. /*!
  611. *****************************************************************************
  612. * \brief NFC-V Poller Extended Lock Single Block
  613. *
  614. * Blocks a Single Block from a device (VICC) supporting extended commands
  615. *
  616. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  617. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  618. * \param[in] uid : UID of the device
  619. * if UID is provided Addressed mode will be used
  620. * \param[in] blockNum : Number of the block to be locked (16 bits)
  621. *
  622. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  623. * \return ERR_PARAM : Invalid parameters
  624. * \return ERR_IO : Generic internal error
  625. * \return ERR_CRC : CRC error detected
  626. * \return ERR_FRAMING : Framing error detected
  627. * \return ERR_PROTO : Protocol error detected
  628. * \return ERR_TIMEOUT : Timeout error
  629. * \return ERR_NONE : No error
  630. *****************************************************************************
  631. */
  632. ReturnCode
  633. rfalNfcvPollerExtendedLockSingleBlock(uint8_t flags, const uint8_t* uid, uint16_t blockNum);
  634. /*!
  635. *****************************************************************************
  636. * \brief NFC-V Poller Extended Read Single Block
  637. *
  638. * Reads a Single Block from a device (VICC) supporting extended commands
  639. *
  640. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  641. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  642. * \param[in] uid : UID of the device to be put to be read
  643. * if UID is provided Addressed mode will be used
  644. * \param[in] blockNum : Number of the block to read (16 bits)
  645. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  646. * \param[in] rxBufLen : length of rxBuf
  647. * \param[out] rcvLen : number of bytes received
  648. *
  649. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  650. * \return ERR_PARAM : Invalid parameters
  651. * \return ERR_IO : Generic internal error
  652. * \return ERR_CRC : CRC error detected
  653. * \return ERR_FRAMING : Framing error detected
  654. * \return ERR_PROTO : Protocol error detected
  655. * \return ERR_TIMEOUT : Timeout error
  656. * \return ERR_NONE : No error
  657. *****************************************************************************
  658. */
  659. ReturnCode rfalNfcvPollerExtendedReadSingleBlock(
  660. uint8_t flags,
  661. const uint8_t* uid,
  662. uint16_t blockNum,
  663. uint8_t* rxBuf,
  664. uint16_t rxBufLen,
  665. uint16_t* rcvLen);
  666. /*!
  667. *****************************************************************************
  668. * \brief NFC-V Poller Extended Write Single Block
  669. *
  670. * Writes a Single Block from a device (VICC) supporting extended commands
  671. *
  672. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  673. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  674. * \param[in] uid : UID of the device
  675. * if UID is provided Addressed mode will be used
  676. * \param[in] blockNum : Number of the block to write (16 bits)
  677. * \param[in] wrData : data to be written on the given block
  678. * \param[in] blockLen : number of bytes of a block
  679. *
  680. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  681. * \return ERR_PARAM : Invalid parameters
  682. * \return ERR_IO : Generic internal error
  683. * \return ERR_CRC : CRC error detected
  684. * \return ERR_FRAMING : Framing error detected
  685. * \return ERR_PROTO : Protocol error detected
  686. * \return ERR_TIMEOUT : Timeout error
  687. * \return ERR_NONE : No error
  688. *****************************************************************************
  689. */
  690. ReturnCode rfalNfcvPollerExtendedWriteSingleBlock(
  691. uint8_t flags,
  692. const uint8_t* uid,
  693. uint16_t blockNum,
  694. const uint8_t* wrData,
  695. uint8_t blockLen);
  696. /*!
  697. *****************************************************************************
  698. * \brief NFC-V Poller Extended Read Multiple Blocks
  699. *
  700. * Reads Multiple Blocks from a device (VICC) supporting extended commands
  701. *
  702. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  703. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  704. * \param[in] uid : UID of the device to be put to be read
  705. * if UID is provided Addressed mode will be used
  706. * \param[in] firstBlockNum : first block to be read (16 bits)
  707. * \param[in] numOfBlocks : number of consecutive blocks to read (16 bits)
  708. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  709. * \param[in] rxBufLen : length of rxBuf
  710. * \param[out] rcvLen : number of bytes received
  711. *
  712. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  713. * \return ERR_PARAM : Invalid parameters
  714. * \return ERR_IO : Generic internal error
  715. * \return ERR_CRC : CRC error detected
  716. * \return ERR_FRAMING : Framing error detected
  717. * \return ERR_PROTO : Protocol error detected
  718. * \return ERR_TIMEOUT : Timeout error
  719. * \return ERR_NONE : No error
  720. *****************************************************************************
  721. */
  722. ReturnCode rfalNfcvPollerExtendedReadMultipleBlocks(
  723. uint8_t flags,
  724. const uint8_t* uid,
  725. uint16_t firstBlockNum,
  726. uint16_t numOfBlocks,
  727. uint8_t* rxBuf,
  728. uint16_t rxBufLen,
  729. uint16_t* rcvLen);
  730. /*!
  731. *****************************************************************************
  732. * \brief NFC-V Poller Extended Write Multiple Blocks
  733. *
  734. * Writes Multiple Blocks from a device (VICC) supporting extended commands
  735. * In order to not limit the length of the Write multiple command, a buffer
  736. * must be provided where the request will be composed and then sent.
  737. *
  738. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  739. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  740. * \param[in] uid : UID of the device to be put to be read
  741. * if UID is provided Addressed mode will be used
  742. * \param[in] firstBlockNum : first block to be write (16 bits)
  743. * \param[in] numOfBlocks : number of consecutive blocks to write (16 bits)
  744. * \param[in] txBuf : buffer where the request will be composed
  745. * \param[in] txBufLen : length of txBuf
  746. * \param[in] blockLen : number of bytes of a block
  747. * \param[in] wrData : data to be written
  748. * \param[in] wrDataLen : length of the data do be written. Must be
  749. * aligned with number of blocks to write and
  750. * the size of a block
  751. *
  752. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  753. * \return ERR_PARAM : Invalid parameters
  754. * \return ERR_IO : Generic internal error
  755. * \return ERR_CRC : CRC error detected
  756. * \return ERR_FRAMING : Framing error detected
  757. * \return ERR_PROTO : Protocol error detected
  758. * \return ERR_TIMEOUT : Timeout error
  759. * \return ERR_NONE : No error
  760. *****************************************************************************
  761. */
  762. ReturnCode rfalNfcvPollerExtendedWriteMultipleBlocks(
  763. uint8_t flags,
  764. const uint8_t* uid,
  765. uint16_t firstBlockNum,
  766. uint16_t numOfBlocks,
  767. uint8_t* txBuf,
  768. uint16_t txBufLen,
  769. uint8_t blockLen,
  770. const uint8_t* wrData,
  771. uint16_t wrDataLen);
  772. /*!
  773. *****************************************************************************
  774. * \brief NFC-V Get System Information
  775. *
  776. * Sends Get System Information command
  777. *
  778. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  779. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  780. * \param[in] uid : UID of the device to be put to be read
  781. * if UID is provided Addressed mode will be used
  782. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  783. * \param[in] rxBufLen : length of rxBuf
  784. * \param[out] rcvLen : number of bytes received
  785. *
  786. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  787. * \return ERR_PARAM : Invalid parameters
  788. * \return ERR_IO : Generic internal error
  789. * \return ERR_CRC : CRC error detected
  790. * \return ERR_FRAMING : Framing error detected
  791. * \return ERR_PROTO : Protocol error detected
  792. * \return ERR_TIMEOUT : Timeout error
  793. * \return ERR_NONE : No error
  794. *****************************************************************************
  795. */
  796. ReturnCode rfalNfcvPollerGetSystemInformation(
  797. uint8_t flags,
  798. const uint8_t* uid,
  799. uint8_t* rxBuf,
  800. uint16_t rxBufLen,
  801. uint16_t* rcvLen);
  802. /*!
  803. *****************************************************************************
  804. * \brief NFC-V Extended Get System Information
  805. *
  806. * Sends Extended Get System Information command
  807. *
  808. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  809. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  810. * \param[in] uid : UID of the device to be put to be read
  811. * if UID is provided Addressed mode will be used
  812. * \param[in] requestField : Get System info parameter request field
  813. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  814. * \param[in] rxBufLen : length of rxBuf
  815. * \param[out] rcvLen : number of bytes received
  816. *
  817. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  818. * \return ERR_PARAM : Invalid parameters
  819. * \return ERR_IO : Generic internal error
  820. * \return ERR_CRC : CRC error detected
  821. * \return ERR_FRAMING : Framing error detected
  822. * \return ERR_PROTO : Protocol error detected
  823. * \return ERR_TIMEOUT : Timeout error
  824. * \return ERR_NONE : No error
  825. *****************************************************************************
  826. */
  827. ReturnCode rfalNfcvPollerExtendedGetSystemInformation(
  828. uint8_t flags,
  829. const uint8_t* uid,
  830. uint8_t requestField,
  831. uint8_t* rxBuf,
  832. uint16_t rxBufLen,
  833. uint16_t* rcvLen);
  834. /*!
  835. *****************************************************************************
  836. * \brief NFC-V Transceive Request
  837. *
  838. * Performs a generic transceive with an ISO15693 tag
  839. *
  840. * \param[in] cmd : NFC-V command
  841. * \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
  842. * for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
  843. * \param[in] param : Prepend parameter on certain proprietary requests
  844. * For default commands skip: RFAL_NFCV_PARAM_SKIP
  845. * \param[in] uid : UID of the device to be put to be read
  846. * if UID is provided Addressed mode will be used
  847. * \param[in] data : command parameters append after UID
  848. * \param[in] dataLen : command parameters Len
  849. * \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
  850. * \param[in] rxBufLen : length of rxBuf
  851. * \param[out] rcvLen : number of bytes received
  852. *
  853. * \return ERR_WRONG_STATE : RFAL not initialized or incorrect mode
  854. * \return ERR_PARAM : Invalid parameters
  855. * \return ERR_IO : Generic internal error
  856. * \return ERR_CRC : CRC error detected
  857. * \return ERR_FRAMING : Framing error detected
  858. * \return ERR_PROTO : Protocol error detected
  859. * \return ERR_TIMEOUT : Timeout error
  860. * \return ERR_NONE : No error
  861. *****************************************************************************
  862. */
  863. ReturnCode rfalNfcvPollerTransceiveReq(
  864. uint8_t cmd,
  865. uint8_t flags,
  866. uint8_t param,
  867. const uint8_t* uid,
  868. const uint8_t* data,
  869. uint16_t dataLen,
  870. uint8_t* rxBuf,
  871. uint16_t rxBufLen,
  872. uint16_t* rcvLen);
  873. #endif /* RFAL_NFCV_H */
  874. /**
  875. * @}
  876. *
  877. * @}
  878. *
  879. * @}
  880. */