rfal_t1t.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_t1t.h
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief Provides NFC-A T1T convenience methods and definitions
  31. *
  32. * This module provides an interface to perform as a NFC-A Reader/Writer
  33. * to handle a Type 1 Tag T1T (Topaz)
  34. *
  35. *
  36. * \addtogroup RFAL
  37. * @{
  38. *
  39. * \addtogroup RFAL-AL
  40. * \brief RFAL Abstraction Layer
  41. * @{
  42. *
  43. * \addtogroup T1T
  44. * \brief RFAL T1T Module
  45. * @{
  46. *
  47. */
  48. #ifndef RFAL_T1T_H
  49. #define RFAL_T1T_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_T1T_UID_LEN 4 /*!< T1T UID length of cascade level 1 only tag */
  64. #define RFAL_T1T_HR_LENGTH 2 /*!< T1T HR(Header ROM) length */
  65. #define RFAL_T1T_HR0_NDEF_MASK 0xF0 /*!< T1T HR0 NDEF capability mask T1T 1.2 2.2.2 */
  66. #define RFAL_T1T_HR0_NDEF_SUPPORT 0x10 /*!< T1T HR0 NDEF capable value T1T 1.2 2.2.2 */
  67. /*! NFC-A T1T (Topaz) command set */
  68. typedef enum {
  69. RFAL_T1T_CMD_RID = 0x78, /*!< T1T Read UID */
  70. RFAL_T1T_CMD_RALL = 0x00, /*!< T1T Read All */
  71. RFAL_T1T_CMD_READ = 0x01, /*!< T1T Read */
  72. RFAL_T1T_CMD_WRITE_E = 0x53, /*!< T1T Write with erase (single byte) */
  73. RFAL_T1T_CMD_WRITE_NE = 0x1A /*!< T1T Write with no erase (single byte) */
  74. } rfalT1Tcmds;
  75. /*
  76. ******************************************************************************
  77. * GLOBAL TYPES
  78. ******************************************************************************
  79. */
  80. /*! NFC-A T1T (Topaz) RID_RES Digital 1.1 10.6.2 & Table 50 */
  81. typedef struct {
  82. uint8_t hr0; /*!< T1T Header ROM: HR0 */
  83. uint8_t hr1; /*!< T1T Header ROM: HR1 */
  84. uint8_t uid[RFAL_T1T_UID_LEN]; /*!< T1T UID */
  85. } rfalT1TRidRes;
  86. /*
  87. ******************************************************************************
  88. * GLOBAL FUNCTION PROTOTYPES
  89. ******************************************************************************
  90. */
  91. /*!
  92. *****************************************************************************
  93. * \brief Initialize NFC-A T1T Poller mode
  94. *
  95. * This methods configures RFAL RF layer to perform as a
  96. * NFC-A T1T Poller/RW (Topaz) including all default timings
  97. *
  98. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  99. * \return ERR_NONE : No error
  100. *****************************************************************************
  101. */
  102. ReturnCode rfalT1TPollerInitialize(void);
  103. /*!
  104. *****************************************************************************
  105. * \brief NFC-A T1T Poller RID
  106. *
  107. * This method reads the UID of a NFC-A T1T Listener device
  108. *
  109. *
  110. * \param[out] ridRes : pointer to place the RID_RES
  111. *
  112. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  113. * \return ERR_PARAM : Invalid parameter
  114. * \return ERR_NONE : No error
  115. *****************************************************************************
  116. */
  117. ReturnCode rfalT1TPollerRid(rfalT1TRidRes* ridRes);
  118. /*!
  119. *****************************************************************************
  120. * \brief NFC-A T1T Poller RALL
  121. *
  122. * This method send a Read All command to a NFC-A T1T Listener device
  123. *
  124. *
  125. * \param[in] uid : the UID of the device to read data
  126. * \param[out] rxBuf : pointer to place the read data
  127. * \param[in] rxBufLen : size of rxBuf
  128. * \param[out] rxRcvdLen : actual received data
  129. *
  130. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  131. * \return ERR_PARAM : Invalid parameter
  132. * \return ERR_NONE : No error
  133. *****************************************************************************
  134. */
  135. ReturnCode
  136. rfalT1TPollerRall(const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* rxRcvdLen);
  137. /*!
  138. *****************************************************************************
  139. * \brief NFC-A T1T Poller Write
  140. *
  141. * This method writes the given data on the address of a NFC-A T1T Listener device
  142. *
  143. *
  144. * \param[in] uid : the UID of the device to read data
  145. * \param[in] address : address to write the data
  146. * \param[in] data : the data to be written
  147. *
  148. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  149. * \return ERR_PARAM : Invalid parameter
  150. * \return ERR_NONE : No error
  151. *****************************************************************************
  152. */
  153. ReturnCode rfalT1TPollerWrite(const uint8_t* uid, uint8_t address, uint8_t data);
  154. #endif /* RFAL_T1T_H */
  155. /**
  156. * @}
  157. *
  158. * @}
  159. *
  160. * @}
  161. */