rfal_chip.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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_chip.h
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief RF Chip specific Layer
  31. *
  32. * \warning This layer, which provides direct access to RF chip, should
  33. * only be used for debug purposes and/or advanced features
  34. *
  35. *
  36. * \addtogroup RFAL
  37. * @{
  38. *
  39. * \addtogroup RFAL-HAL
  40. * \brief RFAL Hardware Abstraction Layer
  41. * @{
  42. *
  43. * \addtogroup Chip
  44. * \brief RFAL RF Chip Module
  45. * @{
  46. *
  47. */
  48. #ifndef RFAL_CHIP_H
  49. #define RFAL_CHIP_H
  50. /*
  51. ******************************************************************************
  52. * INCLUDES
  53. ******************************************************************************
  54. */
  55. #include "platform.h"
  56. #include "st_errno.h"
  57. #include "rfal_rf.h"
  58. /*****************************************************************************
  59. * RF Chip *
  60. *****************************************************************************/
  61. /*!
  62. *****************************************************************************
  63. * \brief Writes a register on the RF Chip
  64. *
  65. * Checks if the given register is valid and if so, writes the value(s)
  66. * on the RF Chip register
  67. *
  68. * \param[in] reg: register address to be written, or the first if len > 1
  69. * \param[in] values: pointer with content to be written on the register(s)
  70. * \param[in] len: number of consecutive registers to be written
  71. *
  72. *
  73. * \return ERR_PARAM : Invalid register or bad request
  74. * \return ERR_NOTSUPP : Feature not supported
  75. * \return ERR_NONE : Write done with no error
  76. *****************************************************************************
  77. */
  78. ReturnCode rfalChipWriteReg(uint16_t reg, const uint8_t* values, uint8_t len);
  79. /*!
  80. *****************************************************************************
  81. * \brief Reads a register on the RF Chip
  82. *
  83. * Checks if the given register is valid and if so, reads the value(s)
  84. * of the RF Chip register(s)
  85. *
  86. * \param[in] reg: register address to be read, or the first if len > 1
  87. * \param[out] values: pointer where the register(s) read content will be placed
  88. * \param[in] len: number of consecutive registers to be read
  89. *
  90. * \return ERR_PARAM : Invalid register or bad request
  91. * \return ERR_NOTSUPP : Feature not supported
  92. * \return ERR_NONE : Read done with no error
  93. *****************************************************************************
  94. */
  95. ReturnCode rfalChipReadReg(uint16_t reg, uint8_t* values, uint8_t len);
  96. /*!
  97. *****************************************************************************
  98. * \brief Change a register on the RF Chip
  99. *
  100. * Change the value of the register bits on the RF Chip Test set in the valueMask.
  101. *
  102. * \param[in] reg: register address to be modified
  103. * \param[in] valueMask: mask value of the register bits to be changed
  104. * \param[in] value: register value to be set
  105. *
  106. * \return ERR_PARAM : Invalid register or bad request
  107. * \return ERR_NOTSUPP : Feature not supported
  108. * \return ERR_OK : Change done with no error
  109. *****************************************************************************
  110. */
  111. ReturnCode rfalChipChangeRegBits(uint16_t reg, uint8_t valueMask, uint8_t value);
  112. /*!
  113. *****************************************************************************
  114. * \brief Writes a Test register on the RF Chip
  115. *
  116. * Writes the value on the RF Chip Test register
  117. *
  118. * \param[in] reg: register address to be written
  119. * \param[in] value: value to be written on the register
  120. *
  121. *
  122. * \return ERR_PARAM : Invalid register or bad request
  123. * \return ERR_NOTSUPP : Feature not supported
  124. * \return ERR_NONE : Write done with no error
  125. *****************************************************************************
  126. */
  127. ReturnCode rfalChipWriteTestReg(uint16_t reg, uint8_t value);
  128. /*!
  129. *****************************************************************************
  130. * \brief Reads a Test register on the RF Chip
  131. *
  132. * Reads the value of the RF Chip Test register
  133. *
  134. * \param[in] reg: register address to be read
  135. * \param[out] value: pointer where the register content will be placed
  136. *
  137. * \return ERR_PARAM :Invalid register or bad request
  138. * \return ERR_NOTSUPP : Feature not supported
  139. * \return ERR_NONE : Read done with no error
  140. *****************************************************************************
  141. */
  142. ReturnCode rfalChipReadTestReg(uint16_t reg, uint8_t* value);
  143. /*!
  144. *****************************************************************************
  145. * \brief Change a Test register on the RF Chip
  146. *
  147. * Change the value of the register bits on the RF Chip Test set in the valueMask.
  148. *
  149. * \param[in] reg: test register address to be modified
  150. * \param[in] valueMask: mask value of the register bits to be changed
  151. * \param[in] value: register value to be set
  152. *
  153. * \return ERR_PARAM : Invalid register or bad request
  154. * \return ERR_NOTSUPP : Feature not supported
  155. * \return ERR_OK : Change done with no error
  156. *****************************************************************************
  157. */
  158. ReturnCode rfalChipChangeTestRegBits(uint16_t reg, uint8_t valueMask, uint8_t value);
  159. /*!
  160. *****************************************************************************
  161. * \brief Execute command on the RF Chip
  162. *
  163. * Checks if the given command is valid and if so, executes it on
  164. * the RF Chip
  165. *
  166. * \param[in] cmd: direct command to be executed
  167. *
  168. * \return ERR_PARAM : Invalid command or bad request
  169. * \return ERR_NOTSUPP : Feature not supported
  170. * \return ERR_NONE : Direct command executed with no error
  171. *****************************************************************************
  172. */
  173. ReturnCode rfalChipExecCmd(uint16_t cmd);
  174. /*!
  175. *****************************************************************************
  176. * \brief Set RFO
  177. *
  178. * Sets the RFO value to be used when the field is on (unmodulated/active)
  179. *
  180. * \param[in] rfo : the RFO value to be used
  181. *
  182. * \return ERR_IO : Internal error
  183. * \return ERR_NOTSUPP : Feature not supported
  184. * \return ERR_NONE : No error
  185. *****************************************************************************
  186. */
  187. ReturnCode rfalChipSetRFO(uint8_t rfo);
  188. /*!
  189. *****************************************************************************
  190. * \brief Get RFO
  191. *
  192. * Gets the RFO value used used when the field is on (unmodulated/active)
  193. *
  194. * \param[out] result : the current RFO value
  195. *
  196. * \return ERR_IO : Internal error
  197. * \return ERR_NOTSUPP : Feature not supported
  198. * \return ERR_NONE : No error
  199. *****************************************************************************
  200. */
  201. ReturnCode rfalChipGetRFO(uint8_t* result);
  202. /*!
  203. *****************************************************************************
  204. * \brief Measure Amplitude
  205. *
  206. * Measures the RF Amplitude
  207. *
  208. * \param[out] result : result of RF measurement
  209. *
  210. * \return ERR_IO : Internal error
  211. * \return ERR_NOTSUPP : Feature not supported
  212. * \return ERR_NONE : No error
  213. *****************************************************************************
  214. */
  215. ReturnCode rfalChipMeasureAmplitude(uint8_t* result);
  216. /*!
  217. *****************************************************************************
  218. * \brief Measure Phase
  219. *
  220. * Measures the Phase
  221. *
  222. * \param[out] result : result of Phase measurement
  223. *
  224. * \return ERR_IO : Internal error
  225. * \return ERR_NOTSUPP : Feature not supported
  226. * \return ERR_NONE : No error
  227. *****************************************************************************
  228. */
  229. ReturnCode rfalChipMeasurePhase(uint8_t* result);
  230. /*!
  231. *****************************************************************************
  232. * \brief Measure Capacitance
  233. *
  234. * Measures the Capacitance
  235. *
  236. * \param[out] result : result of Capacitance measurement
  237. *
  238. * \return ERR_IO : Internal error
  239. * \return ERR_NOTSUPP : Feature not supported
  240. * \return ERR_NONE : No error
  241. *****************************************************************************
  242. */
  243. ReturnCode rfalChipMeasureCapacitance(uint8_t* result);
  244. /*!
  245. *****************************************************************************
  246. * \brief Measure Power Supply
  247. *
  248. * Measures the Power Supply
  249. *
  250. * \param[in] param : measurement parameter (chip specific)
  251. * \param[out] result : result of the measurement
  252. *
  253. * \return ERR_IO : Internal error
  254. * \return ERR_NOTSUPP : Feature not supported
  255. * \return ERR_NONE : No error
  256. *****************************************************************************
  257. */
  258. ReturnCode rfalChipMeasurePowerSupply(uint8_t param, uint8_t* result);
  259. #endif /* RFAL_CHIP_H */
  260. /**
  261. * @}
  262. *
  263. * @}
  264. *
  265. * @}
  266. */