rfal_dpo.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. * http://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_dpo.h
  27. *
  28. * \author Martin Zechleitner
  29. *
  30. * \brief Dynamic Power adjustment
  31. *
  32. * This module provides an interface to perform the power adjustment dynamically
  33. *
  34. *
  35. * \addtogroup RFAL
  36. * @{
  37. *
  38. * \addtogroup RFAL-HAL
  39. * \brief RFAL Hardware Abstraction Layer
  40. * @{
  41. *
  42. * \addtogroup DPO
  43. * \brief RFAL Dynamic Power Module
  44. * @{
  45. *
  46. */
  47. #ifndef RFAL_DPO_H
  48. #define RFAL_DPO_H
  49. /*
  50. ******************************************************************************
  51. * INCLUDES
  52. ******************************************************************************
  53. */
  54. #include "../platform.h"
  55. #include "../st_errno.h"
  56. /*
  57. ******************************************************************************
  58. * GLOBAL DEFINES
  59. ******************************************************************************
  60. */
  61. #define RFAL_DPO_TABLE_SIZE_MAX 15U /*!< Max DPO table size */
  62. #define RFAL_DPO_TABLE_PARAMETER 3U /*!< DPO table Parameter length */
  63. /*
  64. ******************************************************************************
  65. * GLOBAL TYPES
  66. ******************************************************************************
  67. */
  68. /*! DPO table entry struct */
  69. typedef struct {
  70. uint8_t rfoRes; /*!< Setting for the resistance level of the RFO */
  71. uint8_t inc; /*!< Threshold for incrementing the output power */
  72. uint8_t dec; /*!< Threshold for decrementing the output power */
  73. } rfalDpoEntry;
  74. /*! Function pointer to method doing the reference measurement */
  75. typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t*);
  76. /*
  77. ******************************************************************************
  78. * GLOBAL FUNCTION PROTOTYPES
  79. ******************************************************************************
  80. */
  81. /*!
  82. *****************************************************************************
  83. * \brief Initialize dynamic power table
  84. *
  85. * This function sets the internal dynamic power table to the default
  86. * values stored in rfal_DpoTbl.h
  87. *
  88. *****************************************************************************
  89. */
  90. void rfalDpoInitialize(void);
  91. /*!
  92. *****************************************************************************
  93. * \brief Set the measurement method
  94. *
  95. * This function sets the measurement method used for reference measurement.
  96. * Based on the measurement the power will then be adjusted
  97. *
  98. * \param[in] dpoMeasureFunc: callback of measurement function
  99. *
  100. *****************************************************************************
  101. */
  102. void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc dpoMeasureFunc);
  103. /*!
  104. *****************************************************************************
  105. * \brief Write dynamic power table
  106. *
  107. * Load the dynamic power table
  108. *
  109. * \param[in] powerTbl: location of power Table to be loaded
  110. * \param[in] powerTblEntries: number of entries of the power Table to be loaded
  111. *
  112. * \return ERR_NONE : No error
  113. * \return ERR_PARAM : if configTbl is invalid
  114. * \return ERR_NOMEM : if the given Table is bigger exceeds the max size
  115. *****************************************************************************
  116. */
  117. ReturnCode rfalDpoTableWrite(rfalDpoEntry* powerTbl, uint8_t powerTblEntries);
  118. /*!
  119. *****************************************************************************
  120. * \brief Dynamic power table Read
  121. *
  122. * Read the dynamic power table
  123. *
  124. * \param[out] tblBuf: location to the rfalDpoEntry[] to place the Table
  125. * \param[in] tblBufEntries: number of entries available in tblBuf to place the power Table
  126. * \param[out] tableEntries: returned number of entries actually written into tblBuf
  127. *
  128. * \return ERR_NONE : No error
  129. * \return ERR_PARAM : if configTbl is invalid or parameters are invalid
  130. *****************************************************************************
  131. */
  132. ReturnCode rfalDpoTableRead(rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries);
  133. /*!
  134. *****************************************************************************
  135. * \brief Dynamic power adjust
  136. *
  137. * It measures the current output and adjusts the power accordingly to
  138. * the dynamic power table
  139. *
  140. * \return ERR_NONE : No error
  141. * \return ERR_PARAM : if configTbl is invalid or parameters are invalid
  142. * \return ERR_WRONG_STATE : if the current state is valid for DPO Adjustment
  143. *****************************************************************************
  144. */
  145. ReturnCode rfalDpoAdjust(void);
  146. /*!
  147. *****************************************************************************
  148. * \brief Get Current Dynamic power table entry
  149. *
  150. * Return current used DPO power table entry settings
  151. *
  152. * \return ERR_NONE : Current DpoEntry. This includes d_res, inc and dec
  153. *
  154. *****************************************************************************
  155. */
  156. rfalDpoEntry* rfalDpoGetCurrentTableEntry(void);
  157. /*!
  158. *****************************************************************************
  159. * \brief Dynamic power set enabled state
  160. *
  161. * \param[in] enable: new active state
  162. *
  163. * Set state to enable or disable the Dynamic power adjustment
  164. *
  165. *****************************************************************************
  166. */
  167. void rfalDpoSetEnabled(bool enable);
  168. /*!
  169. *****************************************************************************
  170. * \brief Get the Dynamic power enabled state
  171. *
  172. * Get state of the Dynamic power adjustment
  173. *
  174. * \return true : enabled
  175. * \return false : disabled
  176. *****************************************************************************
  177. */
  178. bool rfalDpoIsEnabled(void);
  179. #endif /* RFAL_DPO_H */
  180. /**
  181. * @}
  182. *
  183. * @}
  184. *
  185. * @}
  186. */