rfal_t1t.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. {
  70. RFAL_T1T_CMD_RID = 0x78, /*!< T1T Read UID */
  71. RFAL_T1T_CMD_RALL = 0x00, /*!< T1T Read All */
  72. RFAL_T1T_CMD_READ = 0x01, /*!< T1T Read */
  73. RFAL_T1T_CMD_WRITE_E = 0x53, /*!< T1T Write with erase (single byte) */
  74. RFAL_T1T_CMD_WRITE_NE = 0x1A /*!< T1T Write with no erase (single byte) */
  75. } rfalT1Tcmds;
  76. /*
  77. ******************************************************************************
  78. * GLOBAL TYPES
  79. ******************************************************************************
  80. */
  81. /*! NFC-A T1T (Topaz) RID_RES Digital 1.1 10.6.2 & Table 50 */
  82. typedef struct
  83. {
  84. uint8_t hr0; /*!< T1T Header ROM: HR0 */
  85. uint8_t hr1; /*!< T1T Header ROM: HR1 */
  86. uint8_t uid[RFAL_T1T_UID_LEN]; /*!< T1T UID */
  87. } rfalT1TRidRes;
  88. /*
  89. ******************************************************************************
  90. * GLOBAL FUNCTION PROTOTYPES
  91. ******************************************************************************
  92. */
  93. /*!
  94. *****************************************************************************
  95. * \brief Initialize NFC-A T1T Poller mode
  96. *
  97. * This methods configures RFAL RF layer to perform as a
  98. * NFC-A T1T Poller/RW (Topaz) including all default timings
  99. *
  100. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  101. * \return ERR_NONE : No error
  102. *****************************************************************************
  103. */
  104. ReturnCode rfalT1TPollerInitialize( void );
  105. /*!
  106. *****************************************************************************
  107. * \brief NFC-A T1T Poller RID
  108. *
  109. * This method reads the UID of a NFC-A T1T Listener device
  110. *
  111. *
  112. * \param[out] ridRes : pointer to place the RID_RES
  113. *
  114. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  115. * \return ERR_PARAM : Invalid parameter
  116. * \return ERR_NONE : No error
  117. *****************************************************************************
  118. */
  119. ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes );
  120. /*!
  121. *****************************************************************************
  122. * \brief NFC-A T1T Poller RALL
  123. *
  124. * This method send a Read All command to a NFC-A T1T Listener device
  125. *
  126. *
  127. * \param[in] uid : the UID of the device to read data
  128. * \param[out] rxBuf : pointer to place the read data
  129. * \param[in] rxBufLen : size of rxBuf
  130. * \param[out] rxRcvdLen : actual received data
  131. *
  132. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  133. * \return ERR_PARAM : Invalid parameter
  134. * \return ERR_NONE : No error
  135. *****************************************************************************
  136. */
  137. ReturnCode rfalT1TPollerRall( const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rxRcvdLen );
  138. /*!
  139. *****************************************************************************
  140. * \brief NFC-A T1T Poller Write
  141. *
  142. * This method writes the given data on the address of a NFC-A T1T Listener device
  143. *
  144. *
  145. * \param[in] uid : the UID of the device to read data
  146. * \param[in] address : address to write the data
  147. * \param[in] data : the data to be written
  148. *
  149. * \return ERR_WRONG_STATE : RFAL not initialized or mode not set
  150. * \return ERR_PARAM : Invalid parameter
  151. * \return ERR_NONE : No error
  152. *****************************************************************************
  153. */
  154. ReturnCode rfalT1TPollerWrite( const uint8_t* uid, uint8_t address, uint8_t data );
  155. #endif /* RFAL_T1T_H */
  156. /**
  157. * @}
  158. *
  159. * @}
  160. *
  161. * @}
  162. */